【发布时间】:2011-10-24 19:55:45
【问题描述】:
我正在尝试在另一个具有提交/操作事件的面板内的弹出面板中提交值。但是在打开弹出面板之前,我需要在我的托管 bean 上调用一个函数来创建一个新的实体对象。外部面板只有 h:form,因为您不能嵌套它们。我已将弹出面板包装在 a4j:region 中,以便在用户提交弹出面板内的值时仅提交此部分。这有效,但不是执行弹出面板时需要调用的准备函数。我试过 a4j:commandLink 但该组件不能与 rich:popupPanel 一起使用(奇怪,因为它们都是 Richfaces 组件?!)。所以我必须中继 h:commandLink 并使用 ajax。
当打开/呈现弹出面板的链接触发时,如何在托管 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 关于弹出面板。 问候克里斯。
【问题讨论】:
标签: jsf jakarta-ee richfaces