5 Replies Latest reply on Sep 7, 2011 12:27 PM by andreas.hartmann

    a4j commandlink in rich:dataTable

    spyke84

      Hi,

      i'm new of richfaces and i have a little problem: i have a rich:dataTable and a rich:dataScroller. in DataTable i have a a4j:commandLink that call a method. when i click a link on a first page the action was called but when i'm move to other page the action of commandlink doesn't work.

       

       

      some one can help me?

        • 1. Re: a4j commandlink in rich:dataTable
          nbelaevski

          Hi Christian,

           

          Please post page and bean code.

          • 2. Re: a4j commandlink in rich:dataTable
            spyke84

            the page code is :

             

             

            <ui:define name="body">

                                <h:form>

                                                    <h:panelGrid columns="1">

             

             

                                                              <rich:datascroller id="datascroller" align="center"

                                                                        for="tabellaStampe" maxPages="10" ReRender="panelTabellaStampe"

                                                                        limitToList="true" page="#{bean.scrollerPage}">

                                                                        <f:facet name="first">

                                                                                  <h:outputText value="Primo" />

                                                                        </f:facet>

                                                                        <f:facet name="first_disabled">

                                                                                  <h:outputText value="Primo" />

                                                                        </f:facet>

                                                                        <f:facet name="last">

                                                                                  <h:outputText value="Ultimo" />

                                                                        </f:facet>

                                                                        <f:facet name="last_disabled">

                                                                                  <h:outputText value="Ultimo" />

                                                                        </f:facet>

                                                              </rich:datascroller>

             

             

                                                                        <rich:dataTable id="tabellaStampe" value="#{elencoStampe}"

                                                                                  var="data" width="1100px" rows="10">

                                                                                  <f:facet name="header">

                                                                                            <rich:columnGroup>

                                                                                                      <rich:column width="200px">

                                                                                                                <h:outputText value="Data" />

                                                                                                      </rich:column>

             

             

                                                                                                      <rich:column width="100px">

                                                                                                                <h:outputText value="Data1" />

                                                                                                      </rich:column>

             

             

                                                                                                      <rich:column width="200px">

                                                                                                                <h:outputText value="Data2" />

                                                                                                      </rich:column>

             

             

                                                                                                      <rich:column width="150px">

                                                                                                                <h:outputText value="Data3" />

                                                                                                      </rich:column>

             

             

                                                                                                      <rich:column width="350px">

                                                                                                                <h:outputText value="Data4" />

                                                                                                      </rich:column>

                                                                                            </rich:columnGroup>

                                                                                  </f:facet>

             

             

                                                                                  <rich:column>

                                                                                            <h:outputText value="#{data.Data}"></h:outputText>

                                                                                  </rich:column>

             

             

                                                                                  <rich:column>

                                                                                            <h:outputText value="#{data.Data1}" />

                                                                                  </rich:column>

             

             

                                                                                  <rich:column>

                                                                                            <a:commandLink value="#{data.Data2}"

                                                                                                      action="#{bean.DettaglioPolizza(data.Data2)}" />

                                                                                  </rich:column>

             

             

                                                                                  <rich:column>

                                                                                            <h:outputText value="#{data.Data3}" />

                                                                                  </rich:column>

             

             

                                                                                  <rich:column>

                                                                                            <h:outputText value="#{data.Data4}" />

                                                                                  </rich:column>

             

             

                                                                        </rich:dataTable>

             

             

             

             

            and the beackin bean code:

             

             

            private int scrollerPage = 1;

             

            @DataModel

                      private List<TabellaStampe> elencoStampe = new ArrayList<TabellaStampe>();

             

            @Factory("elencoStampe")

             

            public void retrieveElencoStampe()

                      {

                                try

                                {

                                          elencoStampe = StampeDAO.getStampe(dataDa, dataA);

                                }

                                catch (Exception e)

                                {

                                          log.error("Errore : " + e.getMessage());

                                }

                      }

            • 3. Re: a4j commandlink in rich:dataTable
              schmu

              Hello

               

              We had a similar problem. What happens if you give the links a generated id? We had code like that:

               

              <rich:dataTable id="matrix"

                                          value="#{model.rowHeaders}" var="row"

                                          rowKeyVar="curRow" style="width:auto; white-space:nowrap;">

              ...

              <rich:columns value="#{model.columnHeaders}"

                                              var="columns" width="auto" index="ind" align="right">

                                              <a4j:commandLink id="a_#{ind}_#{curRow}"

                                                  action="#{action.selectCurrentPos(ind, curRow)}">

              ...

              </rich:dataTable>

               

               

              Or maybe also rerendering the link / table on change page helps...

               

               

              Greetings

              • 4. Re: a4j commandlink in rich:dataTable
                andreas.hartmann

                We have the same Problem (JSF 2 myfaces 2.1.2 / Richfaces 4.1.0.M1)

                 

                inside rich:datatable we have places a h:commandLink wich provides download functionality. On Page 1 (rich:datascroller) everything is work as expected.

                 

                If i ever switch to any other Page, the commandLink will not get executed. It simply renders the page again. No matter if i use the a4j:CommandLink or the h:commandLink.

                 

                <rich:column style="width: 25%;">
                     <f:facet name="header">
                          <cmp:sortableHeader controller="#{repositoryListController}" label="#{messages.repository_column_fileName}" sortKey="fileName" />
                     </f:facet>
                     <h:commandLink value="#{item.fileName}" action="#{repositoryListController.processDownloadContent(item)}" target="_blank" />
                </rich:column>
                

                 

                 

                Any suggestions?

                • 5. Re: a4j commandlink in rich:dataTable
                  andreas.hartmann

                  Ok what i found till now is following:

                   

                  the use of myfaces 2.1.1 brings some problems. After downgrading to version 2.0.6 (not 2.0.7 and neither 2.1.0) the above problem was gone.

                  Strange!

                   

                  I think there are many issues dependeing on which version of the underlying jsf implementation is used.

                  With myfaces 2.0.6 i could use my commandLinks inside rich:dataTable without problems.

                  But if i display a rich:tree there are some problems with image resources (not found under expected resource org.richfaces.images which is only a virtual mapped path).

                  So my Workaround was to copy the images from org.richfaces resource folder to my resource/org.richfaces.images folder and the rich:trees begin to shine ;-)

                   

                  Hope these Problems will be fixed in richfaces 4.1 final ... or is it a myfaces problem?