[jboss-user] [JBoss Seam] - Re: @Factory method kills my @In fields
tomstrummer
do-not-reply at jboss.com
Thu Dec 20 14:09:41 EST 2007
"pete.muir at jboss.org" wrote : Seam injects by variable name, not by type so try @In TestEntity testEntity;
Hmm nope, sorry that did not help. Same error. Here is the updated code snice I realized I had a typo in my template as well:
TestImpl.java
| import java.util.ArrayList;
| import java.util.List;
|
| import javax.ejb.Stateless;
|
| import org.jboss.seam.ScopeType;
| import org.jboss.seam.annotations.Factory;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Logger;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.datamodel.DataModel;
| import org.jboss.seam.log.Log;
|
| @Stateless
| @Name("test")
| public class TestImpl implements Test {
| @Logger Log log;
|
| public void biteMe() {
| log.info( testEntity.getName() );
| something.add(testEntity);
| }
|
| @In(scope=ScopeType.EVENT) private TestEntity testEntity;
|
| @DataModel(scope=ScopeType.PAGE) List<TestEntity> something;
|
| @Factory("something")
| public List<TestEntity> initSomething() {
| List<TestEntity> list = new ArrayList<TestEntity>();
| return list;
| }
| }
|
test.xhtml:
| <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <ui:composition xmlns="http://www.w3.org/1999/xhtml"
| xmlns:s="http://jboss.com/products/seam/taglib"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:rich="http://richfaces.org/rich"
| template="layout/template.xhtml">
|
| <ui:define name="body">
|
| <h:messages globalOnly="true" styleClass="message"/>
|
| <rich:panel>
| <f:facet name="header">Test!</f:facet>
|
| <h:form>
| <h:inputText value='#{testEntity.name}' />
| <h:commandButton type="submit" value='Create' action='#{test.biteMe}' />
|
| <h:dataTable value='#{something}' var='profile'>
| <h:column>
| <f:facet name='header'><h:outputText value='Name' /></f:facet>
| <h:outputText value='#{profile.profileName}' />
| </h:column>
| </h:dataTable>
| </h:form>
|
| </rich:panel>
|
| </ui:define>
| </ui:composition>
|
For real... Comment out that "@Factory" annotation and suddenly it works (of course the list is not initialized then...) Any other ideas?
Thanks again.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114765#4114765
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114765
More information about the jboss-user
mailing list