[jboss-user] [JBoss Seam] - DataModel not made available as a context variable

zzzz8 do-not-reply at jboss.com
Wed Aug 9 16:49:58 EDT 2006


Hi,

I'm a newbie with Seam, but I've been having trouble with the DataModel annotation.  I'm not sure if it's a configuration problem, but I've used the messages example in JBoss Seam 1.0.1 GA as a baseline for my configuration (took many of the configuration values and jars from there).  I'm trying to upgrade a web app that currently runs on MyFaces 1.1.2, Tomahawk 1.1.2, and Tomcat 5.5.15.  I'm also using Tiles - in particular, with Tiles Support from Tomahawk.

I haven't done anything fancy yet - I've just tried to modify a simple existing page.  Here's a snippet of code which I'm having problems with:

@Stateful
  | @Scope(ScopeType.SESSION)
  | @Name("statusData")
  | public class StatusBean implements StatusLocal {
  |     @In
  |     private Context sessionContext;
  | 
  |     @DataModel
  |     private List status;
  | 
  |     @Factory("status")
  |     private void retrieveStatus() {
  |        // Bus. logic code - sets status...
  |     }
  |     
  |     @Remove @Destroy
  |     public void destroy() {
  |         
  |     }
  | }

The interface only lists the destroy method...

@Local
  | public interface StatusLocal {
  |     public void destroy();
  | }

My JSP code attempts to get the DataModel from here...

<h:dataTable value="#{status}" var="varStatus"...

However, I get errors stating that it cannot evaluate the expression:

  | ServletException ... .... Cannot get value for expression: #{status}

When I debug in Eclipse, I notice that the StatusBean class is never even instantiated.  Normally, one would think that there is a configuration problem.  However, if I change the bean code to:

@Stateful
  | @Scope(ScopeType.SESSION)
  | @Name("statusData")
  | public class StatusBean implements StatusLocal {
  |     @In
  |     private Context sessionContext;
  | 
  |     private List myStatus = new ArrayList();
  | 
  |     public List getMyStatus() {
  |          return myStatus;
  |     }
  |     
  |     @Remove @Destroy
  |     public void destroy() {
  |         
  |     }
  | }

and for the interface code is:

@Local
  | public interface StatusLocal {
  |     public List getMyStatus();
  |     public void destroy();
  | }

and the JSP is:

<h:dataTable value="#{statusData.myStatus}" var="varStatus"...

It works!  When I debug from inside Eclipse, I see that the bean is instantiated and the getter is called.  I also see that the sessionContext context variable is injected correctly.  These two things lead me to believe that my configuration is somewhat correct.  I haven't tried any of the other annotations and features of Seam, so I hope things aren't broken there either?

What am I doing wrong here?  I would really appreciate any assistance, as I'm pretty much stuck...

BTW, the messages example works within Tomcat 5.5.15 and if I replace the MyFaces 1.1.3 libs with MyFaces 1.1.2 libs within the messages example, it still works...

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3964165#3964165

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3964165



More information about the jboss-user mailing list