3

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>
<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!!!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
javaBeCool
  • 276
  • 3
  • 13
  • I cannot reproduce your problem on Mojarra 2.1.2. What JSF impl/version are you using? It might have been fixed in a newer version. Only note that I didn't use CDI annotations, just JSF annotations, but that shouldn't make any difference. – BalusC Sep 02 '11 at 12:37
  • Hey BalusC, thanks for testing, i tried it with Mojarra 2.1.3-FCS (beta 3) and the problem still exits. I will try it under other circumstances without seam 3. I can't temporarily label the concret EL-Validation InterfaceImpl, it could be JSF, im still using CDI, but not in this contect. Another question is, did or could you try it with a view-scoped bean (Basic- and SpecificAction)? Thanks a lot! – javaBeCool Sep 02 '11 at 16:55
  • I did use a view scoped bean, but the scope shouldn't matter. It's an EL error. I tested on Tomcat 7 (Servlet 3.0 / EL 2.2). By the way, I'm not sure if it's allowed in CDI, but `@Named` on an abstract class makes no sense to me as it's not constructable anyway. – BalusC Sep 02 '11 at 17:04
  • I used it just for code complition on jboss-xhtml editor, it wound be recognized on java. P.s. Thanks! Okay, i tried it btw. i have to use an hacked jboss 6. I know that's not the perfect environment. – javaBeCool Sep 02 '11 at 17:05

2 Answers2

2

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.

Mike Braun
  • 3,729
  • 17
  • 15
  • Thanks for the suggestion, i will try this on my given system and if it is a managable solution i will post my workaround. – javaBeCool Sep 02 '11 at 16:58
  • Okay, I'm curious what the eventual solution is. The error you're getting is absolutely caused by the EL expression being interpreted as a *value expression* while it should be interpreted as a *method expression*, – Mike Braun Sep 02 '11 at 18:50
1

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" />
ENG_ACK
  • 108
  • 2
  • 7