Outjection ignored - very basic example not running
nschweig.nicole.schweighardt.t-online.de Sep 11, 2008 8:34 PMHello,
I am new to Seam and tried to run a very simple example but it does not work. After searching in google and in forums too many hours I hope anybody here can help me.
I use JBoss AS 4.2.2GA, Seam 2.0.2. I work with Eclipse with JBoss Tools.
I created a New Seam Webproject
, an example project from Jboss Tools. That works fine and the example is running.
Then I only wanted to test outjecting an variable from a session bean. But that does not work. I tried 3 versions:
1. Version
This is my basicBean
import javax.ejb.Remove; import javax.ejb.Stateful; import org.jboss.seam.annotations.Destroy; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Logger; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Out; import org.jboss.seam.faces.FacesMessages; import org.jboss.seam.log.Log; @Stateful @Name("basicBean") public class BasicBean implements BasicBeanLocal { @Logger private Log log; @In FacesMessages facesMessages; public void basicBean() { //implement your business logic here log.info("basicBean.basicBean() action called"); facesMessages.add("basicBean"); } @Out public String foo = "That is a test"; @Remove @Destroy public void destroy() {} }
and this the xhtml-page:
... <h:messages globalOnly="true" styleClass="message"/> <rich:panel> <f:facet name="header">Welcome!</f:facet> <p> <h:outputText value="Test: #{foo}"/> </p> </rich:panel> ...
But foo
(the Text) isn´t displayed.
2. Version
I added a getter-method like someone in a forum told me:
@Out public String foo = "That is a test"; public String getFoo() { return foo; }
The xhtml-page is still like in Version 1:
<h:outputText value="Test: #{foo}"/>
But foo
(the Text) isn´t displayed.
3. Version
The bean is the same as in version 2, with a getter-method.
In the xhtml-page I call the bean directly:
<h:outputText value="Test: #{basicBean.foo}"/>
The result is
javax.faces.FacesException: javax.el.PropertyNotFoundException: /home.xhtml @18,51 value="Test: #{basicBean.foo}": Property 'foo' not found on type org.javassist.tmp.java.lang.Object_$$_javassist_1
Can anybody tell me what I am doing wrong?
Thank you very much.
NSchweig