相关疑难解决方法(0)

如何在JSF中隐藏元素?

是否可以div根据条件隐藏等等(就像你在EL中使用渲染属性一样),而不必将其包装在<h:panelGrid ...>具有渲染属性的etc中?它破坏了我的布局.我只需要逻辑,而不是布局.

jsf

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

隐藏/显示表单取决于selectOneMenu值的更改

我有一个带有a的页面,<h:selectOneMenu>我想显示一些字段或其他字段,具体取决于selectOneMenu的选择值.这是可能的,如果是的话,怎么样?

show hide jsf-2 drop-down-menu

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

JSTL c:选择c:不在JSF页面中工作

考虑以下jstl选择:

<c:choose>
    <c:when test="#{AuthMsgBean.rw['2'] ne null}">
        Display Text
    </c:when>

    <c:otherwise>
        <ph:outputText id="pan" value="Component pan could not be created." />
    </c:otherwise>
</c:choose>
Run Code Online (Sandbox Code Playgroud)

AuthMsgBean = Bean

rw =地图

'2'=关键


题:

当我只是显示#{AuthMsgBean.rw['2'] ne null}它显示的值(true)时,但是一旦我尝试将值解析<c:when test=""/>为when标记重新执行,就好像测试始终为false.

如果我在test(test="true")中输入true,则显示Display Text.

是否可以<c:when>#{AuthMsgBean.rw['2'] ne null}表达式之前评估标记?

如果是这样,有解决方法吗?

java jsf jstl

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

如何检查用户是否已登录?

我希望在用户未登录时显示登录链接,并在用户登录时显示登出链接.我正在使用中定义的容器管理安全性web.xml.

我怎样才能做到这一点?

jsf jsf-2

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

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页面的替代案例

除了c:if或者c:choose,有没有更好的方法来实现几个组件中的1个组件的条件渲染.像JSF页面的开关案例?

jsf jstl facelets jsf-2

4
推荐指数
1
解决办法
8038
查看次数

根据 h:selectOneMenu 值隐藏和显示组件

我有一个带有 a 的页面,<h:selectOneMenu>我想根据菜单的所选值显示某些字段或其他字段。这是可能的,如果是,如何?

<h:selectOneMenu id="productname" value="#{product.productname}" required="true"> 
    <f:selectItem itemLabel="select" itemValue="null" />  
    <f:selectItem itemLabel="Detetgent" itemValue="Detergent"/>  
    <f:selectItem itemLabel="Dishwash" itemValue="Dishwash" />  
    <f:selectItem itemLabel="Powder" itemValue="Powder" />  
    <f:selectItem itemLabel="Liquid" itemValue="Liquid" />       
</h:selectOneMenu>
<h:panelGroup rendered="Detergernt">
    <p>This will be shown if the selected item Detergent.</p>
</h:panelGroup>
<h:panelGroup >
    <p>This will be shown if the selected item Dishwash.</p>
</h:panelGroup>
<h:panelGroup >
    <p>This will be shown if the selected item equal to powder.</p>
</h:panelGroup>
<h:panelGroup >
    <p>This will be shown if the selected item equals to Liquid.</p> …
Run Code Online (Sandbox Code Playgroud)

ajax jsf

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

如何在jsf/icefaces中启用/禁用组件?

我正在寻找如何根据用户登录启用和禁用icefaces组件?例如:

如果以管理员身份登录我需要启用更多组件并以用户身份登录,请禁用某些组件以及在一个页面中添加其他组件?如何在jsf/icefaces中执行此功能?

这两个在一个页面中启用和禁用.

我提出你的建议.

jsf icefaces

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

选择一个selectOneMenu后,渲染其他selectOneMenu组件

我希望<h:selectOneMenu>通过选择main来显示多个<h:selectOneMenu>

这个例子不起作用

<h:form id="selectForm">
    <h:selectOneMenu id="main" value="#{bean.main}">
         <f:selectItem itemValue="1" itemLabel="1"/>
         <f:selectItem itemValue="2" itemLabel="2"/>
         <f:selectItem itemValue="3" itemLabel="3"/>
         <f:selectItem itemValue="4" itemLabel="4"/>
         <f:ajax render="hotelSearch"/>
    </selectOneMenu>
    //this one is displayed if main is greater than 1
    <h:selectOneMenu id="2" rendered="main>1">
         <f:selectItem itemValue="1" itemLabel="1"/>
         <f:selectItem itemValue="2" itemLabel="2"/>
         <f:selectItem itemValue="3" itemLabel="3"/>
         <f:selectItem itemValue="4" itemLabel="4"/>
    </h:selectOneMenu>
    //this one is displayed if main is greater than 2
    <h:selectOneMenu id="3" rendered="main>2">
         <f:selectItem itemValue="1" itemLabel="1"/>
         <f:selectItem itemValue="2" itemLabel="2"/>
         <f:selectItem itemValue="3" itemLabel="3"/>
         <f:selectItem itemValue="4" itemLabel="4"/>
    </h:selectOneMenu>
</h:form>
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

jsf el jsf-2

3
推荐指数
1
解决办法
5253
查看次数

在EL表达式中使用多个布尔条件

我想知道如何在EL中组合多个布尔条件.我有以下示例,它不起作用.

<x:someComponent rendered="#{bean.condition1} or #{bean.condition2}">
Run Code Online (Sandbox Code Playgroud)

如何在EL中使用"OR"和"AND"逻辑运算符?

jsf el or-operator and-operator

2
推荐指数
1
解决办法
5333
查看次数

有条件地基于selectOneMenu值渲染组件

有没有办法根据用户从selectOneMenu组件中选择的当前值渲染组件?我的selectOneMenu组件填充了一个由两个值组成的枚举,吸烟者和非吸烟者.如果用户选择了吸烟者,我想在其下方呈现一个复选框,让用户检查他们每天抽烟的次数10,20,30 +等.如果用户选择非吸烟者,我也希望相反的工作即复选框不会渲染/消失.

jsf selectonemenu conditional-rendering

2
推荐指数
1
解决办法
9140
查看次数