如何在jsf 2.0 outputText中访问DualTreeBidiMap键/值

时间:2012-06-07 10:35:07

标签: jsf-2

我在WebSphere Application Server 8上使用Apache MyFaces 2.0.2。

如何在JSF 2.0中获取DualTreeBidiMap的密钥?

DualTreeBidiMap提供getKey(对象值)或get(对象键)方法。

我在另一个ManagedBean中有Value,所以我想用EL打印出这个值的Key。

我尝试过这样的事情:

<h:outputText value="#{bean1.dualTreeBidiMap.key(bean2.value)}"  />

但这不起作用。

1 个答案:

答案 0 :(得分:0)

由于您的value属性是方法表达式而不是值表达式,因此正确的语法应为:

<h:outputText value="#{bean1.dualTreeBidiMap.getKey(bean2.value)}"  />

只需要为值表达式省略get前缀(对于带有无参数getter的字段)。

请注意,只有EL 2.2才能调用带参数的方法。我没有使用WAS 8,但谷歌的快速搜索显示它应该支持EL 2.2。