2 Replies Latest reply on Oct 16, 2007 8:50 AM by Pete Muir

    DataInputSelection has problem with injection

    Bartosz Jamroz Newbie

      This is my second topic about the same problem, but due to the amount of new topics on the forum, it`s kinda necessary.

      I`ve written a simple controller using code snippet from the 1 chapter of Seam tutorial.

      public class TestControllerBean implements Serializable, TestController {
       private Log log;
       private EntityManager entityManager;
       private List<QuestionCategory> questionCategoryList;
       private QuestionCategory questionCategory;
       /** Creates a new instance of TestControllerBean */
       public TestControllerBean() {
       public void remove() {
       questionCategory = null;
       public void showAll() {
       questionCategoryList = entityManager.createQuery("from QuestionCategory qc").getResultList();
       @Remove @Destroy
       public void destroy() {}

      And the test.xhtml

      <html xmlns="http://www.w3.org/1999/xhtml"
       <h:outputText value="categoryList rowCount is null" rendered="#{questionCategoryList.rowCount == null}"/><br/>
       <h:outputText value="categoryList rowCount = 0" rendered="#{questionCategoryList.rowCount == 0}"/><br/>
       <h:outputText value="Available categoryList: " rendered="#{questionCategoryList.rowCount > 0}"/><br/>
       <h:dataTable var="cat" value="#{questionCategoryList}">
       <h:outputText value="[ #{cat.categoryName} ]"/>
       <h:outputText value=" - [ #{cat.created} ]"><f:convertDateTime pattern="dd-MMM-yyyy H:mm"/></h:outputText>
       <s:link value="remove" action="#{TestController.remove}"/>
       <ui:debug hotkey="d"/>

      It works fine when I want to render list of questionCategories but when i hit "remove" link i get NullPointerException indicating, as far as i think, that questionCategory isn`t injected to the stateful bean.

      The only difference between this code and the tutorial is that in my code i didn`t use @Scope(SESSION) but I don`t think that this could be a problem.

      Any ideas about solving my problem ????