Announcement Announcement Module
Collapse
No announcement yet.
DWR + Spring Portlet MVC Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • DWR + Spring Portlet MVC

    hi,

    i'm using dwr with portlet mvc and now try to use the new dwr2 features to configure dwr using spring namespaces.

    the dwr docu sais:
    The controller tag

    You must declare one <dwr:controller id="dwrController" debug="true" /> tag. This tag does not allow inner tags. In Spring MVC, for each controller you have to map the URLs that it will handle. The simplest way is probably declaring a SimpleUrlHandlerMapping. DWR needs mappings for the following URLs: /engine.js, /interface.js, /call/**, /interface/**. Remember that a DWR Controller is just needed (and useful) in Spring MVC environments (use the servlet in other cases) and this way you get the number of other related Spring services (ie localization).
    how to adapt this to portlet mvc? can i use SimpleUrlHandlerMapping in PortletMVC world?

    thanks, raphael

  • #2
    I assume you are talking about Controllers that would be responding to the actual AJAX requests being made from DWR.

    There is no way for AJAX requests to be directly handled by JSR 168 Portlets. This changes in JSR 286 (Portlet 2.0) which provides a new "resource" phase, but we are still waiting for that spec to go final, so it will be a while before there are usable implementations.

    The normal way to deal with this is with a parallel servlet in the same web application that shares data with the portlet via the session. That servlet can be built using regular Spring MVC just like in a normal web application. Getting portlets and servlets to share session data can be a bit tricky -- there is some documentation on that in the Spring Portlet MVC FAQ.

    One of the tricker concerns here is security -- you need to make sure that the servlet is properly relying on authentication to the portal and not just blindly serving up potentially confidential data. This isn't generally a big deal to implement, but critical to build and test properly. There are some useful portlet features coming in Spring Security 2.0 (formerly known as Acegi Security) which will be helpful with this in the near future.

    Finally, there are some extra considerations regarding namespacing when working with Javascript inside a portlet. Remember that there can be multiple portlets on the same page -- even multiple instances of the same portlet. So it is critical to namespace everything within the Javascript using the value from either the RenderResponse.getNamespace() method or the <portlet:namespace/> JSP tag.

    Comment


    • #3
      Originally posted by johnalewis View Post
      I assume you are talking about Controllers that would be responding to the actual AJAX requests being made from DWR.

      There is no way for AJAX requests to be directly handled by JSR 168 Portlets.
      Why is that? As long as the AJAX requests return actual markup it should be fine, shouldn't it?

      Joerg

      Comment


      • #4
        What URL would you use from AJAX to request either XML data or HTML markup from your Portlet? If you construct a PortletURL, that URL will send you back a complete portal page -- not just data/markup from your portlet. If you construct a URL that goes straight at your portlet webapp, then you need a servlet that will respond to it.

        Now, there are some portals that have custom window states where all the portal "chrome" is removed (sometimes called "Exclusive" window state) and the resulting portal markup is purely the results of the portlet. In those portals, you could use this window state to get data/markup from the portlet. But this is not a standard mechanism.

        Comment


        • #5
          thanks for your replies.

          atm i'm using a parallel DWR servlet and a servlet-mapping, which maps the .js files to the servlet. that's ok - but of course managing everything with my portletMVC controllers would be much nicer.

          so i had a ray of hope that i could map the .js files to my controller like it is proposed for webmvc with the simpleurlhandlermapping.

          My current solution has two major disadvantages:
          * the portlet tags can't be used in the ajax markup (i have to give ajax portlet:actionurls and portlet:namespaces by hand
          * spring localization can't be used, as i the locale is not available

          Comment


          • #6
            Yeah, without some kind of proprietary tricks, there won't be any way to respond to AJAX requests from portlet controllers.

            I don't think there's anything you can do about the portlet taglib. As you've said, you'll have to generate the URLs and get the namespace during the initial portlet request.

            As for the locale, you should be able to set the LocaleContextHolder in some kind of Interceptor for your servlet Controllers. You could either pass around the locale just like you are passing around the URLs, or you could park it in the session or something.

            Comment


            • #7
              Hi,
              Can i get the complete configuration for spring portlet MVC and DWR.
              Specially what to write in web.xml and portlet.xml etc

              Comment

              Working...
              X