値の 1 つのオプションで何をする必要があるかに応じて、バッキング Bean の次のメソッドがあります。
public void valueChanged(ValueChangeEvent valueChangeEvent) {
this.setValueToEL("#{bindings.Deptno.inputValue}", valueChangeEvent.getNewValue()); //Updates the model
System.out.println("\n******** Selected Value: "+resolveExpression("#{bindings.Deptno.attributeValue}"));
System.out.println("\n******** Display Value: "+resolveExpression("#{bindings.Deptno.selectedValue ne ' ' ? bindings.Deptno.selectedValue.attributeValues[1] : ''}"));
}
public Object resolveExpression(String el) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
ValueExpression valueExp = expressionFactory.createValueExpression(elContext,el,Object.class);
return valueExp.getValue(elContext);
}
public void setValueToEL(String el, Object val) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
ValueExpression exp = expressionFactory.createValueExpression(elContext, el, Object.class);
exp.setValue(elContext, val);
}
JSPコンポーネントは次のようになります
<af:selectOneChoice value="#{bindings.Deptno.inputValue}" label="Select Department"
required="true" shortDesc="#{bindings.Deptno.hints.tooltip}"
id="soc1" autoSubmit="true">
<f:selectItems value="#{bindings.Deptno.items}" id="si1"/>
</af:selectOneChoice>
http://blogs.oracle.com/adf/entry/getting_selected_value_from_selectonechoiceから
これにより、表示されるテキストがリアルタイムで取得されます。コンポーネントをサポートするビュー オブジェクトへの接続をさらに探している場合は、次のようなものを見たいと思うでしょう。
public void buttonPressed(ActionEvent actionEvent) {
// Get the binding
BindingContainer bindings =
BindingContext.getCurrent().getCurrentBindingsEntry();
// Get the sepecific list binding
JUCtrlListBinding listBinding =
(JUCtrlListBinding)bindings.get("DepartmentId");
// Get the value which is currently selected
Object selectedValue = listBinding.getSelectedValue();
System.out.println(selectedValue);
}
http://blogs.oracle.com/shay/entry/getting_the_value_from_a_selecから