小编Sam*_*uel的帖子

评估是否设置了MethodExpression属性(获取PropertyNotFoundException)

我有一个带有MethodExpression属性的UI组件changeListener:

<composite:interface>
  <composite:attribute name="changeListener" required="false" method-signature="void actionListener(javax.faces.event.ActionEvent)" />
  ..
</composite:interface>
<composite:implementation>

  <p:remoteCommand name="ajaxOnChange"
                             update="#{cc.attrs.onChangeUpdate}"
                             oncomplete="#{cc.attrs.onchange}"
                             actionListener="#{cc.attrs.changeListener}" />
  ..
</composite:implementation>
Run Code Online (Sandbox Code Playgroud)

changeListener属性是一个可选的方法表达式,在其中用作actionListenerremoteCommand,我想在<p:remoteCommand>changeListener设置属性的情况下呈现该属性.

我已经尝试了几种方法来检查属性是否设置,尤其是:

<c:if test="#{! empty cc.attrs.changeListener}">
Run Code Online (Sandbox Code Playgroud)

<p:remoteCommand rendered="#{cc.attrs.changeListener != null}" />
Run Code Online (Sandbox Code Playgroud)

但我得到一个javax.el.PropertyNotFoundException,因为它试图将属性评估为属性.

如何评估是否设置了可选方法属性?

谢谢

jsf conditional composite-component jsf-2 methodexpression

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