1.Let the life cycle proceed normally.
2.Call FacesContext.renderResponse() to skip the rest of the life cycle up to Render Response.
3.Call FacesContext.responseComplete() to skip the rest of the life cycle entirely.
See "Immediate Components" on page 287 for an example of using FacesContext.renderResponse().
private static final String US = "United States";
public void countryChanged(ValueChangeEvent event) {
FacesContext context = FacesContext.getCurrentInstance();
if (US.equals((String) event.getNewValue()))
context.getViewRoot().setLocale(Locale.US);
else
context.getViewRoot().setLocale(Locale.CANADA);
context.renderResponse();
}
The call to renderResponse() skips the rest of the life cycle—including validation of the rest of the input components in the form—up to Render Response. Thus, the other validations are skipped and the response is rendered normally (in this case, the current page is redisplayed).
To summarize, you can skip validation when a value change event fires by doing the following:
-
Adding an immediate attribute to your input tag
-
Calling FacesContext.renderResponse() at the end of your listener
上文引用:《core JavaServer™ Faces, Second Edition》
posted on 2007-12-11 19:57
*一凡* 阅读(150)
评论(0) 编辑 收藏 所属分类:
JSF