Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
//There is multiple way to programmatically set a value of a view attribute in Oracle ADF :
// 1. The JSF way using the highly recommended library function :
* 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");
// 2. By binding the jsf component to your ADF Bean
//Go To your component > Open property inspector > Set Binding Attribute to your Bean (will create the following getter and setter)
public void setMyInputText(RichInputText myInputText) {
this.myInputText = myInputText;
public RichInputText getMyInputText() {
return myInputText;
//then in your action you can just set and refresh component
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.