[jboss-user] [JBoss Seam] - @Factory method kills my @In fields

tomstrummer do-not-reply at jboss.com
Thu Dec 20 10:43:27 EST 2007


I've narrowed this down as much as possible...  Basically I have an @Factory method in stateless action bean.  When I hit the page, I get:

  | In attribute requires non-null value: test.entity
  | 

The same happens if the action is a stateful SB.  

Here is a simple example which duplicates the behavior:

view/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='#{testProfile.profileName}' />
  | 			<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>
  | 

action/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( entity.getName() );
  | 		something.add(entity);
  | 	}
  | 	
  | 	@In(scope=ScopeType.EVENT) private TestEntity entity;
  | 	
  | 	@DataModel(scope=ScopeType.PAGE) List<TestEntity> something;
  | 	
  | 	@Factory("something") public List<TestEntity> initSomething() {
  | 		List<TestEntity> list = new ArrayList<TestEntity>();
  | 		return list;
  | 	}	
  | }
  | 

action/Test.java

  | import java.util.List;
  | import test.model.TestEntity;
  | import com.enernoc.ess.emulator.model.configuration.Profile;
  | 
  | public interface Test {
  | 	public void biteMe();
  | 	public List<TestEntity> initSomething();
  | }
  | 

model/TestEntity.java

  | import javax.persistence.Entity;
  | import javax.persistence.GeneratedValue;
  | import javax.persistence.Id;
  | import javax.persistence.Version;
  | 
  | import org.jboss.seam.annotations.Name;
  | 
  | @Entity
  | @Name("testEntity")
  | public class TestEntity {
  | 	@Id @GeneratedValue private Long ID;
  | 	@Version private Long version;
  | 	
  | 	private String name;
  | 	
  | 	public String getName() { return this.name; }
  | 	public void setName(String name) { this.name = name; } 
  | }
  | 

Any help would be greatly appreciated... This is so simple I can't see why it wouldn't work.  The @Factory annotation says it is only responsible for the named field, meaning it is only a factory for "something," not "entity".

THanks.

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

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



More information about the jboss-user mailing list