3

私は次の構造を持っています:

@Named    
public class SpecificAction extends BasicAction {

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

}

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

ビューより:

ファイル: 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>

BasicAction.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"
      xmlns:gui="http://java.sun.com/jsf/composite/gui">
     <gui:inplaceInput id="name" valueChangeListener="#{basicAction.calculateSomething}" value=#{bean.name} />
</html>

そして複合コンポーネント:

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

作成したものを実行すると、valueChangeListener の el が「specificAction」であれば完全に機能します。また、「basicAction」式を使用してbasicAction.xhmlで正常に動作します.複合コンポーネントだけで、私はその面白い例外を取得しました:

[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]

何かアイデアはありますか?
Seam 3 または JSF2 Framework のバグか、それとも私の側の愚かなエラーですか?

答えてくれてありがとう!!!

4

2 に答える 2

2

これは、Facelets タグにメソッド バインディングを渡そうとしたときに発生するエラーとまったく同じように見えます。

Facelets の厄介な設計エラーにより、これは機能しません (例外値のみに関係するもの)。

解決策は、Bean とメソッドの名前を別々の属性として渡すことです。次に、最終的に配列スタイルのアドレス指定を使用してそれらを結合します: bean[methodName]。

多分これはあなたの場合にも役立ちます。

アップデート:

OmniFaces と呼ばれる新しいユーティリティ ライブラリにはヘルパー タグがあり、上記の分割なしでメソッド式を使用できます。 methodParamを探します。

于 2011-09-02T08:33:15.663 に答える
1

EL式がメソッドではなくプロパティとして解決されるという同じ問題がありましたが、 Mojarra 2.1.6のアンマネージドBeanに対してのみでした( @BalusC は、マネージドBeanを使用しているため、おそらくこれに遭遇しませんでした)。

Mike が述べたように、Bean とメソッドを別々に渡すことで解決しました。

<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}"/>

使用ページ:

<name:custom value="#{bean.val}"
             valueChangeBean="#{bean}"
             valueChangeMethod="onValChange" />
于 2013-03-06T01:27:54.617 に答える