JSF code.
<ice:inputText id="txtemailFrom" required="true"
requiredMessage="please enter proper value in From Address field" value="#{emailBean1.sender}" maxlength="100" size="40">
<f:validator validatorId="emailValidator" />
</ice:inputText>
<ice:selectOneRadio id="emailType"
value="#{emailBean1.currentEmailType}"
valueChangeListener="#{emailBean1.onEmailTypeChange}"
partialSubmit="true"
style="margin-left:95px">
<f:selectItem itemLabel="Do Not Reply" />
<f:selectItem itemLabel="User's Email" />
<f:selectItem itemLabel="Custom Email" />
</ice:selectOneRadio>
java code for validator:
public void onEmailTypeChange(ValueChangeEvent event) {
logger.debug(new LogEntry(" EmailBean.onEmailTypeChange() execution is started."));
String emailType = event.getNewValue().toString();
FacesContext context = FacesContext.getCurrentInstance();
this.setUserEmailId(roleHandler.getUserId() + "@xxx.com");
HtmlInputText txtComponent = (HtmlInputText) Utils.findComponent(
context.getViewRoot(), "txtemailFrom");
if (emailType.equals("Do Not Reply")) {
this.setEmailFrom("[email protected]");
txtComponent.setValue("[email protected]");
} else if (emailType.equals("User's Email")) {
this.setEmailFrom(this.getUserEmailId());
txtComponent.setValue(this.getUserEmailId());
} else if(emailType.equals("Custom Email")){
this.setEmailFrom("");
txtComponent.setValue("");
}
logger.debug(new LogEntry(
" EmailBean.onEmailTypeChange() execution is ended."));
}
when i am changing the radio button values it is updating the value in inputTextField of fromEmailaddress. i am updating value via java by using this code.
HtmlInputText txtComponent = (HtmlInputText) Utils.findComponent(
context.getViewRoot(), "txtemailFrom");
but my issue is like i am using validator for the inputtext field when i change the radio button and if the email in invalid then its failing and showing error message.. it works as per jsf approach but as per my requirement it should change the value in email inputTextFied.. i tried immediate="true" then its skipping validation phase but its not updating the values into the Emailtextfield.