Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 所需的验证取决于向导中不工作的特定按钮_Jsf_Jsf 2_Primefaces - Fatal编程技术网

Jsf 所需的验证取决于向导中不工作的特定按钮

Jsf 所需的验证取决于向导中不工作的特定按钮,jsf,jsf-2,primefaces,Jsf,Jsf 2,Primefaces,我试图在中实现BalusC的答案,但当我试图使所需的条件依赖于我用来控制向导的“后退”和“下一步”的按钮时,它不起作用。如何才能做到这一点 <h:form id="form" enctype="multipart/form-data" acceptcharset="ISO-8859-1" > <p:growl id="growl" sticky="true" showDetail="true"/> <p:wizard id="wizard

我试图在中实现BalusC的答案,但当我试图使所需的条件依赖于我用来控制向导的“后退”和“下一步”的按钮时,它不起作用。如何才能做到这一点

<h:form id="form" enctype="multipart/form-data" acceptcharset="ISO-8859-1" >  

    <p:growl id="growl" sticky="true" showDetail="true"/>  

    <p:wizard id="wizard" flowListener="#{myBean.onFlowProcess}" showNavBar="false" widgetVar="wizardWV"> 

        <p:tab id="tab1" title="Tab 1"  >  
            <p:panel header="Panel for tab 1">  

                <p:message for="year" />
                <br /> 

                <table>
                    <tr>
                        <td>
                            <h:outputLabel value="Year: "  />
                        </td>
                        <td>
                            <p:inputMask 
                                id="year"
                                value="#{myBean.year}" 
                                required="#{not empty param[nextPanel.clientId]}"
                                requiredMessage="Year is required!"
                                style="width:70px;"  
                                mask="9999" 
                                maxlength="4" 
                            />
                        </td>
                    </tr>
                </table>
            </p:panel>
        </p:tab>

        <p:tab id="tab2" title="Tab 2"  >  
            <p:panel header="Panel for tab 2">  
            </p:panel>
        </p:tab>

    </p:wizard>

    <p:commandButton id="backPanel"  value="Back" onclick="PF('wizardWV').back();" styleClass="internalButton"  />
    <p:commandButton id="nextPanel" binding="#{nextPanel}" value="Next" onclick="PF('wizardWV').next();" styleClass="internalButton" />

</h:form> 



为什么这个问题没有得到回答? 正如@BalusC所说,答案很简单,只需将
@process=“this”

但如果你真的是指“设计”,比如特性/功能,是的,你可以通过它的“小部件”和向导交互,就像你所做的一样,定义你自己的控件。 在您的特定情况下我看不到“设计”的区别,我看到的是向导组件的标准行为,在按下“下一步”按钮时处理当前向导选项卡(并验证其所有组件)

仅对已处理组件(位于执行列表内)触发验证,您可以使用任何ajax组件/事件的
process=“…”
属性控制此列表

您可能希望更改该页面中处理
@all
@form
的另一个组件的默认行为

从您在评论中所说的内容来看,该页面中至少有另一个组件具有ajax行为,如
p:autocomplete
,并且您可能正在使用PF<4.0

在这种情况下,您可以将
process=“@this”
添加到
p:autocomplete
中,以防止处理(然后验证)向导选项卡内的其他组件,如
p:inputMask


@埃里克,我首先想到的是:

<p:wizard binding="#{wizardComponent}" ...>
    <p:tab id="tab0" ...>
        ...
    </p:tab>
    ...
</p:wizard>
<p:commandButton rendered="#{wizardComponent.step != 'tab0'}" value="Back" onclick="PF('wizardWV').back();" />

...
...

向导的“后退”按钮首先是否真的需要执行完整的回发(提交整个表单)?看起来它可能只是一个
type=“button”
或一个
(在
onclick
的末尾带有
return false
)。这也将立即解决“不必要的验证”问题。否则只需添加
process=“@this”
,如果您确实需要回发。@BalusC,,谢谢您的回答,但我没有得到它。。。使按钮返回为false;在onclick结束时,或为添加process=“@this”时,没有解决我的问题。“下一步”按钮仍会转到下一个面板,而不会验证任何内容。。我只需要在单击“下一步”按钮时对每个面板进行验证。我没有说任何关于“下一步”按钮的内容。@BalusC但你所说的“这也会立即解决不必要的验证问题”是什么意思?因为在没有回发的情况下创建按钮,根本不需要执行验证。谢谢您的回答。首先,使用自定义导航栏的关键是能够使用自己设计的按钮。其次,你不明白我想做什么。所需条件不能为真,只能通过“下一步”按钮触发验证。按照您建议的方式,页面中使用faces bean进行迭代的任何其他元素都将触发验证,例如primefaces autocomplete。当使用自定义nav变量时,如何仅在必要时显示后退按钮?i、 e:一开始没有tab@MicheleMariotti非常感谢。但在我尝试以这种方式实施之前,你能看看我昨天发布的这个问题,看看你是否有答案吗?
<p:commandButton type="button" value="Back" onclick="PF('wizardWV').back();" />
<p:commandButton type="button" value="Next" onclick="PF('wizardWV').next();" />
Wizard resides in a container element that style and styleClass attributes apply.
Following is the list of structural css classes.

Selector               Applies
.ui-wizard             Main container element.
.ui-wizard-content     Container element of content.
.ui-wizard-step-titles Container of step titles.
.ui-wizard-step-title  Each step title.
.ui-wizard-navbar      Container of navigation controls.
.ui-wizard-nav-back    Back navigation control.
.ui-wizard-nav-next    Forward navigation control.
<p:wizard binding="#{wizardComponent}" ...>
    <p:tab id="tab0" ...>
        ...
    </p:tab>
    ...
</p:wizard>
<p:commandButton rendered="#{wizardComponent.step != 'tab0'}" value="Back" onclick="PF('wizardWV').back();" />