10 Replies Latest reply on Sep 30, 2009 4:38 PM by Kevin B

    form input not propagating to action pojo

    Kevin B Newbie
      Hello.

      I could really use some assistance at this point as I feel I am hitting a brick wall.

      I am using Seam 2.1.2 on JBoss 4.3 EAP with JDK 1.5.0_19 to compile.  When I hit the purchase button in the example below, the page re-displays but I receive nothing in the logs at all and the desired effect surely does not happen (whether I enter an invalid value or a valid one).  It appears that the input is lost and the confirm action is never called.

      managerda.xhtml
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:s="http://jboss.com/products/seam/taglib"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:rich="http://richfaces.org/rich"
                      xmlns:c="http://java.sun.com/jstl/core"
                      xmlns:a="http://richfaces.org/a4j"
                      template="../layout/template_railed.xhtml">
        <ui:param name="headTitle" value="#{ msg['rda.headTitle'] }"/>
        <ui:param name="bodyTitle" value="#{ msg['rda.bodyTitle'] }"/>
       
        <ui:define name="body">

        <h:messages styleClass="error-message"/>
      ...
        <h:form id="rdaPurchaseForm">
          <table cellpadding="0" width="100%">
            <tr>
              <td class="text-darkgrey">
                Enter number of 5-hour blocks to purchase:&#160;
                <h:inputText id="blocks"
                             value="#{ rdaAction.blocks }"
                             maxlength="2" size="4"/>        
                &#160;
                <h:commandButton action="#{ rdaAction.prePurchConfirm }"
                                 value="Purchase" id="purchase"
                                 image="/img/btn_purchase.gif"
                                 alt="purchase"/>                
                <br />
                <span class="text-darkgrey">$#{ user.rdaBlockPurchasePrice }
                per block will be added to your bill.</span>
              </td>
            </tr>
          </table>
        </h:form>  
      ...
        </ui:define>
       
      </ui:composition>

      RdaAction.java
      @Name( "rdaAction" )
      @Scope( ScopeType.CONVERSATION )
      public class RdaAction
      {
         @Logger
         private static Log log;

         @Out( required = false )
         protected RdaSummary rdaSummary;

         /** The number of blocks the user wants to purchase. */
         @In( required = false )
         @Out( required = false, scope = ScopeType.CONVERSATION )
         protected String purchaseBlocks;

         /** The blocks the user entered. */
         private String blocks;

         @In
         private FacesMessages facesMessages;

         @In
         private UserProfile user;

         @In
         private FacesContext facesContext;
      ...

         public String getBlocks( )
         {
            return blocks;
         }

         public void setBlocks( String blocks )
         {
            this.blocks = blocks;
         }

         @Begin( join = true )
         public String prePurchConfirm(  )
         {
            log.info( "entry for blocks is: " + StringUtils.stripToEmpty( blocks ) );
           
            if( StringUtils.isEmpty( blocks ) ||
                  "0".equals( blocks.trim(  ) ) )
            {
               facesMessages.add(
                     "You must enter the number of blocks to purchase." );
               log.info(
                     "Blocks to purchase for RDA are blank or zero." );

               return null;
            }

            purchaseBlocks = blocks.trim(  );

            return "purchaserdaconfirm";
         }
      ...

      pages.xml
         <page view-id="/rda/managerda.xhtml" action="#{ rdaAction.preManageRda }">
            <navigation from-action="#{ rdaAction.prePurchConfirm }">
               <rule if-outcome="purchaserdaconfirm">
                  <redirect view-id="/rda/purchaserdaconfirm.xhtml"/>
               </rule>
            </navigation>
         </page>



       
        • 1. Re: form input not propagating to action pojo
          Stuart Douglas Master

          I don't suppose you also have a form tag in your template_railed.xhtml file as well? nestled form tags will cause this.

          • 2. Re: form input not propagating to action pojo
            Kevin B Newbie
            No there is no form tag inside template_railed.xhtml.  The template does however use a custom tag that spits out our menus, headers and footers for every page.  It uses a <form ...> tag for a search bar.  I don't believe that is causing an issue at all as other pages have been able to submit.

            I think the culprit could be this at the end of the managerda.xhtml:

              <a:form id="rdaActivityForm">
                <div style="text-align:center;">
                  <a:commandButton action="#{ rdaAction.retrieveRdaSummary }" 
                                           image="/img/btn_previous.gif"   
                                         reRender="summaryData,activityItem,rdaActivityForm,emptyActivityItem,activityReport">              
                       <a:actionparam name="offsetparam" value="#{ (rdaAction.offset+1) }"/>
                    </a:commandButton>
                    &#160;&#160;&#160;&#160;
                  <a:commandButton action="#{ rdaAction.retrieveRdaSummary }"
                                             image="/img/btn_next.gif"
                                             rendered="#{ rdaAction.offset != '0' }"    
                                           reRender="summaryData,activityItem,rdaActivityForm,emptyActivityItem,activityReport">             
                    <a:actionparam name="offsetparam" value="#{ (rdaAction.offset-1) }"/>
                    </a:commandButton>            
                </div>
              </a:form>



            I think it would be a major limitation to not be able to use <h:form> twice on the same page or not be able to use <a:form> with <h:form>

            How should this be handled?
            • 4. Re: form input not propagating to action pojo
              Julien Kronegg Novice

              As Stuart wrote, this behavior is typically caused by nested form tags. You can have two forms on the same page but not a form inside another form.

              • 5. Re: form input not propagating to action pojo
                Kevin B Newbie

                That's great that we established that.  I have no nested forms on the page.


                Back to my original question... what is going on here?  Why is confirm action not being called?


                Thanks in advance.

                • 6. Re: form input not propagating to action pojo
                  Julien Kronegg Novice

                  Can you please follow the steps given in Seam for dummies to determine more precisely the behavior (is the HTTP POST submitted? are the JSF lifecycle INVOKE phase called?)?


                  If it does not help, you could post your full code : managerda.xhtml, template_railed.xhtml and RdaAction.java.

                  • 7. Re: form input not propagating to action pojo
                    Kevin B Newbie
                    I am using the HttpRequestDebugFilter and it is showing the form parameters are set appropriately; however, the action is never called.

                    2009-09-29 16:15:22,124 INFO - ajp-172.18.100.37-8009-1 - com.cox.chsi.app.HttpRequestDebugFilter -   parameters:
                    2009-09-29 16:15:22,124 INFO - ajp-172.18.100.37-8009-1 - com.cox.chsi.app.HttpRequestDebugFilter -     javax.faces.ViewState = [j_id2]
                    2009-09-29 16:15:22,124 INFO - ajp-172.18.100.37-8009-1 - com.cox.chsi.app.HttpRequestDebugFilter -     rdaPurchaseForm = [rdaPurchaseForm]
                    2009-09-29 16:15:22,125 INFO - ajp-172.18.100.37-8009-1 - com.cox.chsi.app.HttpRequestDebugFilter -     rdaPurchaseForm:blocks = [4]
                    2009-09-29 16:15:22,125 INFO - ajp-172.18.100.37-8009-1 - com.cox.chsi.app.HttpRequestDebugFilter -     rdaPurchaseForm:purchase.x = [29]
                    2009-09-29 16:15:22,125 INFO - ajp-172.18.100.37-8009-1 - com.cox.chsi.app.HttpRequestDebugFilter -     rdaPurchaseForm:purchase.y = [10]
                    2009-09-29 16:15:22,127 DEBUG - ajp-172.18.100.37-8009-1 - org.jboss.seam.init.Initialization - Using Java hot deploy


                    • 8. Re: form input not propagating to action pojo
                      Julien Kronegg Novice

                      It seems that the correct form is submitted (rdaPurchaseForm). Two questions:



                      • what about the JSF phases (change the log level according to Seam for dummies to see them)

                      • can you post the HTML page source code (but please use the forum formated text) ?

                      • 9. Re: form input not propagating to action pojo
                        Kevin B Newbie


                         2009-09-29 16:15:22,112 INFO - ajp-172.18.100.37-8009-1 - com.co.chsi.app.HttpRequestDebugFilter - request: method=POST, URL=/internettools/rda/managerda.cox
                        2009-09-29 16:15:22,113 INFO - ajp-172.18.100.37-8009-1 - com.co.chsi.app.HttpRequestDebugFilter -   contentType=application/x-www-form-urlencoded, characterEncoding=null)
                        ...
                        2009-09-29 16:15:22,124 INFO - ajp-172.18.100.37-8009-1 - com.co.chsi.app.HttpRequestDebugFilter -   parameters:
                        2009-09-29 16:15:22,124 INFO - ajp-172.18.100.37-8009-1 - com.co.chsi.app.HttpRequestDebugFilter -     javax.faces.ViewState = [j_id2]
                        2009-09-29 16:15:22,124 INFO - ajp-172.18.100.37-8009-1 - com.co.chsi.app.HttpRequestDebugFilter -     rdaPurchaseForm = [rdaPurchaseForm]
                        2009-09-29 16:15:22,125 INFO - ajp-172.18.100.37-8009-1 - com.co.chsi.app.HttpRequestDebugFilter -     rdaPurchaseForm:blocks = [4]
                        2009-09-29 16:15:22,125 INFO - ajp-172.18.100.37-8009-1 - com.co.chsi.app.HttpRequestDebugFilter -     rdaPurchaseForm:purchase.x = [29]
                        2009-09-29 16:15:22,125 INFO - ajp-172.18.100.37-8009-1 - com.co.chsi.app.HttpRequestDebugFilter -     rdaPurchaseForm:purchase.y = [10]
                        2009-09-29 16:15:22,127 DEBUG - ajp-172.18.100.37-8009-1 - org.jboss.seam.init.Initialization - Using Java hot deploy
                        2009-09-29 16:15:22,183 DEBUG - ajp-172.18.100.37-8009-1 - org.jboss.seam.contexts.FacesLifecycle - >>> Begin JSF request for /internettools/rda/managerda.cox
                        2009-09-29 16:15:22,196 DEBUG - ajp-172.18.100.37-8009-1 - org.jboss.seam.core.Manager - No stored conversation
                        ...[does injections here]
                        2009-09-29 16:15:22,900 DEBUG - ajp-172.18.100.37-8009-1 - org.jboss.seam.core.Manager - Discarding conversation state: 10
                        2009-09-29 16:15:22,901 DEBUG - ajp-172.18.100.37-8009-1 - org.jboss.seam.contexts.FacesLifecycle - After render response, destroying contexts
                        ...[destroying event context, etc.]
                        2009-09-29 16:15:22,914 DEBUG - ajp-172.18.100.37-8009-1 - org.jboss.seam.contexts.FacesLifecycle - <<< End JSF request for /internettools/rda/managerda.cox
                        



                        • 10. Re: form input not propagating to action pojo
                          Kevin B Newbie

                          Here is the HTML generated source:




                          <form id="rdaPurchaseForm" name="rdaPurchaseForm" method="post" action="/path/rda/managerda.cox" enctype="application/x-www-form-urlencoded">
                          <input type="hidden" name="rdaPurchaseForm" value="rdaPurchaseForm" />
                          
                              <table cellpadding="0" width="100%">
                                <tr>
                                  <td class="text-darkgrey">
                                    Enter number of blocks to purchase: <input id="rdaPurchaseForm:blocks" type="text" name="rdaPurchaseForm:blocks" value="" maxlength="2" size="4" />         
                                     <input id="rdaPurchaseForm:purchase" type="image" src="/internettools/img/btn_purchase.gif" name="rdaPurchaseForm:purchase" alt="purchase" />                 
                                    <br />
                          
                                    <span class="text-darkgrey">$7.45
                                    per block will be added to your bill.</span>
                                  </td>
                                </tr>
                              </table><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id2" />
                          </form>