如何从复合组件跳过表单验证



我有一个用于用户确认删除操作的复合组件。但问题是,当用户点击"是",程序试图验证其他输入字段在我的表单。我认为直接属性不起作用。我如何在我的表单中跳过其他输入字段?

我的观点;

<h:form>
<p:commandButton id="myButtonId" onclick="deleteDialog.show();" icon="ui-icon-trash" title="Delete"/>
//someinputfields and validators
<bzn:deleteConfirmDialog actionListener="#{addressBookController.deleteParty()}">
        </bzn:deleteConfirmDialog>
    </h:form>

这是我的复合组件;

<composite:interface>       
    <composite:attribute name="actionListener" 
                         method-signature="java.lang.String action()" />
</composite:interface>
<composite:implementation>
    <p:dialog id="deleteDialogId"                  
              widgetVar="deleteDialog"
              resizable="false"
              height="100"
              width="250"
              >
        <p:outputPanel>                
            <center>
                <p:commandButton value="Yes" immediate="true"
                                 actionListener="#{cc.attrs.actionListener}"
                                 oncomplete="deleteDialog.hide();"/>
                <p:commandButton value="No" oncomplete="deleteDialog.hide();"/>
            </center>
        </p:outputPanel>
    </p:dialog>
</composite:implementation>

属于一个表单的所有输入/按钮必须放在它自己的<h:form>中。

换句话说,不要使用"God"形式。给对话框自己的<h:form>(并确保它没有嵌套在另一个<h:form>中)。

,

<h:form>
    ...
</h:form>
<p:dialog>
    <h:form>
        ...
    </h:form>
</p:dialog>

注意,与复合组件没有任何关系。当你把所有东西放在一个SSCCE风格的视图中时,你会有完全相同的问题(你最好在发布问题之前已经完成了)。

顺便说一下,自1998年HTML 4.01以来,<center>元素已被弃用。我不确定你是从哪里学的HTML,但我建议你寻找最新的资源,最好不要超过3年。

最新更新