Thursday 15 March 2012

jsf 2 - Save and update on same xhtml is not working in primefaces -



jsf 2 - Save and update on same xhtml is not working in primefaces -

hi tried next functionality using primefaces. in xhtml have input field takes input , saves db.after completion of save display saved info in info table of primefaces. upto works fine.now add together single selection datatable .when user click on row update same input column selected data. utilize next code

<h:form id="form"> <p:growl id="messages" /> <p:panel id="panel" header="currency"> <h:panelgrid columns="2" id="currencygrid"> <p:outputlabel value="currency :"/> <p:inputtext value="#{currencybean.currencymaster.currdesc}"/> </h:panelgrid> <p:commandbutton value="add" action="#{currencybean.savecurrency}" update="currencytable"> </p:commandbutton> <p:datatable id="currencytable" var="cur" value="#{currencybean.currencylist}" widgetvar="dlg" selection="#{currencybean.currencymaster}" selectionmode="single" rowkey="#{cur.currid}"> <p:ajax event="rowselect" listener="#{currencybean.onrowselect}" update=":form:currencygrid" /> <p:column headertext="id" style="font-size:12px;"> <h:outputtext value="#{cur.currid}" /> </p:column> <p:column headertext="description" style="font-size:12px;"> <h:outputtext value="#{cur.currdesc}" /> </p:column> </p:datatable> </h:form>

and bean code is:

@managedbean @viewscoped @component public class currencybean implements serializable{ private static final long serialversionuid = 1l; @autowired private currencymaster currencymaster; private list<currencymaster> currencylist; public currencymaster getcurrencymaster() { homecoming currencymaster; } public void setcurrencymaster(currencymaster currencymaster) { this.currencymaster = currencymaster; } public void savecurrency(){ try{ currencyservice.savecurrency(currencymaster); }catch(exception e){ e.printstacktrace(); } } @postconstruct public void currencylist(){ setcurrencylist(currencyservice.getcurrencylist()); } public void onrowselect(selectevent event) {} public void onrowunselect(unselectevent event) {} }

so when click on currrencytable row input field populated , update operation also.

the problem when straight come in info input column globalmaster property going null.

and next error occured;

attempt create saveorupdate event null entity

i alter scopes of bean did not find solution.

and find more solutions above exception problem new values not set currencymaster.

is there error done in context.please guide me..

jsf-2 primefaces

No comments:

Post a Comment