Sometimes when you need to make redirect from current page to another page and pass some GET parameters you can find this solution.
FacesContext faces = FacesContext.getCurrentInstance();
ExternalContext context = faces.getExternalContext();
String url = getSomeURLWithParameters();
try {
context.redirect(url);
} catch (IOException e) {
e.printStackTrace();
}
But it is not safe since it can lead to the security issues.
To avoid it we need following. First create Java class
With following code
Then add bounded task flow or modify existent one
Here we will manage navigation from page1 to the page with name another which is defined in the unbounded task flow. Add managed bean to the task flow
Go back to Design view and set following properties for anotherPage
As you can see here we are passing urlParameter1 with value #{pageFlowScope.parameter1}.
Thats it.
FacesContext faces = FacesContext.getCurrentInstance();
ExternalContext context = faces.getExternalContext();
String url = getSomeURLWithParameters();
try {
context.redirect(url);
} catch (IOException e) {
e.printStackTrace();
}
But it is not safe since it can lead to the security issues.
To avoid it we need following. First create Java class
With following code
Then add bounded task flow or modify existent one
Here we will manage navigation from page1 to the page with name another which is defined in the unbounded task flow. Add managed bean to the task flow
Go back to Design view and set following properties for anotherPage
As you can see here we are passing urlParameter1 with value #{pageFlowScope.parameter1}.
Thats it.





No comments:
Post a Comment