jsf - How can I edit only the last record in a p:dataTable? -


in each query, records variables , need edit last record, cell total-student.

<p:panel style="width:40%; margin: 0 auto; margin-top: 20px;">      <h:form>             <p:datatable id="aviablecuotas" var="pag" value="#{logincontroller.pagos}">             <p:column  headertext="year" styleclass="tableheader">                   <h:outputtext  value="#{pag.year}" styleclass="tablecontent"/>               </p:column>                <p:column  headertext="total students" styleclass="tableheader">                   <h:outputtext value="#{pag.estadistic}" styleclass="tablecontent" />              </p:column>           </p:datatable>      </h:form>      <h:form>         <p:commandbutton value="calculate" action="#{loginbean.getlogin}" style="float: right" />     </h:form> </p:panel> 

thanks in advance...

if want edit 1 column use this:

 <p:datatable id="aviablecuotas" var="pag" value="#{logincontroller.pagos}" editable="true" editmode="cell"> <p:column  headertext="year" styleclass="tableheader">       <h:outputtext  value="#{pag.year}" styleclass="tablecontent"/>   </p:column>    <p:column  headertext="total students" styleclass="tableheader">             <p:celleditor>          <f:facet name="output"><h:outputtext value="#{pag.estadistic}" styleclass="tablecontent" /> </f:facet>          <f:facet name="input"><p:inputtext value="#{pag.estadistic}" styleclass="tablecontent"/></f:facet>       </p:celleditor>   </p:column>  </p:datatable>  

and if want modify last row use that:

<p:datatable id="aviablecuotas" var="pag" value="#{logincontroller.pagos}" editable="true" editmode="cell" rowindexvar="i"> <p:column  headertext="year" styleclass="tableheader">       <h:outputtext  value="#{pag.year}" styleclass="tablecontent"/>   </p:column>    <p:column  headertext="total students" styleclass="tableheader">             <p:celleditor rendered="#{i == (logincontroller.pagos.size() - 1)}">          <f:facet name="output"><h:outputtext value="#{pag.estadistic}" styleclass="tablecontent" /> </f:facet>          <f:facet name="input"><p:inputtext value="#{pag.estadistic}" styleclass="tablecontent"/></f:facet>       </p:celleditor>   </p:column>   </p:datatable>  

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -