jsf - Update datatable in primefaces with update attribute -


i have form contains data required, used code it:

<p: inputtext id = "salary" value = "#{paymentbean.payment.salary}" required = "true" requiredmessage = "#{msg ['required.salary']}" /> 

on same page there datatable contains objects (payment) add through form. once object added, update datable add new object using code:

<p:commandbutton action="#{paymentbean.addnewpayment()}" value="#{msg['button.add_new_account']}" update=":msg :payment_table add_salary_form">     <f:param name="employeeid" value="#{param['employeeid']}" /> </p:commandbutton> 

the problem have when data not entered , click button update done , table appears empty! however, validation message appears there mandatory data.

the datatable is

<p:datatable id="payment_table" var="p" value="#{paymentbean.payments}" rows="15" paginator="true"     paginatortemplate="{currentpagereport}  {firstpagelink} {previouspagelink} {pagelinks} {nextpagelink} {lastpagelink} {rowsperpagedropdown}" rowsperpagetemplate="5,10,15,20">      <p:column headertext="#{msg['label.salary']}">         <h:outputtext value="#{p.salary}" />     </p:column>      <p:column headertext="#{msg['label.date_payment']}">         <h:outputtext value="#{p.paymentdate}">             <f:convertdatetime pattern="dd/mm/yyyy hh:mm" />         </h:outputtext>     </p:column>      <p:column headertext="#{msg['label.payment']}">         <h:outputtext value="#{p.paid == true ? 'payƩ' : 'non payƩ'}" />     </p:column> </p:datatable> 

i use in cdi, managed bean this: //import

import javax.enterprise.context.requestscoped; import javax.faces.context.facescontext; import javax.inject.inject; import javax.inject.named; 

//class

@requestscoped 

@named(value = "paymentbean") public class paymentbean implements serializable {

private static final long serialversionuid = 8709710274424668330l;  final static logger logger = logger.getlogger(paymentbean.class);  list<payment> payments = new arraylist<payment>();  private payment payment;  @inject private ipaymentservice paymentservice;  public paymentbean() {     payment = new payment(); }   public void addnewpayment() {     //code add payment }  //getters , setters 

}

you can try several things

1.- ensure have datatable form tag.
2.- when use ":" in update mean absolute , correct command update=":form-id:payment_table"
3.- recommend use - instead of _ in id because primefaces uses jquery , in cases command may fail search implementation of primefaces jquery. update looks update=":form-id:payment-table"
4.- create wrapper , update wrapper in button full solution be:

<h:panelgrid id="grid-payment-table">      <p:datatable id="payment_table" ... </h:panelgrid> 

5.- change scope @viewscoped


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -