开发者

Problem with evaluating El expressionin combination with seam 3 and JSF2 composite component valueChangeListener

i have following construct:

@Named    
public class SpecificAction extends BasicAction {

    public void calulateSomething(ValueChangeEvent event) {...}
}

}

@Named
public abstract class BasicAction {
     public void calculateSomething(ValueChangeEvent event) {...}
}

Than the views:

File: SpecificAction.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:cc="http://java.sun.com/jsf/composite/cc"
      xml:lang="de" lang="de">
    <ui:composition template="/BasicAction.xhtml">
        <ui:param name="basicAction" value="#{specificAction}" />
....
</ui:composition>

The BasicAction.xhtml contains my Composite Component:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:cc="http://java.sun.com/jsf/composite/cc"
      xmlns:gui="http://java.sun.com/jsf/composite/gui">
     <gui:inplaceInput id="name" valueChangeListener="#{basicAction.calculateSomething}" value=#{bean.name} />
</html>

And the composite component:

<composite:interface>
    <composite:attribute name="value" />
    <composite:editableValueHolder name="Value"/>
    <composite:attribute name="valueChangeListener" targets="Value" />
</composite:interface>
&开发者_StackOverflow中文版lt;composite:implementation>
      <h:inputText id="Value" value="#{cc.attrs.value}" onblur="handleBlur(this.id);" >
          <composite:insertChildren />
      </h:inputText>
</composite:implementation>

If i run my creation it works perfectly if the el of the valueChangeListener is "specificAction". Also it works fine in the basicAction.xhml with the "basicAction" expression, just with the composite component i got that funny Exception:

[ExceptionHandlerFactory] Handling exception javax.faces.event.AbortProcessingException: javax.faces.event.AbortProcessingException: /BasicAction.xhtml @XX,XX valueChangeListener="#{basicAction.calculateSomething}": The class 'SpecificAction' does not have the property 'calculateSomething'.
    at javax.faces.event.MethodExpressionValueChangeListener.processValueChange(MethodExpressionValueChangeListener.java:157) [:2.1.3-FCS]
    at javax.faces.event.ValueChangeEvent.processListener(ValueChangeEvent.java:134) [:2.1.3-FCS]
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769) [:2.1.3-FCS]

Any Idea, what the hack could that be?.

Bug in Seam 3 or in JSF2 Framework or some stubid error on my side?

Thanks for answers!!!


This looks exactly like the kind of error you get when trying to pass a method binding into a Facelets tag.

Due to some awkward design error in Facelets, this never works (something to do with only excepting values).

The solution there is to pass the bean and name of the method as separate attributes. Then combine them eventually using array-style addressing: bean[methodName].

Maybe this also helps in your case.

Update:

A new utility library called OmniFaces has a helper tag that let's you use a method expression without the above mentioned breaking up, look for methodParam.


I had the same issue with the EL expression resolving as a property instead of a method, but only for unmanaged beans on Mojarra 2.1.6 ( @BalusC probably didn't encounter this due to using a managed bean ).

Resolved by passing the bean and method separately as mentioned by Mike:

<composite:attribute name="valueChangeBean" required="true" />
<composite:attribute name="valueChangeMethod" required="true" />
...
<composite:implementation>
    <h:selectBooleanCheckbox
      valueChangeListener="#{cc.attrs.valueChangeBean[cc.attrs.valueChangeMethod]}"
      value="#{cc.attrs.isValue}"/>

Using page:

<name:custom value="#{bean.val}"
             valueChangeBean="#{bean}"
             valueChangeMethod="onValChange" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜