【问题标题】:xhtml add condition for label outputxhtml为标签输出添加条件
【发布时间】:2014-08-11 06:30:51
【问题描述】:

我想在我的网页上添加一个条件来检查检索到的值是否为空或其他:

xhtml

<div id="topbarMsg" class="topbar-msg">
    <c:if value="#{Bean.loginCustomer}" test = EMPTY>
        <h:outputFormat id="welId" value="#{msg['label.welcome']} ">
        </h:outputFormat>
    <c:if test = NOT EMPTY>        
        <h:outputFormat id="welId" value="#{msg['label.welcomeUser']} ">
            <f:param id="paramOneId" value="First Name" />
</div>

java 豆

private Customer loginCustomer;

public final Customer getLoginCustomer() {
    return loginCustomer;
}

从上面的代码中,它将检查名字是否为空,并从那里调用正确的标签以在网页中打印,但似乎无法正常工作。有人吗???

【问题讨论】:

    标签: jsf facelets


    【解决方案1】:

    如果没有看到您的 Customer bean 和您的实际消息,不可能给出结论性的答案,但应该有点接近这个:

    <div id="topbarMsg" class="topbar-msg">
        <h:panelGroup id="welId">
            <h:outputFormat rendered="#{empty Bean.loginCustomer}"
                value="#{msg['label.welcome']}" />  
            <h:outputFormat rendered="#{not empty Bean.loginCustomer}"
                value="#{msg['label.welcomeUser']} ">
    
                <f:param value="{Bean.loginCustomer.firstName}" />
            </h:outputFormat>
        </h:panelGroup>
    </div>
    

    【讨论】:

      【解决方案2】:

      试试这个,

      <h:outputFormat id="welId" value="#{Bean.loginCustomer eq empty ? msg['label.welcome']} : msg['label.welcomeUser']} ">
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-06-16
        • 2011-02-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-06-24
        • 2018-11-16
        相关资源
        最近更新 更多