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

  • Spring Portlet MVC, Spring form taglib and Portlet taglib

    Hi,

    I have a problem which looks not really Spring specific, but more like a general problem with tags in JSPs. I want to put a form into a Portlet and therefore use Spring's <form:form>. I need to set its @action attribute to the <portlet:actionUrl>:

    Code:
    <form:form action="<portlet:actionURL>
                    <portlet:param name="action" value="myAction"/>
                    <portlet:param name="actionParam" value="${command.myParam}"/>
                  </portlet:actionURL>">
    Unfortunately, this does not work. From the error message

    Code:
    org.apache.jasper.JasperException: /html/viewMyActionForm.jsp(17,43) equal symbol expected
            at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
            at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
            at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:90)
            at org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:193)
            at org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:143)
            at org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1328)
            at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1560)
            at org.apache.jasper.compiler.Parser.parse(Parser.java:126)
    ((17,43) points to the third ") I'd guess it's a general problem putting tags (not directives or similar) into tags. Is there any work around on the JSP level?

    I only know a work around on the HTML level that I do not really like: putting <portlet:actionUrl> into a JS function and setting @action of <form:form> via @onSubmit by calling that JS function.

    Thx in advance,
    Jörg

  • #2
    Looks like a problem with nested quotes. Maybe simply using single quotes in the outside set would so it? More readable: have you tried using c:set to create a variable with value equal to your action, and then putting that in the action= attribute of the form tag?

    Comment


    • #3
      Yes, indeed, just using single quotes works - to some extent It makes the error going away - but the content gets not evaluated, i.e. I have <portlet:actionURL> and so on in my HTML code.

      2nd try with <c:set> and its @value attribute: same effect.

      3rd try using <c:set> and nested tag <portlet:actionURL>: works! So at the end it looks like:

      Code:
      <c:set var="portletActionURL">
        <portlet:actionURL>
          <portlet:param name="action" value="myAction"/>
        </portlet:actionURL>
      </c:set>
      
      <form:form action="${portletActionURL}">
      And this is of course also much more readable!

      Thanks David.

      Jörg

      Comment


      • #4
        This seems a little simpler:

        Code:
        <portlet:actionURL var="actionURL">
          <portlet:param name="action" value="myAction"/>
        </portlet:actionURL>
        
        <form:form action="${actionURL}">

        Comment


        • #5
          This A simple solution but have a doubt in param attributes

          Can someone comment on how <portletaram name="action" value="myAction"/> will be rendered in <portlet:actionURL var="actionURL"> tag and where will it be captured, as I am new to portlet technology, I am using Generic Portlet and according to it this will be captured in processAction() of the class forwarded.

          And my other doubt is, If I need to forward action to another class instead of what specified in the portlet.xml, what I need to do and how can I achieve that.

          Thanks,

          Comment

          Working...
          X