[jboss-user] [JBoss Seam] - DataInputSelection has problem with injection
w17chm4n
do-not-reply at jboss.com
Mon Oct 15 03:48:05 EDT 2007
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.
| @Stateful
| @Name("TestController")
| public class TestControllerBean implements Serializable, TestController {
|
| @Logger
| private Log log;
|
| @In
| private EntityManager entityManager;
|
| @DataModel
| private List<QuestionCategory> questionCategoryList;
|
| @DataModelSelection
| @Out(required=false)
| private QuestionCategory questionCategory;
|
| /** Creates a new instance of TestControllerBean */
| public TestControllerBean() {
| }
|
| public void remove() {
| questionCategoryList.remove(questionCategory);
| entityManager.remove(questionCategory);
| questionCategory = null;
| }
|
| @Factory(value="questionCategoryList")
| 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"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:s="http://jboss.com/products/seam/taglib">
| <body>
|
| <h:form>
| <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:column>
| <h:outputText value="[ #{cat.categoryName} ]"/>
| </h:column>
| <h:column>
| <h:outputText value=" - [ #{cat.created} ]"><f:convertDateTime pattern="dd-MMM-yyyy H:mm"/></h:outputText>
| </h:column>
| <h:column>
| <s:link value="remove" action="#{TestController.remove}"/>
| </h:column>
| </h:dataTable>
| </h:form>
|
| <ui:debug hotkey="d"/>
|
| </body>
| </html>
|
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 ????
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4095107#4095107
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4095107
More information about the jboss-user
mailing list