小编luk*_*kas的帖子

PrimeFaces中不同组件的不同Ajax状态

在我的网页上,我使用了模态的全局ajax状态.也就是说,当存在ajax调用时,阻止用户执行其他操作并被迫等待.像这儿:

http://www.primefaces.org/showcase-labs/ui/ajaxStatusScript.jsf

但是,页面上的所有组件都不需要这种行为.例如,对于自动完成,在自动完成组件旁边使用非阻塞功能会更好.在RichFaces中,自动完成组件有状态属性.

在PrimeFaces(3.4 SNAPSHOT)中,有没有办法如何在页面上有两个不同的ajax状态,根据需要独立触发它们?

谢谢,卢卡斯

primefaces jsf-2

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

h:带有布尔项的selectOneMenu不能使用空值

我正在使用JSF 2.0,JBoss 7.1.1 Final,我遇到了selectOneMenu的问题.我希望能够将托管bean中的字段设置为true/false/null.因此,我创建了以下selectOneMenu:

<h:selectOneMenu value="#{personList.criteria.registrationComplete}" >
    <f:selectItem itemValue="#{null}" itemLabel="Any.." />
    <f:selectItem itemValue="true" itemLabel="Yes"/>
    <f:selectItem itemValue="false" itemLabel="No"/>
</h:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)

现在,如果我选择'Any ..',它将为registrationComplete字段(布尔值)分配"false".所以null被解释为false.我还尝试在selectItem中使用布尔值,即:

 <h:selectOneMenu value="#{personList.criteria.registrationComplete}" >
    <f:selectItem itemValue="#{null}" itemLabel="Any.." />
    <f:selectItem itemValue="#{true}" itemLabel="Yes"/>
    <f:selectItem itemValue="#{false}" itemLabel="No"/>
</h:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)

我还在faces-config中注册了转换器,如下所示:

<converter>  
    <converter-id>booleanConverter</converter-id>  
    <converter-class>javax.faces.convert.BooleanConverter</converter-class>  
</converter>
Run Code Online (Sandbox Code Playgroud)

并试图使用它:

<h:selectOneMenu value="#{personList.criteria.registrationComplete}" >
    <f:selectItem itemValue="#{null}" itemLabel="Any.." />
    <f:selectItem itemValue="true" itemLabel="Yes"/>
    <f:selectItem itemValue="false" itemLabel="No"/>
        <f:converter converterId="booleanConverter"/>
</h:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)

但是所有这些尝试都导致了相同的行为 - 当选择空值时,它被解释为false.

我调试了它,在堆栈跟踪中我找到了它发生的位置.在AstValue.setValue(EvaluationContext, Object) line: 204

它叫

ELSupport.coerceToType(value, targetClass)
Run Code Online (Sandbox Code Playgroud)

value参数为null,targetClass为Boolean.然后,此coerceToType方法返回false.

任何想法如何解决这个问题?谢谢!

boolean el selectonemenu jsf-2

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

标签 统计

jsf-2 ×2

boolean ×1

el ×1

primefaces ×1

selectonemenu ×1