onmouseover等属性的JSF条件格式
我正试图根据支持bean中的值格式化panelgrid 我目前正在尝试将其作为onmouseover属性的值:onmouseover等属性的JSF条件格式,jsf,Jsf,我正试图根据支持bean中的值格式化panelgrid 我目前正在尝试将其作为onmouseover属性的值: this.className=#{(actions.currentlySelectedActionButton == 0)?'actionButton actionButtonChosen':'actionButton'}; 而CSS看起来是这样的:(相关部分): 它不起作用了。 任何发现错误的人都会帮我大忙。 谢谢 编辑1 查看HTML源代码,我似乎找不到元素上列出的属性。 我将属
this.className=#{(actions.currentlySelectedActionButton == 0)?'actionButton actionButtonChosen':'actionButton'};
而CSS看起来是这样的:(相关部分):
它不起作用了。
任何发现错误的人都会帮我大忙。
谢谢
编辑1
查看HTML源代码,我似乎找不到元素上列出的属性。
我将属性指定为来自支持bean的ValueExpression
有效的“非值表达式”语法是:
button.setOnmouseout("this.className='actionButton'");
看起来根本不是属性的值表达式语法:
ExpressionFactory ef = FacesContext
.getCurrentInstance().getApplication().getExpressionFactory();
String veString = "(#{actions.currentlySelectedActionButton} = '0')?'actionButton actionButtonChosen':'actionButton'}";
ValueExpression ve = ef.createValueExpression(FacesContext
.getCurrentInstance().getELContext(), veString, String.class);
button.setValueExpression("onmouseover", ve);
再次感谢。看起来像JavaScript。因此,您基本上是使用JSF/EL生成JavaScript代码。您需要验证结果是否正确(即,它在语法上有效且可运行)。只需在您喜爱的webbrowser中打开JSF页面,右键单击它并选择View Source并验证它是否正确。你看到了什么?在生成的输出中,逻辑上应该没有Java/JSF/EL代码。好的。这是我在google chrome开发者屏幕上发现的一个语法问题
"..sen':'actionButton'}" //<--- Redundant '}'
"ctionButton} = '0'" //<-- '=' should be '=='
“.sen”:“actionButton}”//Tnx。有趣的是,在你的第一个问题中,你输入了完全有效的代码,但是你编辑并复制了实际的代码片段,它在语法上确实是无效的!表达式应该与您在视图中输入的表达式完全相同。首先在视图中玩游戏,然后复制粘贴到Java代码可能会更容易。
"..sen':'actionButton'}" //<--- Redundant '}'
"ctionButton} = '0'" //<-- '=' should be '=='