Request Scope
I request page foo.xhtml?myArg=1 (with GET method)...Then in foo.xhtml or its binding bean (FooBean.java) I can access myArg from request scope.
Flash Scope
When you want a variable to persist after a post-back use flash.
Example: foo.xhtml has inputText with id myInputText...I hit commandButton and action/actionListener submitData() is executed...I return to foo.xhtml and want the updated value of myInputText...then in submitData() you should save myInputText value in flash
TODO: to elaborate more with examples...
Request vs Flash Scopes
From web page:
From backing bean:
How to read from / write to Flash Scope
From web page:
From backing bean:
I request page foo.xhtml?myArg=1 (with GET method)...Then in foo.xhtml or its binding bean (FooBean.java) I can access myArg from request scope.
Flash Scope
When you want a variable to persist after a post-back use flash.
Example: foo.xhtml has inputText with id myInputText...I hit commandButton and action/actionListener submitData() is executed...I return to foo.xhtml and want the updated value of myInputText...then in submitData() you should save myInputText value in flash
TODO: to elaborate more with examples...
Request vs Flash Scopes
- In request scope you can access everything included in a HTTP GET request for a new page
- In flash scope you can access
- same as request scope (i.e. everything in request after a HTTP GET request)
- everything in request after a JSF postback (HTTP POST request)
- everything in request after a redirect
From web page:
#{request.id}
From backing bean:
MaprequestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap(); requestMap.get("id"); requestMap.put("id",1);
How to read from / write to Flash Scope
From web page:
#{flash.id}
[but makes no sense]
From backing bean:
Flash flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
flash.get("id");
flash.put("id",1);
No comments:
Post a Comment