提交弹出面板内容,丰富:popupPanel

发布于 2024-11-29 07:28:39 字数 3136 浏览 0 评论 0原文

我正在尝试在另一个具有提交/操作事件的面板内的弹出面板中提交值。但在打开弹出面板之前,我需要在托管 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>

命令链接(重新编辑

<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");
}

这篇文章继续讨论有关弹出面板的内容。 问候克里斯。

I am trying to submit values in a pop-up panel inside another panel that has a submit/action event. But before opening pop-up panel I need to invoke a function on my managed bean that create a new entity object. The outer panel has the only h:form, since you can't nest them. I have wrapped the pop-up panel in a a4j:region to submit only this part when the use submits the values inside the pop-up panel. This works, but not the execution of the preparing function that need to be invoked when the pop-up panel executes. I have tried a4j:commandLink but that component don't work together with the rich:popupPanel (strange since both of them are Richfaces components?!). So I have to relay on the h:commandLink and use ajax.

How can I invoke a function on my managed bean when the link to open/render the pop-up panel fires?

(What is the correct pattern for this?)

PS. The initial question has changed, but not the problem concerning submitting values in a pop-up panel.

Part of the xhtml file:

<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>

The commandLink (re-edit)

<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 about the pop-up panel.
Greetings Chris.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ι不睡觉的鱼゛ 2024-12-06 07:28:39

如果我理解正确的话,当您调用 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,您可以将 limitToList 属性替换为 limitRender

If I understand correctly you want to submit all form elements inside popupPanel but not outside the panel when you invoke someAction1? I can think of two ways to do this:
1. a4jcommandButton has a limitToList attribute, you can list which components you want to be updated on the server
2. create your popupPanel outside of the first form and then use its own form:

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

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

Update
If you are using RichFaces 4 you can replace the limitToList attribute with limitRender

_失温 2024-12-06 07:28:39

问题是弹出窗口不是 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">
...

The problem is that the popup isn't a child of the form in jsf, you only need to use the domElementAttachment attribute to change that. So your code would look like this:

    <h.form>
...
<a4j:region>
      <rich:popupPanel id="popup_sys_user_req" modal="false" autosized="true" resizeable="false" domElementAttachment="form">
      <f:facet name="header">
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文