webtier@glassfish.java.net

Re: [webtier] JSF2 Simple Example Problem

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Tue, 07 Apr 2009 10:09:27 -0700

On 4/7/09 7:20 AM, Paulo Cesar Silva Reis wrote:

If your application contains WEB-INF/faces-config.xml, make sure the
faces-config is versioned 2.0:

<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
     version="2.0">
.
.
.

</faces-config>

> Hi,
>
> I'm trying to run the simple example of JSF2 but JSF2 is not finding
> my ManagedBean declared using @ManagedBean annotation.
>
> Follow my BackinBean:
>
> @ManagedBean(name="simple") public class SimpleBackingBean {
> private String text; @SuppressWarnings("unused")
> @PostConstruct private void init( ) {
> this.setText("initialized"); } public String getText() {
> return text; } public void setText(String text) {
> this.text = text; } }
>
> Follow my xhtml example:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
> <http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%22>> <html
> xmlns="http://www.w3.org/1999/xhtml"
> xmlns:h="http://java.sun.com/jsf/html"
> xmlns:f="http://java.sun.com/jsf/core"
> xmlns:composite="http://java.sun.com/jsf/composite"
> xmlns:ez="http://java.sun.com/jsf/composite/simpleout"
> xmlns:ui="http://java.sun.com/jsf/facelets"> <f:view
> contentType="text/html" /> <h:head> <meta http-equiv="Content-Type"
> content="text/html; /> <title>Simple Backing Bean</title> </h:head>
> <h:body> <h:outputText value="#{simple.text}" /><br/> <h:form
> prependId="false"> <h:inputText id="text" name="text"
> value="#{simple.text}"/> <h:commandButton id="submitText"
> value="submit"/> </h:form> </h:body> </html>
>
> I am using glassfishv3 and Mojarra 2.0.0 (PR2 09).
>
> The printed value on outputText is blank and after pressing the Submit
> I get an error:
>
> javax.servlet.ServletException: /simple.xhtml @16,62
> value="#{simple.text}": Target Unreachable, identifier 'simple'
> resolved to null
> r*oot cause
> *
> javax.el.PropertyNotFoundException: /simple.xhtml @16,62
> value="#{simple.text}": Target Unreachable, identifier 'simple'
> resolved to null
>
> What's wrong?
>
> Thanks in advance.