Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing parameters to next view from Action method

Tags:

jsf-2

I am looking out for different alternatives of passing parameter from an action method in JSF Managed bean to next view.

For example, I have an action method in my managed bean.

public String actionMethod01(){
    String outcome = "nextPage";
    return outcome;
}

If I want to pass a parameter to nextPage, one option which I have is:

outcome += "?param1=value1";

But, its not so convinient if I have multiple parameters to be passed.

Is there a better way for doing it?

Best regards, Anand.

like image 676
Anand Shankar Avatar asked Feb 24 '26 23:02

Anand Shankar


1 Answers

There's nothing in the JSF API which makes this easier. Just create a helper/utility method yourself which makes it more convenient so that you can end up with something like this:

return "nextPage" + toQueryString("param1", "value1", "param2", "value2");
like image 92
BalusC Avatar answered Mar 02 '26 15:03

BalusC