6 Replies Latest reply: Feb 21, 2012 1:20 PM by Brendan Healey RSS

richfaces 4 - executing an action inside rich:dataTable

barbara b Newbie

Hello

I have a problem with executing an action inside a rich:datatable. I have 2 forms in one page. The h:commandbutton in the first form rerenders and fills the rich:datatable in the second form. In the rich:datatable I want to have an edit-button that selects the row and goes to an edit-page. The edit-button unfortunately doesn't work. If I use a h:commandButton I am redirected to the same page and the action is not executed (if I use the name of an action that doesn't exist I even get no errors). If I use a a4j:commandButton nothing happens at all.

 

Has anyone an idea of what I'm doing wrong?

I'm using richfaces-4.0.0.Final, seam 3.1.0.Final

Thanks in advance, barbara

 

This is my code:

 

 

  • 1. Re: richfaces 4 - executing an action inside rich:dataTable
    Brendan Healey Master

    Hi, your code posting didn't work - I find it difficult on the forum myself. Have another go and I'll take

    a look at your problem.

  • 2. Re: richfaces 4 - executing an action inside rich:dataTable
    barbara b Newbie

    Thanks for letting me know, Brendan. Here is the code:

     

      <ui:define name="content">

     

        <h:form>

       

            <h:panelGrid columns="3" id="panelZoekVerenigingen">

           

                <h:outputLabel value="Officiële naam" />

                <h:inputText value="#{verenigingManager.zoekVerenigingOfficieleNaam}" styleClass="long">

     

                <h:commandButton value="Zoek" action="#{verenigingManager.zoekVerenigingen}">

                    <f:ajax render=":formVerenigingen" execute="panelZoekVerenigingen"/>

                </h:commandButton>

                           

            </h:panelGrid>

     

        </h:form>   

     

       

        <h:form id="formVerenigingen">   

               

                <rich:dataTable var="_vereniging" value="#{verenigingManager.verenigingList}" rendered="#{verenigingManager.verenigingList != null}" id="panelVerenigingen">

               

                    <rich:column>

                        <f:facet name="header">Naam</f:facet>

                        <h:commandButton value="#{_vereniging.officieleNaam}" action="#{verenigingManager.editVereniging(_vereniging)}"/>

                    </rich:column>

                   

                </rich:dataTable>

                    

        </h:form>

      

      </ui:define>

  • 3. Re: richfaces 4 - executing an action inside rich:dataTable
    Christian Peter Expert

    Hmmm, try not to (re)render the form directly. This can cause some strange effects like no longer working links or buttons:

     

    <h:commandButton value="Zoek" action="#{verenigingManager.zoekVerenigingen}">

                    <f:ajax render="formVerenigingen:panelVerenigingen" execute="panelZoekVerenigingen"/>

                </h:commandButton>

  • 4. Re: richfaces 4 - executing an action inside rich:dataTable
    barbara b Newbie

    Hello Christian

    I did the change but the action #{verenigingManager.editVereniging(_vereniging)} is still not fired. I've also put everything in one form, but the problem still exists.

     

    barbara

  • 5. Re: richfaces 4 - executing an action inside rich:dataTable
    barbara b Newbie

    I found a solution, I used pretty:link instead:

     

    <pretty:link mappingId="verenigingedit3">

         <f:param name="verenigingid" value="#{_vereniging.verenigingID}"/>

         <h:outputText value="#{_vereniging.officieleNaam}" />

    </pretty:link>

     

    In pretty-config.xml

     

    <url-mapping id="verenigingedit3">

         <pattern value="/verenigingedit3" />

         <view-id value="/private/verenigingedit2.cjsm" />

         <action>#{verenigingManager.editVereniging}</action>

    </url-mapping>

     

    In VerenigingManager.java

     

    public String editVereniging() {

         Map<String,String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();

         String id = params.get("verenigingid");

     

         ...

    }

  • 6. Re: richfaces 4 - executing an action inside rich:dataTable
    Brendan Healey Master

    >> <f:ajax render="formVerenigingen:panelVerenigingen" execute="panelZoekVerenigingen"/>

     

    the problem with this is that panelVerenigingen isn't permanently resident in the DOM because it uses the

    rendered attribute. If you wrapped it in a panelGroup and used the id of this as the target of the f:ajax

    render= I can't see why it shouldn't work.

     

    Don't do this:

    <f:ajax render="panelA"/>

    <h:panelGroup id="panelA" rendered="#{bean.showThis}"/>

     

    This is ok:

    <f:ajax render="panelA"/>

    <h:panelGroup id="panelA">

        <h:panelGroup rendered="#{bean.showThis}"/>

    </h:panelGroup>

     

    I rarely use multiple forms in the same view (with the exception of dialogs & file upload) just because with

    ajax you have control over what gets submitted anyway, and I find myself getting into a naming container

    mess otherwise!

     

    Regards,

    Brendan.