Popuppanel在验证后保持打开状态

时间:2014-11-19 22:25:15

标签: jsf richfaces

我有一个富有面孔的popuppanel,我希望在所有验证完成之前保持打开状态。现在我只是在地址上有一个必需的属性。如果地址丢失并且单击了“提交”按钮,则popuppanel应保持打开状态,直到输入该地址为止。但是,当用户输入地址时,表单会按原样发送电子邮件,但页面保持打开状态。输入必填字段时,我需要关闭popuppanel。

<rich:popupPanel id="addressModalPanel" header="Change Billing Address" modal="true" domElementAttachment="form" width="450" height="400">
            <h2>Submit Change of Billing Address</h2>
            <h:outputLabel value="Enter changes to your company's billing address in the fields below and then click Submit" /><br></br>             
                <h:panelGrid columns="2" >                      
                    <h:outputLabel value="Company Name: "/>
                    <h:inputText value="#{supplieraddress.supplierAddress.supplierName}" disabled="true" />
                    <h:outputLabel value="Vendor Number: " />
                    <h:inputText value="#{supplieraddress.supplierAddress.id}" disabled="true"/>
                    <h:outputLabel value="Address: " />
                    <h:inputText id="add1" value="#{supplieraddress.supplierAddress.add1}" required="true" requiredMessage="Address is required" style="width:200px" />                                                
                    <h:outputLabel value=""/>
                    <h:inputText value="#{supplieraddress.supplierAddress.add2}" style="width:200px" />
                    <h:outputLabel value=""/>
                    <h:inputText value="#{supplieraddress.supplierAddress.add3}" style="width:200px" />
                    <h:outputLabel value="City: " />
                    <h:inputText id="city" value="#{supplieraddress.supplierAddress.city}" />
                    <h:outputLabel value="State: " />
                    <h:inputText id="state" value="#{supplieraddress.supplierAddress.state}" style="width:50px" />                            
                    <h:outputLabel value="Zip: " />
                    <h:inputText id="zip" value="#{supplieraddress.supplierAddress.zip}" style="width:50px" />                            
                    <h:outputLabel value="Country (If not US): " />
                    <h:inputText id="country" value="#{supplieraddress.supplierAddress.country}" style="width:50px" />                                                            

                    <a4j:commandButton id="submit" value="Submit" actionListener="#{supplieraddress.billingAddressEmail()}" oncomplete="if(#{!empty add1}) #{rich:component('addressModalPanel')}.hide()" >

                    </a4j:commandButton>   

                    <h:commandButton value="Close" >              
                        <rich:componentControl event="click" target="addressModalPanel" operation="hide" />             
                    </h:commandButton>

                    <a4j:outputPanel ajaxRendered="true">
                        <rich:message for="add1" style="color:red"/>
                    </a4j:outputPanel>                       

                </h:panelGrid>                          


            </rich:popupPanel>

1 个答案:

答案 0 :(得分:0)

if(#{!empty add1})看起来像是对empty运营商的误用; empty仅适用于收藏集。你应该使用什么

<a4j:commandButton id="submit" value="Submit" actionListener="#{supplieraddress.billingAddressEmail()}" oncomplete="if(!#{facesContext.validationFailed}) #{rich:component('addressModalPanel')}.hide()" >

其中facesContext.validationFailed是检查当前JSF上下文的验证状态的便捷方法