Wednesday, June 22, 2011

get Locale in JSF

public Locale getLocale()
{
FacesContext fc=FacesContext.getCurrentInstance();
UIViewRoot vr= fc.getViewRoot();
Locale lc=vr.getLocale();
return lc;

}

Tuesday, June 21, 2011

JSF validation function

public void validateName(FacesContext fc, UIComponent c, Object value) {
if ( ((String)value).contains("_") )
throw new ValidatorException(
new FacesMessage("Name cannot contain underscores"));

Tuesday, June 07, 2011

View Parameter in JSF(equalant to $_GET in PHP)

url:http://localhost:8080/Jfa/faces/profile.xhtml?user=tom  

<f:metadata>
<f:viewParam name="user" value="#{student.getx}"/>
</f:metadata>