Reputation: 299
I have a form where when i click the radio button it will make ajax call to controller with the values of three textbox.
The below code works fine where an ajax call is made to the controller.
<h:selectOneRadio id="mobilePhoneId" styleClass="addradio" value="#{Controller.accountContactPageBean.mobilePhoneSelected}" onclick="onClickPreferredPhone(this)">
<f:selectItem itemValue ="Mobile" itemLabel="Preferred" />
<f:ajax render="homePhone officePhone mobilePhone" listener="#{Controller.resetPreferredLine('Mobile')}"/>
</h:selectOneRadio>
To send the values in the textbox in ajax call i included execute there after there is no call made to the controller plz help.
Here is what it looks like with execute.
<h:selectOneRadio id="mobilePhoneId" styleClass="addradio" value="#{Controller.accountContactPageBean.mobilePhoneSelected}" onclick="onClickPreferredPhone(this)">
<f:selectItem itemValue ="Mobile" itemLabel="Preferred" />
<f:ajax render="homePhone officePhone mobilePhone" execute="homePhone officePhone mobilePhone" listener="#{Controller.resetPreferredLine('Mobile')}"/>
</h:selectOneRadio>
Upvotes: 0
Views: 905
Reputation: 1033
For much complex validations it is better to validate it from controller. If the values are matched in the controller throw as shown in below.
if(true){
FacesContext facesContext = FacesContext.getCurrentInstance();
String mode = facesContext.getExternalContext().getRequestParameterMap().get("accountSaveType");
FacesMessage message = new FacesMessage();
message.setSummary("You error message");
message.setDetail("You error message");
facesContext.addMessage("your component ID", message);
return path; //same page to throw the error eg. "/home/index"
}
Upvotes: 2
Reputation: 2738
I'm not sure if your first code works, when you use the listener attribute this must point to a method with the next contract: public void MethodName(AjaxBehaviourEvent event)
but the way, maybe in the execute you have an invalid id you can also send all the values from the form in that way execute="@form" or execute="@all".
Upvotes: 0