Announcement Announcement Module
Collapse
No announcement yet.
JSP Renderers Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JSP Renderers

    Does Spring Surf support the JSP Renderers documented for Alfresco Surf here: http://wiki.alfresco.com/wiki/Surf_P...#JSP_Renderers

    I have done some investigating and I do not see any Spring Surf documentation or examples on JSP Renderers. In fact, I was a bit alarmed to see that the org.springframework.extensions.surf.render.RenderS ervice.renderJspPage() method is commented out in the source code (on the trunk).

    Thanks,

    Bob
    Last edited by BoJo; Aug 26th, 2010, 08:09 PM.

  • #2
    spring-travel sample app uses a JSP Renderer

    I see a JSP Renderer configured for the spring-surf-application-spring-travel sample project provided with the source (https://src.springframework.org/svn/se-surf/trunk). The login-dialog.xml component-type declaration (under spring-surf-applications/spring-surf-application-spring-travel/src/main/webapp/WEB-INF/classes/surf/site/component-types) contains the following:

    ----------------------------------
    <!-- Define the rendering processors for this component type -->
    <processor mode="view">
    <id>jsp</id>
    <jsp-path>/WEB-INF/jsp/login-dialog.jsp</jsp-path>
    </processor>
    ----------------------------------

    The login page (spring-surf-applications/spring-surf-application-spring-travel/src/main/webapp/WEB-INF/pages/login.xml) then defines the following component:

    ----------------------------------
    <component>
    <region-id>body</region-id>
    <component-type-id>login-dialog</component-type-id>
    </component>
    ----------------------------------

    Makes sense. I see the login-dialog.jsp page as weil.

    I'm now looking into:

    1) How do I wire-in a Java controller?

    Using the "root objects" the Surf MVC framework wires in. The equivalent to "context", "page", "url" in the Web Scripts redering framework.

    2) Accessing the model created in the Java controller in the JSP

    Comment


    • #3
      Hi,

      Yes you can still use JSP pages in Surf, as you have noted there is an example in one of the sample apps, also Alfresco Share uses a single JSP based site-index page. The JSPProcessor class still exists - that commented out code you can see has been refactored out and I will remove the detritus for the RC1 release.

      You can retrieve the Surf RequestContext object thus:

      Code:
      RequestContext context = (RequestContext)request.getAttribute(RequestContext.ATTR_REQUEST_CONTEXT);
      The support for other model objects needs to be improved for JSP (and other languages such as Groovy), but you can retrieve a lot from the RequestContext.

      Cheers,

      Kev

      Comment


      • #4
        !

        Indeed. Reference THIS post to see how I got JSPs working.

        Thanks Kev!

        Comment


        • #5
          I am curious what "support for other model objects needs to be improved" means in the above response. It is true that you can retrieve a lot of information from the RequestContext. However, I need to pass specific ("custom") information to the JSP.

          You state that I can access the RequestContext in the JSP:

          Code:
          RequestContext context = (RequestContext)request.getAttribute(RequestContext.ATTR_REQUEST_CONTEXT);
          The JavaDoc for org.springframework.extensions.surf. RequestContext lists a getValuesMap() method:
          -----------------------------------------
          Map<String,Serializable>
          getValuesMap()
          Returns the underlying map of the custom key/values pairs stored on this RequestContext instance.
          -----------------------------------------

          I was hoping this would access the Map returned from the executeImp() method in a DeclarativeWebScript implementation. Is this not the case?

          If not, what is the best practice for passing data between a Java DeclarativeWebScript an a JSP Renderer?

          Thanks,

          Bob

          P.S. I can't test JSP model access at the moment because I don't have a working example of combining a JSP Renderer with a Java DeclarativeWebScript (see THIS post))

          Comment

          Working...
          X