値の式は、パブリックgetter/setterメソッドによって公開されるプロパティにバインドされています。
<h:inputText value="#{bean.value}" />
これはpublic T getValue()
とpublic void setValue(T value)
方法が必要です。文字通り全く同じ名前のprivate T value;
プロパティの存在がではなく、であることに注意してください。 <h:outputText>
,<h:dataTable>
,<f:selectItems>
などの純粋な出力コンポーネントでは、セッターメソッドもではなく、必須です。
メソッド式は、非ゲッター/セッターメソッド(「アクション」メソッド)にバインドされています。
<h:commandButton value="submit" action="#{bean.submit}" />
これはT
は、最終的にvoid
することができ、この方法は、最終的には、属性のメソッド式の署名に応じて、追加の引数を取ることができpublic T submit()
方法が必要です。 view declaration language documentationの正確な詳細は、たとえば<h:inputText>
、<h:commandButton>
、<f:ajax>
のようになります。ここ<h:commandButton>
のaction
とactionListener
属性定義のエキスです:
Name: action
Type: javax.el.MethodExpression (signature must match java.lang.Object
action())
Description: MethodExpression representing the application action to invoke when
this component is activated by the user. The expression must
evaluate to a public method that takes no parameters, and returns an
Object (the toString() of which is called to derive the logical
outcome) which is passed to the NavigationHandler for this
application.
Name: actionListener
Type: javax.el.MethodExpression (signature must match void
actionListener(javax.faces.event.ActionEvent))
Description: MethodExpression representing an action listener method that will be
notified when this component is activated by the user. The
expression must evaluate to a public method that takes an
ActionEvent parameter, with a return type of void, or to a public
method that takes no arguments with a return type of void. In the
latter case, the method has no way of easily knowing where the event
came from, but this can be useful in cases where a notification is
needed that "some action happened".
はい、私はスペックはすべてサポート値式を属性と述べるにややずさんであることに同意します。一般に、実際には、すべての属性が#{}
のように式言語をサポートしていることを意味します。一方、メソッド式は、ちょうど「特別な」値式であるかのように解釈することもできますが、正確にはそうではありません。私はいくつかの混乱を解決する要求でこれに関する仕様書の問題報告を投稿しました:issue 1036。
値式の代わりにメソッド式を割り当てることはできますか?私。 ' ' –
@ St.Antario:http://stackoverflow.com/search?q=javax.el.propertynotwritableexception+h%3Ainputtext – BalusC
だから、意味がないので、短い答えはいいえ.... –