8 Replies Latest reply on May 19, 2009 1:58 PM by damian pooley

    commandButton not calling action

    Ronald Stampley Newbie
      In the segment of code below, for some odd reason, I am seeing two strange effects.

      1.  The form submission never calls my validator.
      2.  rcounter has no value when i try to use it in the form id, but it does have a value in the hidden field.

      I am using SEAM 2.1.1.GA, Richfaces 3.3.0 GA, and JSF 1.2_09-b01-BETA1.

      Any help in resolving these issue would be greatly appreciated.

      <s:div rendered="#{commentViewList.hasData(imageFullView.id)}">
                               <rich:dataTable value="#{commentViewList.getCommentViewList(imageFullView.id)}" var="com" rowKeyVar="rcounter" id="table"  columnsWidth="100px,500px,100px" >
                                 <rich:column sortable="false" styleClass="commentBorder"> 
                                     <f:facet name="header">
                                         <h:outputText value="Name"/>
                                     </f:facet>
                                     <h:outputText value="#{com.name}"/>
                                 </rich:column>
                                 <rich:column sortable="false" styleClass="commentBorder">
                                     <f:facet name="header">
                                         <h:outputText value="Comment"/>
                                     </f:facet>
                                     <h:outputText value="#{com.comment}"/>
                                 </rich:column>
                                 <rich:column sortable="false" styleClass="commentBorder">
                                     <f:facet name="header">
                                         <h:outputText value="Time"/>
                                     </f:facet>
                                     <h:outputText value="#{com.time}"/>
                                 </rich:column>
                                 <rich:column sortable="false" styleClass="commentBorder" rendered="#{commentViewList.hasCommentByCurrentUser()}">
                                     <f:facet name="header">
                                         <h:outputText value="Delete"/>
                                     </f:facet>
                                     <s:fragment rendered="#{(com.uid eq servletUtils.userID) or imageFullView.isOwner()}">
                                          <h:form id="delComment_#{rcounter}">
                                               <h:inputHidden id="delValue" value="#{com.id}" />
                                               <h:inputHidden id="delImage" value="#{imageFullView.id}" />
                                               <h:inputHidden id="count" value="#{rcounter}" />
                                               <h:commandButton type="submit" action="#{deleteCommentValidator.validate}" value="X" />
                                          </h:form>
                                     </s:fragment>
                                 </rich:column>
                             </rich:dataTable>
                         </s:div>
        • 1. Re: commandButton not calling action
          Arbi Sookazian Master

          I've never even contemplated using EL in an id attribute value.  Why do you need to make your id's values dynamic?


          Have you tried replacing #{rcounter} with 1?


          Is your deleteCommentValidator component a JavaBean or EJB?  If EJB, is a local/remote interface implemented by your SFSB/SLSB implementation class?

          • 2. Re: commandButton not calling action
            Ronald Stampley Newbie
            The values are unique so I can determine which item in the list the user selected when the form is submitted.  If you have a better way to pass this value, i'd love to hear it because I've been having no luck.

            If I use 1 instead of rcounter, then every form has an id of "delComment_1".

            the deleteComponentValidator is a JavaBean.
            • 3. Re: commandButton not calling action
              damian pooley Newbie

              your inner form should already have an id of table:n:delComment where n is the row number. if the var com is what the validator is validating, then you can do deleteCommentValidator.validate(com), and also put the form outside the table.


              i do similar inside a pageflow transition action.

              • 4. Re: commandButton not calling action
                Ronald Stampley Newbie
                Tried that, but still my validator is not called.  It's like it's completely ignoring the validator.

                <s:div rendered="#{commentViewList.hasData(imageFullView.id)}">
                                         <h:form>
                                              <rich:dataTable value="#{commentViewList.getCommentViewList(imageFullView.id)}" var="com" rowKeyVar="rcounter" id="table"  columnsWidth="100px,500px,100px" >
                                                <rich:column sortable="false" styleClass="commentBorder"> 
                                                    <f:facet name="header">
                                                        <h:outputText value="Name"/>
                                                    </f:facet>
                                                    <h:outputText value="#{com.name}"/>
                                                </rich:column>
                                                <rich:column sortable="false" styleClass="commentBorder">
                                                    <f:facet name="header">
                                                        <h:outputText value="Comment"/>
                                                    </f:facet>
                                                    <h:outputText value="#{com.comment}"/>
                                                </rich:column>
                                                <rich:column sortable="false" styleClass="commentBorder">
                                                    <f:facet name="header">
                                                        <h:outputText value="Time"/>
                                                    </f:facet>
                                                    <h:outputText value="#{com.time}"/>
                                                </rich:column>
                                                <rich:column sortable="false" styleClass="commentBorder" rendered="#{commentViewList.hasCommentByCurrentUser()}">
                                                    <f:facet name="header">
                                                        <h:outputText value="Delete"/>
                                                    </f:facet>
                                                    <s:fragment rendered="#{(com.uid eq servletUtils.userID) or imageFullView.isOwner()}">
                                                         <h:commandButton action="#{commentViewList.delete(com)}" value="X" />
                                                    </s:fragment>
                                                </rich:column>
                                            </rich:dataTable>
                                           </h:form>
                                   </s:div>

                • 5. Re: commandButton not calling action
                  damian pooley Newbie

                  just a quickie... is 'com' (table variable) defined by any bean @Name? I've found that I've had to use different var names otherwise seam would likely create/use the bean by name rather than the var version.

                  • 6. Re: commandButton not calling action
                    Ronald Stampley Newbie

                    no other variables had the name com.  I have however gone a different route.  I found several posts that talk about issues with rich:datatables and h:commandbuttons.  I have replaced the h:commandButton with an s:link and implemented @DataModel and @DataModelSelection.  While I would like to use a post, i can live with the get used by s:link.  Thanks for your help.

                    • 7. Re: commandButton not calling action
                      Arbi Sookazian Master

                      Ronald Stampley wrote on May 18, 2009 03:19:


                      no other variables had the name com.  I have however gone a different route.  I found several posts that talk about issues with rich:datatables and h:commandbuttons.  I have replaced the h:commandButton with an s:link and implemented @DataModel and @DataModelSelection.  While I would like to use a post, i can live with the get used by s:link.  Thanks for your help.


                      what posts specifically?  I have used rich:dataTable and h:commandButton extensively with no problems that I can recall...

                      • 8. Re: commandButton not calling action
                        damian pooley Newbie

                        As above I use this extensively without problem:


                        <rich:dataTable id="tasksTable" rows="10" value="#{taskIns.allOpen(user.getUsername())}" var="ti">
                          <rich:column width="50" sortBy="#{ti.id}">
                            <f:facet name="header">
                               <h:outputText value="#{msg.taskbookTableId}"/>
                            </f:facet>
                            <h:commandLink action="#{taskIns.choose(ti.id)}" value="#{ti.id}"/>
                          </rich:column>



                        taskIns is a session bean. @DataModelSelection always starts off with the 0 index element 'selected' which is why i moved off it because other pages ended up getting the wrong thing...