如何在弹出式面板中提交值? [英] How to submit values in a pop-up panel?

查看:105
本文介绍了如何在弹出式面板中提交值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有豆挣扎着理解如何以正确的方式使用 rich:popupPanel 组件。有一些关于如何使用 rich:popupPanel 以及如何从中提交值的帖子(至少我没有找到)。



为了让事情变得更糟,面板接缝添加(当检查html时)将一个硬编码的_content添加到其组件id名称(生成的div)。我试图使用 aj4:region 标签来部分呈现完整的表单。但是这并没有起作用,因为没有发布到管理bean的地方。所以现在我还剩下一个选项,面板有自己的形式,在页面的主窗口之外。

我可以看到表单(弹出)值的评估正在发生,但没有执行持久化值的bean函数(我看到POST请求命令按钮)。我现在能想到的唯一原因是,弹出式面板使用另一个bean来坚持页面上的主窗体的值(它们都是会话范围)。
我在考虑忽略弹出式面板,因为它很难完成这项工作。也许它是一个众所周知的秘密,因为它很少发布它。如果使用 componentController 或仅使用 a4j:commanLink ,则表现相同。

如何从 rich:popupPanel 提交值并调用支持bean函数来保存弹出窗体值? / p>

感谢克里斯,如果有人能够对此有所了解,请致电克里斯。

我在Glassfish 3.1上使用Richfaces 4.0-final

 < h:form id =main_form> 
<! - 弹出命令 - >
< a4j:commandLink actionListener =#{userController.prepareCreateSysRequest}oncomplete =#{rich:component('popup_sys_user_req_form:popup_sys_user_req')}。show(); return false;
execute =@ thisvalue =请求新扇区/类别/>

...
< a4j:commandButton action =#{projectController.Create}...>
< / h:表格>

< rich:popupPanel id =popup_sys_user_reqmodal =trueautosized =trueresizeable =false>
< f:facet name =header>
< h:outputText value =新建项目请求/>
< / f:facet>
< f:facet name =controls>
onclick =#{rich:component('popup_sys_user_req')}。hide(); return false;>
X
< / h:outputLink>
< / f:facet>
< h:panelGrid columns =2>
< h:outputLabel value =请求新:/>
< h:selectOneMenu id =sys_req_typevalue =#{userController.selectedSysRequestType}required =truerequiredMessage =请求类型是必需的title =请求类型>
< f:selectItems value =#{userController.getSysRequestTypeItems()}>
< / f:selectItems>
< / h:selectOneMenu>
< h:outputLabel value =说明:/>
< h:inputTextarea id =user_req_descvalue =#{userController.selectedSysUserRequest.description}required =truerequiredMessage =Decription is missing/>
< / h:panelGrid>
< a4j:commandButton action =#{userController.CreateSysUserRequest}onclick =#{rich:component('popup_sys_user_req')}。hide(); return false; execute =@ formrender =popup_sys_user_req_formvalue =发送请求/>
< / rich:popupPanel>
< / h:表格>


解决方案

第一次只提交两次。

为了修复它,表单必须在popupPane之外。而且popupPanel应该有attibute domElementAttachment =form。



示例。

 < h:表格> 
< rich:popupPanel id =shipmentItemUpdateDialog
autosized =true
domElementAttachment =form>
< f:facet name =header>
< h:panelGroup>
< h:outputText value =#{shipmentBundle.shipmentItemDetailsHeader}/>
< / h:panelGroup>
< / f:facet>
< f:facet name =controls>
< h:commandLink>
< rich:componentControl target =shipmentItemUpdateDialogoperation =hide/>
< / h:commandLink>
< / f:facet>
< h:outputText for =shipmentItemName
value =#{coreBundle.requiredChar}#{shipmentBundle.shipmentItemName}
/>
< h:inputText id =shipmentItemName
disabled =false
required =true
value =#{shipmentItemController.shipmentItemUI.value.name}
label =#{shipmentBundle.shipmentItemName}
size =40>
< / h:inputText>

< h:outputText for =shipmentItemCode
value =#{coreBundle.requiredChar}#{shipmentBundle.shipmentItemCode}
/>
< h:inputText id =shipmentItemCode
disabled =false
required =true
value =#{shipmentItemController.shipmentItemUI.value.code}
label =#{shipmentBundle.shipmentItemCode}
size =40>
< / h:inputText>

< h:outputText value =#{coreBundle.requiredChar}#{shipmentBundle.shipmentItemAmount}
/>
< h:inputText id =shipmentItemAmount
disabled =false
required =true
value =#{shipmentItemController.shipmentItemUI.value.amount}
label =#{shipmentBundle.shipmentItemAmount}
size =4>
< f:validateLongRange minimum =1/>
< / h:inputText>


< h:outputText value =#{coreBundle.requiredChar}#{shipmentBundle.shipmentItemNeedsCooling}
/>
< h:selectBooleanCheckbox id =shipmentItemNeedsCooling
disabled =false
required =true
value =#{shipmentItemController.shipmentItemUI.value.needsCooling}
label =#{shipmentBundle.shipmentItemNeedsCooling}
/>

< h:outputText for =shipmentItemDetails
value =#{shipmentBundle.shipmentItemDetails}
/>
< h:inputTextarea id =shipmentItemDetails
disabled =false
required =true
value =#{shipmentItemController.shipmentItemUI.value.details}
label =#{shipmentBundle.shipmentItemDetails}
cols =38
rows =5
/>
< / h:panelGrid>

< h:panelGrid columns =1dir =LTR>
< h:panelGrid columns =2dir =LTR>
< a4j:commandButton value =#{coreBundle.acceptButton}
action =#{shipmentItemController.onUpdate()}
render =shipmentItemsTable>
< / a4j:commandButton>
< h:commandLink value =#{coreBundle.closeLink}
immediate =true>
< rich:componentControl target =shipmentItemUpdateDialogoperation =hide/>
< / h:commandLink>
< / h:panelGrid>
< h:outputText value =#{coreBundle.requiredText}/>
< / h:panelGrid>
< / rich:popupPanel>
< / h:表格>

我希望这有助于您。


I have bean struggling to understand how to use the rich:popupPanel component in the right way. There are (at least not that I could find) few post about how to use the rich:popupPanel and how to submit values from it.

To make matter worse the panel seams to add (when checking the html) a hard coded "_content" to its component id name (to the div generated). I have tried to use aj4:region tag to partial render the complete form. But that didn't seamed to work, cause nothing where posted to managed bean. So now I have one option left, where the panel has its own form, outside the main one on the page.

I can see that the evaluation of the form (popup) values is happening, but not the execution of the bean function that persist the values (I see the POST request of the command button). The only reason I can think of at the moment, is that the pop-up panel use another bean to persist the values that the main form on the page (both of them are session scoped). I am thinking of omit the pop-up panel all together, since it seams so hard to make this work. Maybe its a well know secret, since it so few post about it. It behaves the same if if use componentController or only a a4j:commanLink.

How is it possible to submit values from a rich:popupPanel and invoke a backing bean function to persist the pop-up form values ?

Appreciate if someone can shed some light on this, greetings Chris.

I use Richfaces 4.0-final on Glassfish 3.1

<h:form id="main_form">
<!-- Command for popup -->
<a4j:commandLink actionListener="#{userController.prepareCreateSysRequest}" oncomplete="#{rich:component('popup_sys_user_req_form:popup_sys_user_req')}.show(); return false;" 
                                     execute="@this" value="Request New Sector/Category" />

    ...
<a4j:commandButton action="#{projectController.Create}" ...>
</h:form>

<h:form id="popup_sys_user_req_form">
    <rich:popupPanel id="popup_sys_user_req" modal="true" autosized="true" resizeable="false">
        <f:facet name="header">
            <h:outputText value="New Project Request" />
        </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.selectedSysRequestType}" required="true" requiredMessage="Request Type is required" title="Request Type">
                <f:selectItems value="#{userController.getSysRequestTypeItems()}">
                </f:selectItems>
            </h:selectOneMenu>
            <h:outputLabel value="Description:" />
            <h:inputTextarea id="user_req_desc" value="#{userController.selectedSysUserRequest.description}" required="true" requiredMessage="Decription is missing" />
        </h:panelGrid>
        <a4j:commandButton action="#{userController.CreateSysUserRequest}" onclick="#{rich:component('popup_sys_user_req')}.hide(); return false;" execute="@form" render="popup_sys_user_req_form" value="Send Request" />
    </rich:popupPanel>
</h:form>

解决方案

For what I have done I used to have the issue to got to submit twice only the first time.

To fix it the form got to be outside the popupPane. And also that the popupPanel should have the attibute domElementAttachment="form".

Example.

        <h:form>
            <rich:popupPanel id="shipmentItemUpdateDialog" 
                             autosized="true"
                             domElementAttachment="form">
                <f:facet name="header">
                    <h:panelGroup>
                        <h:outputText value="#{shipmentBundle.shipmentItemDetailsHeader}" />
                    </h:panelGroup>
                </f:facet>
                <f:facet name="controls">
                    <h:commandLink>
                        <h:graphicImage value="/core/images/modal/close.png"/>
                        <rich:componentControl target="shipmentItemUpdateDialog" operation="hide" />
                    </h:commandLink>
                </f:facet>
                <h:outputText for="shipmentItemName"
                              value="#{coreBundle.requiredChar} #{shipmentBundle.shipmentItemName}"
                              />
                <h:inputText id="shipmentItemName" 
                             disabled ="false"
                             required ="true"
                             value="#{shipmentItemController.shipmentItemUI.value.name}" 
                             label="#{shipmentBundle.shipmentItemName}"
                             size="40" >
                </h:inputText>  

                <h:outputText for="shipmentItemCode"
                              value="#{coreBundle.requiredChar} #{shipmentBundle.shipmentItemCode}"
                              />
                <h:inputText id="shipmentItemCode" 
                             disabled ="false"
                             required ="true"
                             value="#{shipmentItemController.shipmentItemUI.value.code}" 
                             label="#{shipmentBundle.shipmentItemCode}"
                             size="40" >
                </h:inputText>         

                <h:outputText value="#{coreBundle.requiredChar} #{shipmentBundle.shipmentItemAmount}"
                              />
                <h:inputText id="shipmentItemAmount" 
                             disabled ="false"
                             required ="true"
                             value="#{shipmentItemController.shipmentItemUI.value.amount}" 
                             label="#{shipmentBundle.shipmentItemAmount}"
                             size="4" >
                    <f:validateLongRange minimum="1"/>
                </h:inputText>      


                <h:outputText value="#{coreBundle.requiredChar} #{shipmentBundle.shipmentItemNeedsCooling}"
                              />
                <h:selectBooleanCheckbox id="shipmentItemNeedsCooling" 
                                         disabled ="false"
                                         required ="true"
                                         value="#{shipmentItemController.shipmentItemUI.value.needsCooling}" 
                                         label="#{shipmentBundle.shipmentItemNeedsCooling}"
                                         />                    

                <h:outputText for="shipmentItemDetails"
                              value="#{shipmentBundle.shipmentItemDetails}"
                              />
                <h:inputTextarea id="shipmentItemDetails" 
                                 disabled ="false"
                                 required ="true"
                                 value="#{shipmentItemController.shipmentItemUI.value.details}" 
                                 label="#{shipmentBundle.shipmentItemDetails}"
                                 cols="38" 
                                 rows="5" 
                                 /> 
            </h:panelGrid>

            <h:panelGrid columns="1" dir="LTR">
                <h:panelGrid columns="2" dir="LTR">
                    <a4j:commandButton value="#{coreBundle.acceptButton}" 
                                       action="#{shipmentItemController.onUpdate()}"
                                       render="shipmentItemsTable">
                    </a4j:commandButton>
                    <h:commandLink value="#{coreBundle.closeLink}" 
                                   immediate="true">
                        <rich:componentControl target="shipmentItemUpdateDialog" operation="hide" />
                    </h:commandLink>
                </h:panelGrid>
                <h:outputText value="#{coreBundle.requiredText}"/>
            </h:panelGrid>
            </rich:popupPanel>              
        </h:form>

I hope this helps.

这篇关于如何在弹出式面板中提交值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆