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

fernando_jmt do-not-reply at jboss.com
Tue Feb 6 10:12:49 EST 2007


You can try defining a new different role for the second DumbUser.

First you need to modify your dumbClass like this (adding a new role):

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

Then your hello world component:

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

Then the JSF should looks like:

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



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

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



More information about the jboss-user mailing list