Wednesday, October 28, 2009

Read Variable From PageDef

In your page definition you can define a variable and set a value to it and you can read this variable and retrieve its value from backingbean as :

1- goto your page definition and in the executables section right click in the variables then choose insert inside the variables ----> variable.
2- set the name as "sameh" and the type to "String" then Ok.
3- set a default value to this variable with "Great Man".
4- in your backingbean write this :

FacesContext facesContext = FacesContext.getCurrentInstance();
Application app = facesContext.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
ValueExpression valueExp = elFactory.createValueExpression(elContext, "#{bindings.sameh}", Object.class);
Object varValue = valueExp.getValue(elContext);
// varValue will be Great Man

No comments:

Post a Comment