首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EL表达式的JSF困难

EL表达式的JSF困难
EN

Stack Overflow用户
提问于 2013-03-30 02:28:11
回答 2查看 262关注 0票数 1

我在使用属性"required“JSF2+ Prime Faces 3.5时遇到了一个问题。

下面的代码运行得很好:

代码语言:javascript
复制
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">

<ui:decorate template="/templates/main_template.xhtml">
    <ui:define name="centro">
        <h:head>
        </h:head>
        <h:body>
            <f:view>
                <h:form id="form">

                    <h3>TITLE</h3>



                    <h:panelGrid id="panel1" columns="3">

                        <h:outputLabel for="input1" value="Input1" />
                        <p:inputText id="input1" value="#{controller.myObject.input1}" label="input1" required="#{empty param['form:input3']}"/>
                        <p:message for="input1" />

                        <h:outputLabel for="input2" value="Input2" />
                        <p:inputText id="input2" value="#{controller.myObject.input2}" label="input2" required="#{empty param['form:input3']}"/>
                        <p:message for="input2" />

                        <h:outputLabel for="input3" value="Input3" />
                        <p:inputText id="input3" value="#{controller.myObject.input3}" label="input3" required="#{empty param['form:input1']}"/>
                        <p:message for="input3" />

                    </h:panelGrid>


                    <p:commandButton id="btn" value="Save" update="form" actionListener="#{controller.save}" />

                </h:form>
            </f:view>
        </h:body>
</ui:define>
</ui:decorate>
</html>

如果我在代码中添加了一个TAB视图,则所需的字段验证将不再有效,如下所示:

代码语言:javascript
复制
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">

<ui:decorate template="/templates/main_template.xhtml">
    <ui:define name="centro">
        <h:head>
        </h:head>
        <h:body>
            <f:view>
                <h:form id="form">

                    <h3>#{msgs.clienteCadastroTitulo}</h3>

                    <p:tabView id="tabView">

                    <p:tab id="tab1" title="TAB 1">


                    <h:panelGrid id="panel1" columns="3">

                        <h:outputLabel for="input1" value="Input1" />
                        <p:inputText id="input1" value="#{controller.myObject.input1}" label="input1" required="#{empty param['form:input3']}"/>
                        <p:message for="input1" />

                        <h:outputLabel for="input2" value="Input2" />
                        <p:inputText id="input2" value="#{controller.myObject.input2}" label="input2" required="#{empty param['form:input3']}"/>
                        <p:message for="input2" />

                        <h:outputLabel for="input3" value="Input3" />
                        <p:inputText id="input3" value="#{controller.myObject.input3}" label="input3" required="#{empty param['form:input1']}"/>
                        <p:message for="input3" />
                    </h:panelGrid>

                    </p:tab>

                    </p:tabView>

                    <p:commandButton id="btn" value="Save" update="form" actionListener="#{controller.save}" />

                </h:form>
            </f:view>
        </h:body>
    </ui:define>
</ui:decorate>
</html>

我不会在这里发布我尝试过的一切,但他们可以肯定我已经尝试过使用教程中概述的各种方法,其他用户的问题等。

尽管如此,我还是不能理解我哪里错了,你想给我一些提示,这样我就可以正确地执行验证了。

基本上,我的必需属性应该是动态的,根据表单中的字段填充与否。

提前感谢大家。

EN

回答 2

Stack Overflow用户

发布于 2013-03-30 05:22:53

如果您查看API文档http://www.primefaces.org/docs/api/3.5/org/primefaces/component/tabview/TabView.html

tabview正在实现javax.faces.component.NamingContainer,因此您需要使用命名容器分隔符":“来包含它的id。

代码语言:javascript
复制
form:tabView:input3
票数 1
EN

Stack Overflow用户

发布于 2013-03-30 04:57:16

可能通过添加和,您更改了参数‘for :inputX’的路径,尝试将其更改为参数‘for:tab1:inputX’或参数‘for:tabView:tab1:inputX’。不确定确切的组合,但真的希望这是错误的原因。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15709219

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档