ajax - Rendering updated components from backing bean after Save -
i have been working on creating dynamic table captures cells have been updated (for quicker save) , refresh/rerender cells after save.
so far, have table being created, of items updated being captured nicely via ajax listener, stuck on not being able refresh/rerender updated components after save.
code snippet page:
<h:form id="formmain" prependid="false"> <div id="contentwrapper"> <p:messages id="messages" severity="warn, error" autoupdate="true" closable="true" /> <div style="float:right; position:relative; top: -3px;"> <h:commandbutton id="btnsaveupdates" styleclass="save_updates_button"> <f:ajax execute="@this" listener="#{remediationdetail.processupdates}"/> </h:commandbutton> </div> <h:panelgroup id="detailedit" styleclass="clear_left" layout="block"> <h:datatable id="tbldetails" styleclass="slate_table remediation" value="#{remediationdetail.details}" var="dataitem"> <c:foreach items="#{remediationdetail.detailheaders}" var="key" varstatus="looper"> <h:column> <f:facet name="header">#{key.fielddefinition.fieldconfiguration.customlabel}</f:facet> <c:if test="#{key.fielddefinition.datatype.name eq 'number'}"> <h:panelgroup id="detailnumberpanel#{looper.index}"> <h:inputtext id="txtdetailnumber#{looper.index}" rendered="#{remediationdetail.containserrors(dataitem.id, key.fielddefinition.id)}" value="#{dataitem.entitylist[looper.index].val}" styleclass="remediation_textbox error_marker" title="#{remediationdetail.errormessages(dataitem.id, key.fielddefinition.id)}"> <f:convertnumber maxfractiondigits="0" maxintegerdigits="19"/> <f:ajax event="change" execute="@this" render="@none" listener="#{remediationdetail.markchangedentity}"/> <f:attribute name="entity" value="#{dataitem.entitylist[looper.index]}"/> </h:inputtext> <h:outputtext id="txtdetailnumberout#{looper.index}" rendered="#{not remediationdetail.containserrors(dataitem.id, key.fielddefinition.id)}" value="#{dataitem.entitylist[looper.index].val}"></h:outputtext> </h:panelgroup> </c:if> <c:if test="#{key.fielddefinition.datatype.name eq 'decimal'}"> <h:panelgroup id="detaildecimalpanel#{looper.index}"> <h:inputtext id="txtdetaildecimal#{looper.index}" rendered="#{remediationdetail.containserrors(dataitem.id, key.fielddefinition.id)}" convertermessage="value provided not valid decimal" styleclass="remediation_textbox error_marker" title="#{remediationdetail.errormessages(dataitem.id, key.fielddefinition.id)}" value="#{dataitem.entitylist[looper.index].val}"> <f:convertnumber maxfractiondigits="2" maxintegerdigits="19"/> <f:ajax event="change" execute="@this" render="@none" listener="#{remediationdetail.markchangedentity}"/> <f:attribute name="entity" value="#{dataitem.entitylist[looper.index]}"/> </h:inputtext> <h:outputtext id="txtdetaildecimalout#{looper.index}" rendered="#{not remediationdetail.containserrors(dataitem.id, key.fielddefinition.id)}" value="#{dataitem.entitylist[looper.index].val}"> <f:convertnumber maxfractiondigits="2" maxintegerdigits="19"/> </h:outputtext> </h:panelgroup> </c:if> <c:if test="#{key.fielddefinition.datatype.name eq 'date'}"> <h:panelgroup id="detaildatepanel#{looper.index}"> <h:inputtext id="txtdetaildate#{looper.index}" rendered="#{remediationdetail.containserrors(dataitem.id, key.fielddefinition.id)}" styleclass="remediation_textbox error_marker dates" title="#{remediationdetail.errormessages(dataitem.id, key.fielddefinition.id)}" value="#{dataitem.entitylist[looper.index].val}"> <f:convertdatetime locale="en_us" pattern="mm/dd/yyyy" /> <f:ajax event="change" execute="@this" render="@none" listener="#{remediationdetail.markchangedentity}"/> <f:attribute name="entity" value="#{dataitem.entitylist[looper.index]}"/> </h:inputtext> <h:outputtext id="txtdetaildateout#{looper.index}" rendered="#{not remediationdetail.containserrors(dataitem.id, key.fielddefinition.id)}" value="#{dataitem.entitylist[looper.index].val}"> <f:convertdatetime locale="en_us" pattern="mm/dd/yyyy" /> </h:outputtext> </h:panelgroup> </c:if> <c:if test="#{key.fielddefinition.datatype.name eq 'boolean'}"> <h:panelgroup id="detailbooleanpanel#{looper.index}"> <h:selectbooleancheckbox id="cbdetailbooleaninput#{looper.index}" rendered="#{remediationdetail.containserrors(dataitem.id, key.fielddefinition.id)}" title="#{remediationdetail.errormessages(dataitem.id, key.fielddefinition.id)}" value="#{dataitem.entitylist[looper.index].val}"> <f:ajax event="change" execute="@this" render="@none" listener="#{remediationdetail.markchangedentity}"/> <f:attribute name="entity" value="#{dataitem.entitylist[looper.index]}"/> </h:selectbooleancheckbox> <h:outputtext id="txtdetailbooleanoutput#{looper.index}" rendered="#{not remediationdetail.containserrors(dataitem.id, key.fielddefinition.id)}" value="#{dataitem.entitylist[looper.index].val}"></h:outputtext> </h:panelgroup> </c:if> <c:if test="#{key.fielddefinition.datatype.name eq 'string'}"> <h:panelgroup id="detailstringpanel#{looper.index}"> <h:inputtext id="txtdetailstring#{looper.index}" rendered="#{key.fielddefinition.inputtype eq 'textbox' , remediationdetail.containserrors(dataitem.id, key.fielddefinition.id)}" value="#{dataitem.entitylist[looper.index].val}" styleclass="remediation_textbox error_marker" title="#{remediationdetail.errormessages(dataitem.id, key.fielddefinition.id)}"> <f:ajax event="change" execute="@this" render="@none" listener="#{remediationdetail.markchangedentity}"/> <f:attribute name="entity" value="#{dataitem.entitylist[looper.index]}"/> </h:inputtext> <h:selectonemenu id="dddetailstring#{looper.index}" styleclass="remediation_select error_marker" rendered="#{key.fielddefinition.inputtype eq 'dropdown' , remediationdetail.containserrors(dataitem.id, key.fielddefinition.id)}" value="#{dataitem.entitylist[looper.index].val}" title="#{remediationdetail.errormessages(dataitem.id, key.fielddefinition.id)}"> <f:selectitems value="#{dataitem.entitylist[looper.index].fielddefinition.listitemset.selectitemslist}"></f:selectitems> <f:ajax event="change" execute="@this" render="@none" listener="#{remediationdetail.markchangedentity}"/> <f:attribute name="entity" value="#{dataitem.entitylist[looper.index]}"/> </h:selectonemenu> <h:outputtext id="txtdetailstringout#{looper.index}" rendered="#{not remediationdetail.containserrors(dataitem.id, key.fielddefinition.id)}" value="#{dataitem.entitylist[looper.index].val}"></h:outputtext> </h:panelgroup> </c:if> </h:column> </c:foreach> </h:datatable> </h:panelgroup> </div> </h:form>
code backing bean
@managedbean @sessionscoped public class remediationdetail implements serializable { public void markchangedentity(ajaxbehaviorevent ajaxevent){ entity entity = (entity) utility.getajaxactionattribute(ajaxevent, "entity"); //capture client ids updated getcomponentsidstorefresh().add(ajaxevent.getcomponent().getparent().getclientid()); //capture entities changed getchangedentities().add(entity); } //this save happens , hoping updating of components !! public void processupdates(ajaxbehaviorevent event){ entitydomain.processentities(changedentities); facescontext.getcurrentinstance().getpartialviewcontext().getrenderids().addall(getcomponentsidstorefresh()); } }
after save occurs , add client ids updated partialviewcontext().getrenderids() don't see being updated. have tried omnifaces ajax.update(clientid) no success either.
i have updated code snippets stands full table being built.
my questions are:
- is doing possible ?
- am approaching rendering of components correctly ?
- what missing ?
my environment: mojarra 2.1.7 tomcat 7.022
regards,
mike
this code works fine me on mojarra 2.1.21. mojarra 2.1.7 march 2012 , little on 1 year old. recommend upgrade it.
i can't pinpoint version between 2.1.7 , 2.1.21 and/or mojarra issue fixes concrete problem 2.1.7 don't recognize problem, can tell lot of things have been improved in view state management lately. more, since 2.1.18, eternal chicken-egg problem taglibs+viewscope has been fixed, may releated.
Comments
Post a Comment