• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Array dispaly

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have array containing simple integers . I want to display these integers
on another page using struts's <logic:iterate> tag.How can i display?/*


package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class loginform extends org.apache.struts.action.ActionForm {
private int array [];
private String gender;
private String text;
private String text1;


public void setArray() {
int array[]={1,2};
}

public int[] getArray() {
return (this.array);
}


public void setGender(String gender) {
this.gender = gender;
}

public String getGender() {
return (this.gender);
}


public String getText() {
return text;
}

public void setText(String string) {
text = string;
}

public String getText1() {
return text1;
}

public void setText1(String string) {
text1 = string;
}

public loginform() {
super();
// TODO Auto-generated constructor stub
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (getText() == null || getText().length() < 1) {
errors.add("text", new ActionMessage("error.text.required"));
// TODO: add 'error.name.required' key to your resources
}
if (getText1() == null || getText1().length() < 1) {
errors.add("text1", new ActionMessage("error.text1.required"));
// TODO: add 'error.name.required' key to your resources
}

return errors;
}
}

Here is my form bean

Thanks in advance
 
Rohitash sharma
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I am using this type of coding


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h2>Hello World!</h2>
<bean:write property="text" name="loginform"/>
<bean:write property="gender" name="loginform"/>
<logic:iterate id="xyz" name="loginform" property="array">

</logic:iterate>

</body>
</html>


But it is giving some type of error
 
Rohitash sharma
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know how to write
<bean:write> tag between <logic:iterate> tag
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi rohit

Are you using struts 2?
Then why don't you try <s:iterator/> instead of <logic:iterate/>


Thanks
Harimohan
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please specify your problem
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic