Friday, October 25, 2013

Accessing URL Params

1. Using Groovy:
URL: http://highbrow:7101/TestUrl/Faces/TestPage.jspx?pupOrderNumber=27826728&pageMode=PUP

#{param.pupOrderNumber}  -- returns its value: 27826728
#{param.pageMode}  -- returns its value: PUP

2. Programmatically:
HttpServletRequest request =(HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
String ordNum = request.getParameter("pupOrderNumber");
String pMode= request.getParameter("pageMode");

or

FacesContext fctx = FacesContext.getCurrentInstance();
ExternalContext ectx = fctx.getExternalContext();

java.util.Map params = ectx.getRequestParameterMap();
String ordNum = (String)params.get("pupOrderNumber");
String pMode = (String)params.get("pageMode");
Related Posts Plugin for WordPress, Blogger...