jsf 2.0 ajax呈现整个页面(来自按钮)而不是仅渲染一个面板组

时间:2015-09-28 14:59:27

标签: ajax jsf-2 autocomplete render

我有一个按钮,只能渲染一个特定的panelGroup(parentWrapper)。相反,它重新渲染整个页面。这是它应该工作的方式:

  1. 用户查找Excel文档并在fileupload组件中输入位置
  2. 然后,用户使用自动填充组件选择客户
  3. 然后用户点击AddCustomer按钮。执行CustomerInSchedule(自动完成)和动作editScheduleController.addCustomerRowFromLookAhead(),两者都正常工作。
  4. 当用户单击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"> 
    
  5. 出于某种原因,我无法在此处继续添加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  -->                                               
    

1 个答案:

答案 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.