text: DataModel not made available as a context variablezzzz8 Aug 9, 2006 4:49 PM
  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...
  1. Re: DataModel not made available as a context variableGavin King Aug 9, 2006 5:38 PM (in response to zzzz8)
  You cannot have a private @Factory method. It must be on the business interface.
  2. Re: DataModel not made available as a context variablezzzz8 Aug 9, 2006 5:59 PM (in response to zzzz8)
  Thanks Gavin! It works! Thanks for the quick reply and for pointing out my idiocy! :)
  3. Re: DataModel not made available as a context variablehdslkf hklsdg Aug 10, 2006 4:43 AM (in response to zzzz8)
  btw: please make sessionContext transient:
  @In private transient Context sessionContext;
  Otherwise you will run into problems when the bean gets passivated due to idle time and reactived.