3 Replies Latest reply on Mar 1, 2008 2:26 PM by pete007

    Calling class method on form entry


      Hi, I think it is a very simple question, but I not for me. :)

      I have split a working form in two parts and something is missing now.

      Here is the working original:

      the selectandshow.xhtml

      <h:form id="routerForm">
        Start: <h:outputText escape="false" value="${router.startNodesSelectBox}"/>
        End: <h:outputText escape="false" value="${router.endNodesSelectBox}"/>
        <h:commandButton id="findroute" value="find a route" action="#{router.findroute}"/>
        <h:graphicImage value="../images/#{router.startImage}"/>
        <h:graphicImage value="../images/#{router.endImage}"/>

      And that is, what I made out of it:

      the selectform.xhtml:

      <h:form id="routerForm">
        Start: <h:outputText escape="false" value="${router.startNodesSimple}"/>
        End: <h:outputText escape="false" value="${router.endNodesSimple}"/>
        <h:commandButton id="findroute" value="find a route" action="/showonlyform.xhtml"/>

      the showonlyform.xhtml:

        Start: #{router.start}
        <h:graphicImage value="../images/#{router.startImage}"/>
        End: #{router.end}
        <h:graphicImage value="../images/#{router.endImage}"/>

      I had to replace the action parameter to point to the second form and now nobody is calling the router.findRoute()-method. So I only see the two parameters start and end from the selectboxes, but the images are empty because they were not calculated.

      I would like to call the method before rendering of the second form. Where and how would I do this best?

      Thanks in advance, Peter

        • 1. Re: Calling class method on form entry

          Maybe that was too long .. or too simple? .. here's a shorter try:

          I got this in my form:

          Start: #{router.start}
          <h:graphicImage value="../images/#{router.startImage}"/>

          The content of the variable startImage is calculated by a method router.findRoute();

          Assuming, I call it by a GET request like this:


          I only see the String Start: Terminal1, but there is no image.

          I tried to place a page action in pages.xml to call the method:

          <page view-id="showonlyform*" action="#{router.findRoute}">
             <param name="start" value="#{router.start}"/>

          But there is still no image. The method isn't called. Nothing in the logs.

          Any ideas, where to look next?

          • 2. Re: Calling class method on form entry
            Kariem Hussein Newbie

            For your second example: is it possible that you are missing the / in front of the view-id? Shouldn't it be

            <page view-id="/showonlyform*" …

            Just guessing, because all my rules are setup this way. For the page configuration I prefer using <view-id>.page.xml. Shouldn't an error be raised, just the way you receive an error in <s:link/> if the view-id does not start with a slash?

            Did you try calling the action directly, and just returning the view id from the action? Or instead, returning an identifier which is used in navigation rules?

            • 3. Re: Calling class method on form entry

              You're right, I only forgot the slash, will check this later, when I'm at home, thanks a lot.

              I didn't get any error messages, but I think, that you cannot force a slash at the beginning because the term is a regexp and could be like "*Edit*" or some weird stuff, which is valid too. What would a view-id without slash reference to? If there is nothing, that can be accessed this way, it can be deleted.