我有一个按钮,只能渲染一个特定的panelGroup(parentWrapper)。相反,它重新渲染整个页面。这是它应该工作的方式:
当用户单击AddCustomer按钮时,ajax应该只呈现:CustomerScheduleForm:parentWrapper。而不是整个页面被渲染。这会在本页的其他部分产生问题。所以问题是:为什么ajax渲染整个页面而不仅仅是panelGroup id =" parentWrapper" ?
<div align="center">
<h:panelGroup id="editScreenDiv" layout="block" style="width:1180px">
<h:panelGrid border="0" columns="2" class="SimpleFormBoundedSection SubRegionBox" columnClasses="InputLabel,InputElement" rowClasses="FirstRow,LastRow" headerClass="SectionHead">
<!-- some stuff -->
<l:fileUpload id="fileupload" value="#{editScheduleController.customerRateScheduleBean.sourceFile}" onchange="file_onchange()" rendered="#{editScheduleController.customerRateScheduleBean.action != 'editSchedule'}" />
<!-- ... some stuff -->
<h:commandButton id="AddCustomer" value="Add" action="#{editScheduleController.addCustomerRowFromLookAhead()}" >
</h:commandButton>
<p:autoComplete id="CustomerInSchedule" required="false" value="#{editScheduleController.customerNumberAndName}" completeMethod="#{editScheduleController.suggestAuthorizedCustomer}" minQueryLength="3" scrollHeight="250" size="65" maxlength="50" forceSelection="true">
出于某种原因,我无法在此处继续添加xhtml代码。以下是属于同一页面的其余代码。我省略了div和dataTable的样式属性。
<f:ajax render=":CustomerScheduleForm:parentWrapper" execute="CustomerInSchedule" onevent="clearCustomerInSchedule()"/>
</p:autoComplete>
<h:panelGroup id ="parentWrapper">
<h:panelGroup id ="wrapper">
<div>
<h:dataTable id="customerTable" value="#{editScheduleController.customerRateScheduleBean.listOfCustomersInSchedule}"
var="customerRow" >
<!-- ...some stuff -->
</h:dataTable>
</div>
</h:panelGroup>
</h:panelGrid>
</h:panelGroup>
<!-- ... some stuff -->
答案 0 :(得分:0)
Add an update to your commandButton, with the component to update : update=":CustomerScheduleForm:parentWrapper"
.
Edit : do this accordinaly with esiting commandButton to p: instead of h to use the update and ajax.