I am a bit of a newbie to primefaces and here is a problem I am trying to solve. I have a simple input component that I'm trying to Ajaxify using p:ajax and below is my UI
Code: Select all
<h:form id="simpleForm">
Enter your name and Tab out <h:inputText id="nameInput" value="#{Person.firstName}" required="true" valueChangeListener="#{Person.validatePassword}">
<p:ajax process="nameInput" event="blur" update="msgs" />
</h:inputText>
<p:message for="nameInput" id="msgs" showDetail="true"/>
</h:form>
<p:message> to <p:messages>
Code: Select all
<h:form id="simpleForm">
Enter your name and Tab out <h:inputText id="nameInput" value="#{Person.firstName}" required="true" valueChangeListener="#{Person.validatePassword}">
<p:ajax process="nameInput" event="blur" update="msgs" />
</h:inputText>
<p:messages id="msgs" showDetail="true"/>
</h:form>
Code: Select all
@ManagedBean(name="Person")
@RequestScoped
public class Person {
private String firstName;
/** Creates a new instance of Person */
public Person() {
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public void validatePassword(ValueChangeEvent evt)
{
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,this.firstName + " is valid", "Hello "+firstName));
}
}
And the error message is :
SEVERE: Error Rendering View[/person.xhtml]
java.lang.NullPointerException
at org.primefaces.component.message.MessageRenderer.encodeEnd(MessageRenderer.java:65)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1617)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1610)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:379)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1522)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
Dev Env:
Java 6, Primefaces 2.0 in Glassfish 6.8:
I have a feeling that I'm doing a very rookie mistake and hence I'm knocking your doors.Please can some one clarify.
Best Regards,
Goutham