[jboss-user] [JBoss Seam] - Re: multiple component instances in one page

soudmaijer do-not-reply at jboss.com
Tue Feb 6 09:59:34 EST 2007


Alright,

this works, but now to another problem. Lets say my simple object looks like this:


  | @Name("dumbUser")
  | public class DumbUser {
  | 	
  | 	private String name;
  | 		
  | 	public DumbUser() {
  | 	}
  | 
  | 	public String getName() {
  | 		return name;
  | 	}
  | 
  | 	public void setName(String name) {
  | 		this.name = name;
  | 	}
  | }
  | 

and my helloworld component looks like this:


  | @Name("helloworld")
  | public class Helloworld {
  | 
  | 	@In("dumbUser")
  | 	private DumbUser dumbUser;
  | 	
  | 	public String sayHello() {
  | 		System.out.println("sayHello: "+ dumbUser.getName());
  | 		return "success";
  | 	}
  | }
  | 

my jsf like this:


  |     <h:form>
  |         <div>
  |         	<h:inputText value="#{dumbUser.name}"></h:inputText>
  |         	
  |             <h:commandButton type="submit" value="sayHello!" action="#{helloworld.sayHello}"/>     			  
  |         </div>
  |     </h:form>
  | 

This all works fine, but if I want to add another dumbUser to the Helloworld component, something like this:


  | @Name("helloworld")
  | public class Helloworld {
  | 
  | 	@In("dumbUser")
  | 	private DumbUser dumbUser1;
  | 	
  | 	@In("dumbUser")
  | 	private DumbUser dumbUser2;	
  | 	
  | 	public String sayHello() {
  | 		System.out.println("sayHello: "+ dumbUser1.getName());
  | 		System.out.println("sayHello: "+ dumbUser2.getName());
  | 		return "success";
  | 	}
  | }

Is this possible? How do I access them from the JSF? Something like this?


  |     <h:form>
  |         <div>
  |         	<h:inputText value="#{dumbUser1.name}"></h:inputText>
  |         	<h:inputText value="#{dumbUser2.name}"></h:inputText>
  |         	
  |             <h:commandButton type="submit" value="sayHello!" action="#{helloworld.sayHello}"/>     			  
  |         </div>
  |     </h:form>
  | 

This doesnt work... but i`ve tried many variations... is it possible?

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

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



More information about the jboss-user mailing list