Существует несколько способов программно установить значение атрибута представления в Oracle ADF. Вот два из них:
- Способ JSF с использованием настоятельно рекомендуемой библиотечной функции JSFUtils.java:
/**
* Method for setting a new object into a JSF managed bean
* Note: will fail silently if the supplied object does
* not match the type of the managed bean.
* @param expression EL expression
* @param newValue new value to set
*/
public static void setExpressionValue(String expression, Object newValue) {
FacesContext facesContext = getFacesContext();
Application app = facesContext.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
ValueExpression valueExp = elFactory.createValueExpression(elContext, expression, Object.class);
//Check that the input newValue can be cast to the property type
//expected by the managed bean.
//If the managed Bean expects a primitive we rely on Auto-Unboxing
Class bindClass = valueExp.getType(elContext);
if (bindClass.isPrimitive() || bindClass.isInstance(newValue)) {
valueExp.setValue(elContext, newValue);
}
}
JSFUtils.setExpressionValue("#{bindings.YOUR_VO_ATTRIBUTE.inputValue}","YOUR VALUE");
Привязав компонент jsf к вашему компоненту ADF
Перейдите в свой компонент> Открыть инспектор свойств> Установите атрибут привязки для вашего компонента (создаст следующий метод получения и установки)
public void setMyInputText(RichInputText myInputText) {
this.myInputText = myInputText;
}
public RichInputText getMyInputText() {
return myInputText;
}
//then in your action you can just set and refresh component
this.setMyInputText(YourValue);
AdfFacesContext.getCurrentInstance().addPartialTarget(this.getMyInputText);
https://gist.github.com/CedricL46/6cc291ce80601f50b66973e1000690a9