This discussion is archived
1 Reply Latest reply: Jul 26, 2012 11:32 PM by Frank Nimphius RSS

Accessing pageFlowScope Map from javascript

user739817 Newbie
Currently Being Moderated
I have the following use case

Model Layer Method - returns a comma-separated string
Bean Method - Accesses this model layer method and assigns the comma separated string to a pageFlowScope variable (lets say #{pageFlowScope.temp})
Jsff -
<af:resource>
alert('${pageFlowScope.temp}');
</af:resource>

What I've been encountering
1) Lets say the Model layer method return "A,B,C"
2) The alert is consistent (i.e. in the alert, I get "A,B,C")
3) In the same session, the model layer method now returns "D,E,F"
4) The alert is consistent (i.e. in the alert, I get "D,E,F")
5) In the same session, the model layer method now returns "A,B,C" again
6) The alert continues to be "D,E,F"

Basically, unless the return value from model layer changes to something that has not been encountered till that point in time, the alert sticks with the latest value even though the pageFlowScope var changes behind the scene.
Looks like something to do with caching.

Also, my af:resource tag is encompassed in a container component (af:panelFormLayout) which means it shouldn't be cached

Can anyone explain this behavior and how I can always keep my javascript variable consistent with the pageFlowScope var?
  • 1. Re: Accessing pageFlowScope Map from javascript
    Frank Nimphius Employee ACE
    Currently Being Moderated
    Hi,

    always make sure yo mention the JDeveloper version. Apparently you use JDeveloper 11g R2 and JSF 2 as otherwise using EL in this form is not possible. Anyway, don't rely on people guessing.

    I am wondering why you read the JS from the page flow scope instead of using teh ExtendedRenderKitService to invoke JS on the client
    //Apache Trinidad Class
    ExtendedRenderKitService service = Service.getRenderKitService(FacesContext.getCurrentInstance(), ExtendedRenderKitService.class);
    service.addScript(FacesContext.getCurrentInstance(), "alert('hello world');");
    For more complex JS string compositions, use the StringBuffer class (which also is better to use if you want to add dynamic data read from a model)

    +"af:resource tag is encompassed in a container component (af:panelFormLayout) which means it shouldn't be cached"+

    No guarantee that this is not cached unless you partially refresh the surrounding component. Still then, your EL uses "$" which is an immediate call upon JSF compile time whereas PPR is deferred. Using the extended renderkit service is the better way of solving your coding issue

    Frank

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points