Hi Mike

> HttpServletRequest request =
>     
> (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
>
> String someParameterValue = 
> request.getParameter(Constants.SOME_PARAMETER_KEY);
>
> I have a feeling that this is not the best way.  Is there some methodology in 
> JSF that allows me
> to hide the HttpServletRequest?  Any suggestions?

yes! Faces provides a Map for HTTP parameters. Call this:

Map params = 
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();

params.get(Constants.SOME_PARAMETER_KEY);

so you are not tied to Servlet API inside of your backing beans.


Copy and paste from getRequestParameterMap()'s JavaDoc:

<snip>
Servlet: This must be the set of parameters available via the
javax.servlet.ServletRequest methods getParameter() and
getParameterNames().

Portlet: This must be the set of parameters available via the
javax.portlet.PortletRequest methods getParameter() and
getParameterNames().
</snip>

HTH,
Matthias

Reply via email to