2011-08-11 41 views
1

我想提交一個彈出式面板中提交/操作事件的另一個面板中的值。但在打開彈出式面板之前,我需要調用託管bean上的一個函數來創建一個新的實體對象。外板只有h:表格,因爲你不能嵌套它們。我已將彈出式面板封裝在a4j:區域中,以便在使用提交彈出式面板中的值時僅提交此部分。這可以工作,但不能執行彈出式面板執行時需要調用的準備功能。我試過a4j:commandLink但該組件不能與rich:popupPanel(奇怪,因爲它們都是Richfaces組件?!)。所以我必須在h:commandLink上繼續並使用ajax。提交彈出式面板內容,豐富:popupPanel

當打開/渲染彈出面板的鏈接觸發時,如何調用託管bean上的函數?

(什麼是這個正確的方式?)

PS。最初的問題已經改變,但不是彈出式面板中提交值的問題。在XHTML文件的

部分:

<h.form> 
... 
<a4j:region> 
     <rich:popupPanel id="popup_sys_user_req" modal="false" autosized="true" resizeable="false"> 
         <f:facet name="header"> 
          <h:outputText value="Request New Sector/Category" /> 
         </f:facet> 
         <f:facet name="controls"> 
          <h:outputLink value="#" 
              onclick="#{rich:component('popup_sys_user_req')}.hide(); return false;"> 
           X 
          </h:outputLink> 
         </f:facet> 
         <h:panelGrid columns="2"> 
          <h:outputLabel value="Request New:" /> 
          <h:selectOneMenu id="sys_req_type" value="#{userController.selectedSysUserRequest.sysrequesttype}" required="true" > 
           <f:selectItems value="#{userController.getSysRequestTypeItems('SECTOR_CATEGORY')}"> 
           </f:selectItems> 
          </h:selectOneMenu> 
          <h:outputLabel value="Description:" /> 
          <h:inputTextarea id="user_req_desc" value="#{userController.selectedSysUserRequest.description(desc)}" required="true" requiredMessage="Decription is missing" /> 
         </h:panelGrid> 
         <a4j:commandButton action="#{userController.CreateSysUserRequest()}" value="Send Request" execute="sys_user_req_form" oncomplete="#{rich:component('popup_sys_user_req')}.hide(); return false;"/> 
        </rich:popupPanel> 
       </a4j:region> 
</h:form> 

的commandLink(重新編輯

<h:commandLink actionListener="#{userController.prepareCreateSysRequest}" value="Request New Sector/Category">  
    <f:ajax execute="popup_sys_user_req @this" render="popup_sys_user_req"> 
     <rich:componentControl id="popup_ctr" event="click" target="popup_sys_user_req" operation="show"/> 
    </f:ajax>         
</h:commandLink> 
---------------------------- 
//Managed Bean: 
public void prepareCreateSysRequest(ActionEvent event) { 
    selectedSysUserRequest = new Sysuserrequest(); 
    JsfUtil.log("Prepare Create System User Request"); 
} 

This post continues the dicussion有關彈出面板。 問候克里斯。

回答

1

如果我理解正確,您希望在popupPanel中提交所有表單元素,但在調用someAction1時不在面板之外?我可以想到兩種方法: 1.a4jcommandButton具有limitToList屬性,您可以列出要在服務器上更新哪些組件 2.在第一個窗體之外創建popupPanel,然後使用自己的窗體:

<h:form> 
... 
<a4j:commandButton action="someAction2"... 
</h:form> 

<rich:popupPanel> 
<h:form> 
... 
<a4j:commandButton action="someAction1"... 
</h:form> 
</rich:popupPanel> 

更新 如果您使用RichFaces的4可以更換限於列表與limitRender

屬性
+0

我使用richfaces 4,並且沒有用於commandbutton的limitToList。想想這就是爲什麼有地區,但不知道。將嘗試第二個建議。謝謝。 – Chris

+0

後續問題,我嘗試通過使用execute = @ form來限制處理。頁面上的第二個表單,但它接縫,它試圖提交另一個。富有:地區的路要走? – Chris

+0

當我將彈出面板移動到其自己的窗體中時,彈出面板的標題消失。 JSF是不是因爲我想的那麼虛弱? – Chris

1

的問題是,彈出是不是在JSF形式的孩子,你只需要使用domElementAttachment attribu改變這一點。因此,您的代碼如下所示:

<h.form> 
... 
<a4j:region> 
     <rich:popupPanel id="popup_sys_user_req" modal="false" autosized="true" resizeable="false" domElementAttachment="form"> 
     <f:facet name="header"> 
... 
相關問題