Announcement Announcement Module
Collapse
No announcement yet.
Fragment and Ajax requests Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fragment and Ajax requests

    I've just upgraded form SWF 1.0 to 2.0 and I'd like to refresh just a fragment of my page using Ajax.
    But it seems that I have to use a template engine like Tiles.
    I'm currently using Sitemesh and it works perfectly for me, I don't want to switch to Tiles :-(

    Can't we imagine to refresh a fragment that is in fact just a element of the DOM referenced by its ID ?
    It would be cool if the fragment ID was referring to a div ID.

    Or maybe we could have an approach like AjaxAnyWhere where you use a taglib to define you zone to reload.

    Is it easy to use Tiles and Sitemesh on the same application ?
    If yes, I could just define my fragment using Tiles and the rest of the application will continue to use Sitemesh...

    Cedric

  • #2
    Sitemesh + tiles

    Hi,

    To answer your questions based on our experiences:

    I've just upgraded form SWF 1.0 to 2.0 and I'd like to refresh just a fragment of my page using Ajax.
    But it seems that I have to use a template engine like Tiles.
    I'm currently using Sitemesh and it works perfectly for me, I don't want to switch to Tiles :-( . Is it easy to use Tiles and Sitemesh on the same application ?
    If yes, I could just define my fragment using Tiles and the rest of the application will continue to use Sitemesh...
    We use sitemesh and tiles both, and they are coexisting peacefully. You can think of tiles as page composition mechanism, where we define fragments and then use ajax to update the fragments. Sitemesh is more of a page decoration mechanism where we add footers, headers, menu bar and so on. Sitemesh is used only for main page refreshes, and not applied for ajax loads.

    Although I understand that with Tiles supporting abstract definitions, sitemesh is no longer needed, as you can achieve the standard page layout and decorations very much using tiles abstract template instead of sitemesh. It may very well help performance and scalability a bit too, since you would avoid an extra parsing cycle introduced by the sitemesh filter.

    Can't we imagine to refresh a fragment that is in fact just a element of the DOM referenced by its ID ?
    It would be cool if the fragment ID was referring to a div ID. Or maybe we could have an approach like AjaxAnyWhere where you use a taglib to define you zone to reload.
    Exactly, I too echo your points. Currently we are use jquery functions such as get and formSubmit to refresh particular tags. Its so simple by writing wrapper functions that look like below that hides the jquery internals from the developers. When Spring JS starts providing a similar format, we will replace our underlying implementations.

    function ajaxget(url, targetDivName)
    function ajaxformSubmit(formName, targetDivName, actionUrl)

    Comment


    • #3
      Thanks for your input :-)

      Currently we are use jquery functions such as get and formSubmit to refresh particular tags.
      I was also thinking about a system to refresh a fragment of the page with an Ajax framework (like jquery for you) but if SWF is going into this direction, I prefer to wait and see what they're doing...

      Although I understand that with Tiles supporting abstract definitions, sitemesh is no longer needed, as you can achieve the standard page layout and decorations very much using tiles abstract template instead of sitemesh. It may very well help performance and scalability a bit too, since you would avoid an extra parsing cycle introduced by the sitemesh filter.
      What do you mean by Tiles supporting abstract definitions ?
      I didn't want to use Tiles at the beginning of my project because, I don't want to define each new page in a XML tile configuration file. Sitemesh decorate all pages without any supplementary configuration...

      Comment


      • #4
        What do you mean by Tiles supporting abstract definitions ?
        Just like an abstract class, you can define a page (similar to your sitemesh decoration page) that contains header, footer, css, etc. Instead of decorator body tag, it has the insert tile attribute. And just like abstract method, you dont need to specify one upfront. Once the page definition is used in actual functional jsps, the insert tile attribute can be filled by the actual content. Tough to explain, but have a look at spring webflow mvc booking example, especially standard.jsp on how the parallel the sitemesh and tile mechanisms are. Actually, i took just about an hour converting some 7 pages from sitemesh to tiles to align with the spring webflow booking mvc example. All you need to do is strip html off the individual jsps, just convert some sitemesh tags in your decoration page to insert tiles, and define the views.xml. Just one drawback, header title had to be same for all pages, and we just kept it the application name. But it gives a big advantage in using page composition pattern.

        I didn't want to use Tiles at the beginning of my project because, I don't want to define each new page in a XML tile configuration file.
        Well, thats your choice, and depends on your requirement. If your page is composed of fragments, where you wish to refresh fragments, independently through ajax, page composition pattern is the key, and tiles supports it quite well. And having to define one time tile definition in views.xml is not such as criminal thing to do. We got over it quickly and make it a part of our dev paradigm. We found tile composition extremely beneficial to support the partial fragment refresh through Ajax as explained above.

        I dont think in either sitemesh or tiles, there is a huge difference in configuration. You have to anyway write decorators.xml, and a very tiresome job of excluding the ajax url requests you dont want sitemesh to decorate. But you gain by reducing the cpu cycles sitemesh needs to parse your page output and then put its decoration. I am in favor of doing some extra in dev to save CPU cycles if I can.

        Comment

        Working...
        X