Reputation:
I need to send hostPage
parameter value to my bean loginDialog()
method.
<h:commandButton id="loginbtn" value="Sign in" action="#{userBean.loginDialog()}" class="btn-myForm" >
<f:param name="hostPage" value="Books"/>
<p:ajax process="@form" update="@form"/>
</h:commandButton>
But I got this error:
java.lang.ClassCastException: java.lang.String cannot be cast to org.primefaces.component.api.ClientBehaviorRenderingMode
When I remove <f:param>
or <p:ajax>
, I have no error. How is this caused and how can I solve it?
Upvotes: 1
Views: 1429
Reputation: 66
It looks like org.primefaces.behavior.ajax.AjaxBehaviorRenderer might have had/has a defect which causes the exception that you saw.. Regardless, there are several other ways that you can achieve what you need to accomplish. Here's one approach that closely reflects the wording of your question (works since JSF 2.0):
<h:commandButton id="loginbtn" value="Sign in" action="#{userBean.loginDialog(Books)}" class="btn-myForm" >
<f:ajax execute="@form" render="@form" />
</h:commandButton>
And in your Managed Bean:
public String loginDialog(String pageName) {
String nextPage = pageName;
}
But like I said, this is just one approach. You can find tons of documentation online about passing parameters in JSF.
Upvotes: 0
Reputation: 2476
i have no idea of primefaces, but i would suggest the following:
if you want to send form Data with AJAX, then:
<h:commandButton value="Sign in">
<f:param name="hostPage" value="Books"/>
<f:ajax execute="@form" render="@form" listener="#{userBean.loginDialog}" ></f:ajax>
</h:commandButton>
in your bean:
public final void loginDialog(AjaxBehaviorEvent event) {
String param = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("hostPage");
}
OR (EL 2.2)
<h:commandButton value="Sign in">
<f:ajax execute="@form" render="@form" listener="#{userBean.loginDialog('Books')}" ></f:ajax>
</h:commandButton>
in your bean:
public final void loginDialog(String param) {
}
Upvotes: 1