2 Replies Latest reply on Mar 16, 2009 10:32 AM by rschoeler

    Submitting row contents in datatable

      Hello!

      I have a small problem but I think there is a simple solution for it. I am using a dataTable (bind to a java.util.List of entities) and I want to enable direct editing of the results (similiar to Excel). That's quite easy, I just use <h:inputText /> instead of <h:outputText /> elements within <rich:column>. Small example:

      ...
      <rich:column sortBy="#{item.createdOn}">
       <f:facet name="header">
       <h:outputText value="#{messages['createdOn']}" />
       </f:facet>
       <h:inputText value="#{item.createdOn}" />
      </rich:column>
      
      <rich:column>
       <f:facet name="header">
       <h:outputText value=" " />
       </f:facet>
       <a4j:commandLink action="#{manager.save}"
       reRender="table">
       <a4j:actionparam name="saveParam" value="#{item.id}"
       assignTo="#{manager.id}" />
       <h:graphicImage value="/images/save.png"/>
       </a4j:commandLink>
      </rich:column>
      ...
      


      But now I have the problem that the values are bound to the list of items but I need a way to transmit the values for one row when the user clicks the save link. For short: When the user clicks the save link, the whole row contents shall be submitted, but unfortunately I don't know how to do.

      Thanks in advance!

        • 1. Re: Submitting row contents in datatable
          ilya_shaikovsky

          Sorry but can't get the problem :/ All the changes should passed to model items just after button click.. Or I miss something?

          • 2. Re: Submitting row contents in datatable

            Hello wark2007, one possible way is to use a4j:support alone or in combination with f:setPropertyChangeListener (JSF 1.2), or use a4j:commandLink etc.

            I write this examples only out from my mind - therefore semantic failures are possible (only show you possible ways to go....8-})!

            VAR 1 - only a4j:support
            <a4j:support event="onclick" actionListener="#{YOURBEAN.processMETHOD}" reRender="YOUR-TABLEID" eventsQueue="USE_OR_NOT"/>

            VAR 2 - var contains the OID of the changedtable and target contains the variable of the BEAN, which store the OID.....during work of the action-Method you can take this OID of the row to do your saving stuff
            <a4j:support event="onclick" reRender="YOUR-TABLEID">
            <f:setPropertyChangeListener var="SOURCE" target="target" />
            </a4j:support>

            VAR 3: direct usage of a4j:commandLink

            regards
            rschoeler