我正在尝试在另一个具有提交/操作事件的面板中的弹出式面板中提交值。但在打开弹出面板之前,我需要在托管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关于弹出式面板。 问候克里斯。
答案 0 :(得分:1)
如果我理解正确你想要在调用someAction1时提交popupPanel中的所有表单元素但不在面板外提交?我可以想到两种方法: 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
替换limitToList属性答案 1 :(得分:1)
问题是弹出窗口不是jsf中窗体的子窗口,您只需要使用 domElementAttachment 属性来更改它。所以你的代码看起来像这样:
<h.form>
...
<a4j:region>
<rich:popupPanel id="popup_sys_user_req" modal="false" autosized="true" resizeable="false" domElementAttachment="form">
<f:facet name="header">
...