0

簡単なシナリオがあります。この例は PrimeFaces からのものですが、同様の方法で使用するすべてのタグに適用されると思います。

<p:autoComplete value="#{address.country}" id="#{layoutId}_country" 
    completeMethod="#{addressBean.completeCountry}" var="country"
    itemLabel="#{country.name}" itemValue="#{country}"
    converter="#{countryConverter}">
</p:autoComplete>

Bean のメソッド (例: addressBean.completeCounty) で、AutoComplete オブジェクトにアクセスできます。私が取得したいのは、値自体ではなく、その値 (#{address.country}) の参照です。

それはどこに縛られているのですか?

4

1 に答える 1

2

私が取得したいのは、値自体ではなく、その値 (#{address.country}) の参照です。

#{address.country}この質問は少しあいまいですが (言語の壁の可能性があります)、私があなたを正しく理解していれば、何らかの理由で式文字列として取得したいと考えています。までに入手できUIComponent#getValueExpression()ますValueExpression#getExpressionString()

public List<Country> completeCountry(String query) {
    UIComponent component = UIComponent.getCurrentComponent(FacesContext.getCurrentInstance());
    String valueEL = component.getValueExpression("value").getExpressionString();
    // ...
}
于 2012-12-14T14:24:42.060 に答える