You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by slayer666 <rf...@hotmail.es> on 2010/05/18 21:21:38 UTC

Interator values not showed

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!!.
-- 
View this message in context: http://old.nabble.com/Interator-values-not-showed-tp28599699p28599699.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


nested struts2 validation

Posted by Stephen Ince <st...@gmail.com>.
Hi,
  I would like to do nested struts2 validation. I have two questions.

1) How do I specify the validation for the following field. Can some point me to some documenation for the expression validation.


<input type="text" name="searchResults[${i}].resource.name" ..
validation.xml

<validator type="expression">
<param name="expression">
searchResults.{#this.resource.name.length() &gt; 0}.{? #this == false }.size() &lt;= 0
</param>
<message key="resource.name.required" />
</validator>

2) Can specify a particular method for an action class.

e.g.

SearchAction-search!update-validation.xml
where
search -- is the action alias and
update -- is the method to execute in SearchAction

Steve

Re: Interator values not showed

Posted by slayer666 <rf...@hotmail.es>.
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


Re: Interator values not showed

Posted by Alex Rodriguez Lopez <al...@flordeutopia.pt>.
>
> 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


Re: Interator values not showed

Posted by slayer666 <rf...@hotmail.es>.


slayer666 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!!.
> 

-- 
View this message in context: http://old.nabble.com/Interator-values-not-showed-tp28599699p28606214.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