struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slayer666 <rfu...@hotmail.es>
Subject Re: Interator values not showed
Date Wed, 19 May 2010 10:05:16 GMT

Thanks Alex,
but i've solved the problem. 
This is my Action class:

public class IteratorAction extends ActionSupport implements ModelDriven{
	private ArrayList<Band> groups=new ArrayList<Band>();
	private ArrayList<Band> groups1=new ArrayList<Band>();
	private Band band=new Band("","");
	
	public String greeting(){
		return "Hi, Every body";
	}
			
	@Override
	public Object getModel() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public String execute() throws Exception {
		this.groups.add(new Band("trash","Slayer"));
		this.groups.add(new Band("trash","kreator"));
		this.groups.add(new Band("death","Deicide"));
		this.groups.add(new Band("death","Obituary"));
		this.groups1.add(new Band("heavy","Judas Priest"));
		this.groups1.add(new Band("heavy","Primal Fear"));
		return SUCCESS;
	}

	public ArrayList<Band> getGroups() {
		return groups;
	}

	public void setGroups(ArrayList<Band> groups) {
		this.groups = groups;
	}

	public ArrayList<Band> getGroups1() {
		return groups1;
	}

	public void setGroups1(ArrayList<Band> groups1) {
		this.groups1 = groups1;
	}

	public Band getBand() {
		return band;
	}

	public void setBand(Band band) {
		this.band = band;
	}					
}

And this is my jsp code:

 <s:append var="metalBands">
   <s:param value="%{groups}"/>
   <s:param value="%{groups1}"/>
 </s:append>
 Total Bands:<br>
 <s:iterator id="band" value="#metalBands">
   Band: <s:property value="name"/><br>
 </s:iterator>

Finally i used the ModelDriven interface to get the bean atributes in a
better way.

Thanks for replying.

Cheers!!.


Alex Rodriguez Lopez wrote:
> 
>>
>> Hi,
>> i'm trying the append tag and the list values of the appended lists are
>> not
>> showed.
>> This is the main part of the jsp code:
>>
>> <s:append var="metalBands">
>>     <s:param value="%{groups}"/>
>>     <s:param value="%{groups1}"/>
>>   </s:append>
>>   Total Bands:<br>
>>   <s:iterator id="band" value="%{#metalBands}">
>>     Band:<s:property value="#band.name"/><br>
>>   </s:iterator>
>>
>>
>> This is my Action class:
>>
>> package struts2.action;
>>
>> import java.util.ArrayList;
>>
>> import com.opensymphony.xwork2.ActionSupport;
>>
>> public class IteratorAction extends ActionSupport {
>> 	ArrayList<Band>  groups=new ArrayList<Band>();
>> 	ArrayList<Band>  groups1=new ArrayList<Band>();
>> 	
>> 	public String greeting(){
>> 		return "Hi, Every body";
>> 	}
>> 		
>> 	@Override
>> 	public String execute() throws Exception {
>> 		this.groups.add(new Band("trash","Slayer"));
>> 		this.groups.add(new Band("trash","kreator"));
>> 		this.groups.add(new Band("death","Deicide"));
>> 		this.groups.add(new Band("death","Obituary"));
>> 		this.groups1.add(new Band("heavy","Judas Priest"));
>> 		this.groups1.add(new Band("heavy","Primal Fear"));
>> 		return SUCCESS;
>> 	}
>>
>> 	public ArrayList<Band>  getGroups() {
>> 		return groups;
>> 	}
>>
>> 	public void setGroups(ArrayList<Band>  groups) {
>> 		this.groups = groups;
>> 	}
>>
>> 	public ArrayList<Band>  getGroups1() {
>> 		return groups1;
>> 	}
>>
>> 	public void setGroups1(ArrayList<Band>  groups1) {
>> 		this.groups1 = groups1;
>> 	}			
>> }
>>
>> This is my bean class:
>>
>> package struts2.action;
>>
>> public class Band {
>> 	private String style;
>> 	private String name;
>> 	
>> 	public Band(String st,String n){
>> 		this.style=st;
>> 		this.name=n;
>> 	}
>>
>> 	public String getStyle() {
>> 		return style;
>> 	}
>>
>> 	public void setStyle(String style) {
>> 		this.style = style;
>> 	}
>>
>> This is the ouput application:
>>
>> Total Bands:
>> Band:
>> Band:
>> Band:
>> Band:
>> Band:
>> Band:
>>
>> As you can see there is no values showed .
>> Please, can you help me with this?.
>>
>> Thanks in advanced!!.
> 
> I think you need a public getter for band.name:
> 
> public String getName() {
> 	return name;
> }
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Interator-values-not-showed-tp28599699p28606255.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message