简体   繁体   中英

change label value using value stored at session

i have two jsf pages (home.jsf and employees.jsf) , home page has a button that navigates to employees page, while navigating i store value in session scope at (Managed bean)

    public void putSessionAL(ActionEvent actionEvent) {
    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("key","value");
}

public String navigate() {
    return "employees";
}

i want to change Label at employees viewObject from UIHints tab depending on value stored at session using the following groovy expression

adf.context.sessionScope.key

and changed trustMode to trusted but it fires the following exception

oracle.jbo.script.ExprScriptException: JBO-29114 ADFContext is not setup to process messages for this exception. Use the exception stack trace and error code to investigate the root cause of this exception. Root cause error code is JBO-25188. Error message parameters are {0=Employees.FirstName, 1=, 2=oracle.jbo.script.ExprSecurityException}
at oracle.jbo.script.ExprScriptException.throwException(ExprScriptException.java:316)
at oracle.jbo.script.ExprScriptException.throwExceptionWithExprDef(ExprScriptException.java:387)
at oracle.jbo.ExprEval.processScriptException(ExprEval.java:599)
at oracle.jbo.ExprEval.doEvaluate(ExprEval.java:697)
at oracle.jbo.ExprEval.evaluate(ExprEval.java:508)
at oracle.jbo.ExprEval.evaluate(ExprEval.java:487)
at oracle.jbo.common.NamedObjectImpl.resolvePropertyRaw(NamedObjectImpl.java:680)
at oracle.jbo.server.DefObject.resolvePropertyRaw(DefObject.java:366)

One way to do it at the VO UIHint attribute label level will be programmaticaly by doing as follow :

  • In your VO go to the java tab and add the RowImpl java class
  • In the VORowImpl Add the following function

    public String getMySessionLabel() { return (String)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("key"); }
  • In the Label add the following EL expression :

     adf.object.getMySessionLabel()

This technique allow you more control than pure EL, if you want to do more than getting from session for example. In your case pure EL, as you did, should work as well. (Would need to check what is wrong with yours, maybe just missing the

        #{adf.context.sessionScope.key}

If you attempt to get your label from a method in viewRowImpl. So this will be executed at least once for each row. I think this solution isn't fit for your case.

anyway ADF as a framework added strong policy and validations in EL in general and especially in version 12.2.x.

The solution for you case as following:

  1. Create new class in model layer which extends oracle.jbo.script.ExprSecurityPolicy class
  2. Override checkProperty method.

     @Override public boolean checkProperty(Object object, String string, Boolean b) { if (object.getClass().getName().equals("oracle.adf.share.http.ServletADFContext") && string.equals("sessionScope")) { return true; } return super.checkProperty(object, string, b); }
  3. Open adf-config.xml source and in startup tag set your class ExprSecurityPolicy property.

like:

<startup ExprSecurityPolicy="model.CustomExprSecurityPolicy">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM