相关疑难解决方法(0)

JSF2 Facelets中的JSTL有意义吗?

我想有条件地输出一些Facelets代码.

为此,JSTL标签似乎工作正常:

<c:if test="${lpc.verbose}">
    ...
</c:if>
Run Code Online (Sandbox Code Playgroud)

但是,我不确定这是否是最佳做法?还有另一种方法来实现我的目标吗?

jsf jstl facelets jsf-2

159
推荐指数
2
解决办法
8万
查看次数

在JSF页面中定义和重用EL变量

是否可以在EL表达式中定义变量并重新使用该变量?

例如 :

<h:inputText 
   value="#{myBean.data.something.very.long}"
   rendered="#{myBean.data.something.very.long.showing}"
/>
Run Code Online (Sandbox Code Playgroud)

我的想法是这样的:

<!-- 
     somehow define a variable here like : 
     myVar = #{myBean.data.something.very.long} 
-->
<h:inputText 
   value="#{myVar}"
   rendered="#{myVar.showing}"
/>
Run Code Online (Sandbox Code Playgroud)

有任何想法吗 ?谢谢 !

jsf el jsf-2

56
推荐指数
2
解决办法
8万
查看次数

JSF形式的IF-ELSE条件.需要知道正确的方法

我的表单上有if-else条件,我在其中显示标题和按钮文本以进行添加和更新.

下面我在struts2项目中使用的代码和相同的代码想在xhtml页面的JSF2项目中使用.

Struts2

 <s:if test="person==null || person.id==null || person.id==''">
                <s:set var="buttonText" value="getText('person.button.add')"/>
                <s:text name="person.h1.add.text"/>
                <i><s:text name="person.smallfont.add.text"/></i>
            </s:if>
            <s:else>
                <s:set var="buttonText" value="getText('person.button.edit')"/>
                <s:text name="person.h1.edit.text"/>
                <s:text name="person.smallfont.edit.text"/>
            </s:else>
Run Code Online (Sandbox Code Playgroud)

我可以在xhtml页面中使用JSTL并使用上面的代码,但我在下面使用EL看到了不同的方法.我不确定,但不喜​​欢下面的方法

<h:outputLabel value="Add Information" rendered="#{!empty personBean.person.id}" />
<h:outputLabel value="Use the form below to add your information." rendered="#{!empty personBean.person.id}" />

<h:outputLabel value="Update Information" rendered="#{empty personBean.person.id}" />
<h:outputLabel value="Use the form below to edit your information." rendered="#{empty personBean.person.id}" />
Run Code Online (Sandbox Code Playgroud)

我的问题:

有人指导我如何在JSF项目的IF-ELSE条件中使用上面的代码.使用EL/JSTL还是其他?

jsf-2

5
推荐指数
1
解决办法
6万
查看次数

标签 统计

jsf-2 ×3

jsf ×2

el ×1

facelets ×1

jstl ×1