When I click on a command button of <h:form>
tag in the mentioned below page, I expect that query parameters are sent as request parameters once I hit the submit button, as my page URL is ../index.xhtml?cid=12&ctype=video
.
I expected that in my action method it should be printed CID=12
, however, it printed CID=NULL
. What is the problem and how can I solve it?
My view:
<h:body id="body">
<h:form id="form">
<p:commandButton action="#{authorizationBean.getParameters()}" value="Ajax Submit" id="ajax" />
</h:form>
</h:body>
My managed bean:
@ManagedBean
@SessionScoped
public class AuthorizationBean {
public boolean getParameters(){
Map<String, String> parameterMap = (Map<String, String>) FacesContext.getCurrentInstance()
.getExternalContext().getRequestParameterMap();
String cid = parameterMap.get("cid");
System.out.println("CID="+cid);
return true;
}
}