Primefaces(JSF2)局部更新和局部提交
?
通过partialSubmit来指定局部提交的元素进行提交,完成后通过update来指定要进行更新的元素.此方法对于大表单进行局部AJAX时很有帮助.可以大大减少不必要的网络IO .?
<h:form id="testForm">
<h:panelGrid columns="5" cellpadding="5">
<h:outputLabel for="firstnameTxt" value="Name:" style="font-weight:bold"/>
<p:inputText id="firstnameTxt" value="#{reportVM.firstname}" />
<p:inputText id="lastnameTxt" value="#{reportVM.lastname}" />
<br/>
<h:outputLabel for="introductionTxt" value="Introduction:" style="font-weight:bold"/>
<p:inputText id="introductionTxt" value="#{reportVM.introductionTxt}" />
<p:commandButton value="Submit" update="firstname,lastname" partialSubmit="true" process="firstnameTxt,lastnameTxt"/>
<h:outputText value="#{reportVM.firstname}" id="firstname" />
<h:outputText value="#{reportVM.lastname}" id="lastname" />
</h:panelGrid>
</h:form>
?