10 Replies Latest reply: Aug 23, 2011 12:52 AM by binh le quang RSS

commandLink, commandButton in h:dataTable does not execute action

Chris Moerz Newbie

I've got a h:commandLink in a h:dataTable but for some reason the action is not getting executed. The action is not bound to any action in pages.xml, so it does not cause a redirect. To add to my confusion, I can rename the action to anythin except a completely invalid/non-existent function name (e.g. 123func would be illegal because that does not represent a valid Java method name) and no exception is thrown when clicking the link or button.


I'm at a loss why this is happening. Here's my code:


<h:dataTable value="#{dataItemList.selectedItem.notBefore}" var="nBitem"
    rowClasses="odd,even"
        columnClasses="extraTinyCol centered,defaultCol,defaultCol,defaultCol,tinyCol" >
                    
        <h:column>
                <f:facet name="header">#</f:facet>
                <s:div styleClass="viewSection">
                        <p style="text-align:center;padding:5px"><h:outputText value="#{nBitem.id}" /></p>
                </s:div>
        </h:column>
                                        
        <h:column>
                <f:facet name="header">#{messages['org.nycentral.labels.Description']}</f:facet>
                                
                <s:decorate template="../layout/display.xhtml">
                        <s:div styleClass="viewSection">
                                <h:outputText value="#{nBitem.description}" escape="false" />
                        </s:div>
                </s:decorate>                                     
        </h:column>
                                        

        <h:column>
                <f:facet name="header">#{messages['org.nycentral.labels.Action']}</f:facet>
                <h:commandLink action="#{dataItemList.switchItem(nBitem)}">
                        <h:graphicImage value="/img/fugue-icons/16x16/magnifier_arrow.png" 
                                alt="#{messages['org.nycentral.labels.GoView']}"/>
                </h:commandLink>
                <h:commandButton action="#{dataItemList.select(nBitem)}" value="Go">
                </h:commandButton>
        </h:column>
</h:dataTable>            



Does anyone have an idea why my commandLink doesn't work?? I do have working commandLinks that are in dataTables in my project; that's the only one that's broken and I'm really clueless as to how this is even possible?? I've been scratching my head over this for two days now and it's driving me nuts that such a stupid and totally simple thing holds me up for so long. Anyone, please, even if it's just a gut feeling what may be causing it, please tell me.


thx in advance
chris

  • 1. Re: commandLink, commandButton in h:dataTable does not execute action
    Marcio Endo Newbie

    This usually happens when I have nested <h:form>. Make sure you DON'T have something like:


    <h:form>
       <h:form>
       (...)
          <h:commandLink action="#{foo}" />
       (...)
       </h:form>
    </h:form>
    

  • 2. Re: commandLink, commandButton in h:dataTable does not execute action
    Chris Moerz Newbie

    Thanks for the pointer; I double checked but I'm afraid that's not the problem.


    In the meantime I figured out that it's obviously caused by a rich:tabPanel that's around the dataTable. When I move the datatable out of the tabpanel, it works! Somehow the tabPanel seems to be influencing the commandLink if it's inside a datatable... really weird behaviour.


    Anyone got a clue how to fix this?


    thx chris

  • 3. Re: commandLink, commandButton in h:dataTable does not execute action
    Arbi Sookazian Master

    show the entire relevant JSF code (including <h:form>, for example).


    I just tested this code and the action for the commandLink executed (Seam 2.0.2-FP)


         <rich:tabPanel>
            <rich:tab label="First">
                <h:form>
                     <h:dataTable id="workOrdersTable" 
                                                value="#{testSFSBAction.workOrdersList}"  
                                                var="workOrder">
                                                
                            <h:column>
                                  <f:facet name="header"><h:outputText value="MAC Address"/></f:facet>
                                  <h:outputText value="#{workOrder.macAddress}"
                                                   converter="macAddressConverter"/>
                             </h:column>
                             
                             <h:column>
                                  <f:facet name="header"><h:outputText value="Work Order #"/></f:facet>
                                  <h:outputText value="#{workOrder.workOrderNo}"/>
                             </h:column>
                                                 
                        </h:dataTable>
                        
                        <h:commandLink value="GoLink" action="#{testSFSBAction.myAction}"/>
                             
                   </h:form>
            </rich:tab>
            <rich:tab label="Second">
                Here is tab #2
            </rich:tab>
            <rich:tab label="Third">
                Here is tab #3
            </rich:tab>
        </rich:tabPanel>



  • 4. Re: commandLink, commandButton in h:dataTable does not execute action
    Ronald Stampley Newbie

    I have run into the exact same problem.  I am using SEAM 2.1.1 GA and Rich faces 3.3.0 GA.  Please let me know if you found a solution, what it is.

  • 5. Re: commandLink, commandButton in h:dataTable does not execute action
    Andrey Svalov Newbie

    Hi Ronald


    I just found that this has been fixed in Richfaces 3.3.1 release. Download and enjoy!

  • 6. Re: commandLink, commandButton in h:dataTable does not execute action
    Tiago Reis Newbie

    Hi,


    I'm running into problem of nested Form tags causing a link not to execute its function . Does anyone knows if that issue as been solved? Or is it not considered an issue?


    I'm running RichFaces 3.2.2.


    Thanks

  • 7. Re: commandLink, commandButton in h:dataTable does not execute action
    Julien Kronegg Novice

    I had a similar problem (form submitted using a POST method, but action not called). This was caused by <form> included in another <form> (nested forms).


    Cleaning the page to get only one form solved the problem.


    Other suggestions did not work:



  • 8. Re: commandLink, commandButton in h:dataTable does not execute action
    Rene Felgenträger Newbie

    in general, if an action is not invoked most of the times jsf does not decode the component tree properly/completely.
    in my case,
    the rich:tabPanel caused some problems as the selectedTab-Attribute was resolved to null causing the component-tree not be properly decoded.


    example (not working, as dummyVar is resolved to null):




    <rich:tabPanel switchType="ajax" selectedTab="#{dummyVar}">



    I didnt recognise this bug, as everything worked as expected (a:commandLink, a:commandButton etc.). Adding a h:commandButton in one tab showed me my bug.



    greetings



    accless



  • 9. Re: commandLink, commandButton in h:dataTable does not execute action
    Igor Espin Newbie

    Hi Chris,


    Can you tell me if you solved this issue?? Im having the exact problem and I cant get it solved.


    Thanks!

  • 10. Re: commandLink, commandButton in h:dataTable does not execute action
    binh le quang Newbie

    Please try make your manage bean is session scope