Can someone tell me how to catch the parameters passed from the URI in a JSF managed bean? I have a navigation menu, all nodes of which are connected to some kind of navigation building. And I have two similar subjects: product acquisition and product release. They have the same page, but one other parameter: productType. I am trying to install it by simply adding it to the url in the to-view-id element as follows:
<navigation-case> <from-outcome>acquiring|products</from-outcome> <to-view-id>/pages/products/list_products.jspx?productType=acquiring</to-view-id> </navigation-case> <navigation-case> <from-outcome>issuing|products</from-outcome> <to-view-id>/pages/products/list_products.jspx?productType=issuing</to-view-id> </navigation-case>
But I cannot get this "productType" from my managed bean. I tried to get it through FacesContext as follows:
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("productType")
And like this:
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); request.getParameter("productType");
And I tried to include it as a managed bean parameter in faces-config.xml, and then get it through a regular setter:
<managed-bean> <managed-bean-name>MbProducts</managed-bean-name> <managed-bean-class>my.package.product.MbProducts</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> <managed-property> <property-name>productType</property-name> <value>#{param.productType}</value> </managed-property> </managed-bean> ... public class MbProducts { ... public void setProductType(String productType) { this.productType = productType; } ... }
But none of these methods helped me. They all returned null. How can I get this productType? Or how can I transfer it in another way?
source share