Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get parameters from the URL in JSF properly? [duplicate]

Tags:

jsf

I believe there are 2 ways to get the parameters from the URL in JSF.

One being in the bean:

Map<String, String> params =FacesContext.getCurrentInstance().
                   getExternalContext().getRequestParameterMap();
String parameterOne = params.get("parameterOne");

and the other one being in the facelets page

<f:metadata>
    <f:viewParam name="parameterOne" value="#{bean.parameterOne}"/>
</f:metadata>

Obviously the latter one will require a field in the class and getter / setter for it.

Besides that, what are the differences between these 2 different approaches? Which one should be preferred?

like image 904
Koray Tugay Avatar asked Jul 26 '13 19:07

Koray Tugay


1 Answers

I think this may help: Get Request and Session Parameters and Attributes from JSF pages

In fact, there should be a query:

<h:outputText value="#{param['id']}" />
like image 160
Christian Kuetbach Avatar answered Nov 09 '22 19:11

Christian Kuetbach