In JSF 2.0, a new @ManagedProperty annotation is used to dependency injection (DI) a managed bean into the property of another managed bean. Let see a @ManagedProperty example : MessageBean.java – A managed bean named “message“. import java.io.Serializable; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; @ManagedBean(name="message") @SessionScoped public class MessageBean implements Serializable { //business logic and whatever methods… […]

Read more Injecting Managed beans in JSF 2.0

Problem In JSF 2.0, while using the @ManagedProperty annotation to DI the bean into the field of another bean, HelloBean.java @ManagedBean @SessionScoped public class HelloBean implements Serializable { @ManagedProperty(value="#{message}") private MessageBean messageBean; MessageBean.java @ManagedBean(name="message") @SessionScoped public class MessageBean implements Serializable { It hits the following error message. An Error Occurred: Unable to create managed bean […]

Read more JSF 2.0 : managed bean x does not exist, Check that appropriate getter and/or setter methods exist

Problem In JSF, the faces-config.xml file can used to includes manages beans, navigation rules or any JSF faces configurations. But, putting all the configurations into a single faces-config.xml file will cause this file become huge very fast, and causing a serious maintainability issue. Solution Actually, you can split the faces-config.xml into multiple smaller files, each […]

Read more How to split faces-config.xml into multiple files?

Problem A JSF’s button with Ajax support… <h:outputText id="output" value="#{helloBean.sayWelcome}" /> <h:form> <h:inputText id="name" value="#{helloBean.name}"></h:inputText> <h:commandButton value="Welcome Me"> <f:ajax execute="name" render="output" /> </h:commandButton> </h:form> When this page is displayed, it prompts the following error message javax.faces.FacesException: <f:ajax> contains an unknown id ‘output’ – cannot locate it in the context of the component j_idt8 Obviously, the […]

Read more JSF 2.0 : <f:ajax> contains an unknown id

Problem While deploying JSF 2.0 web application to Tomcat 6.0.26, hits the “JSP version of the container is older than 2.1” exception and failed to start the Tomcat server. But the JSP api v2.1 is included in the project class path, why the Tomcat is still saying that JSP version is older than 2.1? <dependency> […]

Read more JSF 2.0 + Tomcat : It appears the JSP version of the container is older than 2.1…

Problem While deploying JSF 2.0 web application to Tomcat 6.0.26, hits following jstl class not found error. java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config … Caused by: java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config … 18 more Solution By default, Tomcat container doesn’t contain any jstl library. To fix it, declares jstl.jar in your Maven pom.xml file. <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> Note Please refer […]

Read more java.lang.ClassNotFoundException : javax.servlet.jsp.jstl.core.Config

Problem In Eclipse IDE, while deploying a JSF 2.0 web application to Tomcat 6.0.26, hits the following exception and failed to start the Tomcat server. P.S Both jsf-api-2.1.0-b03.jar and jsf-impl-2.1.0-b03.jar libraries are included in the project classpath. INFO: Unsanitized stacktrace from failed start… java.lang.IllegalArgumentException: javax.faces.context.ExceptionHandlerFactory at javax.faces.FactoryFinder.validateFactoryName(FactoryFinder.java:630) at javax.faces.FactoryFinder.setFactory(FactoryFinder.java:287) … SEVERE: Critical error during deployment: […]

Read more java.lang.IllegalArgumentException: javax.faces.context.ExceptionHandlerFactory