java - ViewScoped ManagedBean is keeping alive after non-ajax post -
i'm using primefaces 4.0, spring, spring security , hibernate. not know why after making post in ajax="false" commandbutton viewscoped bean returning form old values and not beingness destroyed. in other viewscoped beans working fine not. have tried solve quite while , can't create work.
the form quite large, simplify create clear
<h:form id="anadirform"> <p:panel id="panel" header="aƱadir factura"> <h:panelgrid id="grid" columns="2" style="margin-bottom:10px"> <f:facet name="header"> <p:messages id="messages" autoupdate="true" /> </f:facet> <h:outputlabel for="justificante" value="justificante: *" /> <p:inputtext id="justificante" value="#{facturabean.factura.justificante}" required="false" > <p:ajax event="change" listener="#{facturabean.comprobarjustificante}"/> </p:inputtext> .... </h:panelgrid> </p:panel> <p:datatable style="width: 780px;" id="lineasfacturas" var="facturalinea" value="#{facturabean.factura.lineas}"> <p:column> <p:inputtext value="#{facturalinea.contrapartida}" /> </p:column> <p:column style="width: 90px;"> <p:inputtext style="width: 85px;" value="#{facturalinea.base}" > <p:ajax event="change" process="lineasfacturas" update="lineasfacturas" listener="#{facturabean.sumarbases}"/> </p:inputtext> </p:column> ..... </p:datatable> <p:commandbutton value="guardar" process="@all" ajax="false" action="#{facturabean.savefactura}" > </h:form>
bean
@managedbean @viewscoped public class facturabean implements serializable{ private list<facturalinea> facturalineas; private factura factura; private facturalinea facturalin; priv .... @postconstruct public void init(){ facturalineas = new arraylist<facturalinea>(); factura = new factura(); factura.n .... } .... public void savefactura(){ simpledateformat sdf=new simpledateformat("yyyy-mm-dd"); dateformat dateformat = new simpledateformat("eee mmm dd hh:mm:ss z yyyy", locale.english); dateformat hourformat = new simpledateformat("hh:mm:ss"); date hr = new date(); string fechafactura = null; string fechapunteo = sdf.format(hour); string horapunteo = hourformat.format(hour); seek { date dat = dateformat.parse(factura.getfechafactura()); fechafactura = sdf.format(dat); }catch (parseexception e){ } factura.setfechafactura(fechafactura); factura.setfechapunteo(fechapunteo); factura.sethorapunteo(horapunteo); factura.setagente(facescontext.getcurrentinstance().getexternalcontext().getremoteuser()); calcularimporte(); dao.save(factura); } .... public void sumarbases(){ integer suma = 0; for(facturalinea fl :factura.getlineas()){ suma += fl.getbase(); } factura.setsumabases(suma); calcularimporte(); } public void comprobarjustificante(){ for(factura f : lista){ if(factura.getjustificante() == f.getjustificante()){ facescontext.getcurrentinstance().addmessage(null, new facesmessage("justificante en uso")); break; } } }
i have tried homecoming string in savefactura method because rode on balusc blog http://balusc.blogspot.com.es/2011/09/communication-in-jsf-20.html says:
"@viewscoped: bean in scope lives long you're interacting same jsf view in browser window/tab. created upon http request , destroyed 1 time postback different view... need homecoming null or void action (listener) methods maintain bean alive."
but bean not beingness destroyed in way, not know now.
sorry grammar or spelling mistakes.
java spring jsf primefaces view-scope
No comments:
Post a Comment