• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to create text boxes using array/collections using struts tag

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have 4 text boxes in a row and i have 10 such rows. I am using struts html tag and my code is as follows:

<tr>

<td>
1.
</td>
<td>
<html:text property="POD1"></html:text>
</td>
<td>
<html:text property="PONP1"></html:text>
</td>
<td>
<html:text property="POQ1" size="6"></html:text>
</td>
<td></td>
<td>
<html:text property="UOM1" size="4" value="nos."></html:text>
</td>
</tr>
<tr>
<td>
2.
</td>
<td>
<html:text property="POD2"></html:text>
</td>
<td>
<html:text property="PONP2"></html:text>
</td>
<td>
<html:text property="POQ2" size="6"></html:text>
</td>
<td></td>
<td>
<html:text property="UOM2" size="4" value="nos."></html:text>
</td>
</tr>

till 10.
I have corresponding getter setter methods in my Action Form.

My concern is , if in future i want to increase the number of text boxes, it would be very tedious for me to do so. Also the number of getters and setters will go on increasing.

So is there any other alternative to this? May be using array or collections?

Please help me out javascript:emoticon('');

Thanks

 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please, Post this topic in sturts forum. you may get better response

Coming to your question. you should read about Index Properties
 
Deeps Mistry
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

seetharaman venkatasamy wrote:Please, Post this topic in sturts forum. you may get better response

Coming to your question. you should read about Index Properties



Hi,

I had posted this question in struts forum, but one rancher told me to shift it to jsp forum. javascript:emoticon('');

Thanks for your prompt reply.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Deeps Mistry wrote:Thanks for your prompt reply.



You are welcome. and please read (and implement yourself) about the index property article. it is very usefull
 
Deeps Mistry
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

seetharaman venkatasamy wrote:

Deeps Mistry wrote:Thanks for your prompt reply.



You are welcome. and please read (and implement yourself) about the index property article. it is very usefull



Hi,

Is it compulsory to use DynaActionForm to implement the index property?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Deeps Mistry wrote:Is it compulsory to use DynaActionForm to implement the index property?



Not at All
 
Deeps Mistry
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

seetharaman venkatasamy wrote:

Deeps Mistry wrote:Is it compulsory to use DynaActionForm to implement the index property?



Not at All



Hi,

I am stuck and confused and dont know what to do further. Please help me out ranchers.

I tried using indexed property but didn't work out.

Please help me out.javascript:emoticon('');

Thanks
 
Deeps Mistry
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Deeps Mistry wrote:

seetharaman venkatasamy wrote:

Deeps Mistry wrote:Is it compulsory to use DynaActionForm to implement the index property?



Not at All



Hi,

I am stuck and confused and dont know what to do further. Please help me out ranchers.

I tried using indexed property but didn't work out.

Please help me out.javascript:emoticon('');

Thanks



Hi all,

I tried the following:
1) Created a bean containing 4 getters setters for the 4 text boxes in a row.
2) Then i created an arraylist and added 10 new bean objects to it.
3) I set this arraylist in the form.
4) I put a logic iterate tag to iterate over the arraylist in my jsp page.

The code is a s follows:
My bean:

public class AddPOBean {

private String POD = null;
private String PON = null;
private String POQ = null;
private String UOM = null;


public String getPOD() {
return POD;
}
public void setPOD(String pod) {
POD = pod;
}
public String getPON() {
return PON;
}
public void setPON(String pon) {
PON = pon;
}
public String getPOQ() {
return POQ;
}
public void setPOQ(String poq) {
POQ = poq;
}
public String getUOM() {
return UOM;
}
public void setUOM(String uom) {
UOM = uom;
}

}

My Action class:

arrBean = new ArrayList();
for(int i = 0;i<10;i++)
{
objAddPOBean = new AddPOBean();
arrBean.add(objAddPOBean);
}
objAddPOForm.setArrBean(arrBean);

My jsp page:
<tr>
<td>
<logic:iterate id="AddPOForm" name="AddPOForm">
<html:text name ="AddPOForm" property="arrBean"></html:text>
</logic:iterate>
</td>
<tr>


I am getting the following error:

javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot create iterator for this collection


Am i doing anything wrong? Please help me out

Thanks
 
Deeps Mistry
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Deeps Mistry wrote:

Deeps Mistry wrote:

seetharaman venkatasamy wrote:

Deeps Mistry wrote:Is it compulsory to use DynaActionForm to implement the index property?



Not at All



Hi,

I am stuck and confused and dont know what to do further. Please help me out ranchers.

I tried using indexed property but didn't work out.

Please help me out.javascript:emoticon('');

Thanks



Hi all,

I tried the following:
1) Created a bean containing 4 getters setters for the 4 text boxes in a row.
2) Then i created an arraylist and added 10 new bean objects to it.
3) I set this arraylist in the form.
4) I put a logic iterate tag to iterate over the arraylist in my jsp page.

The code is a s follows:
My bean:

public class AddPOBean {

private String POD = null;
private String PON = null;
private String POQ = null;
private String UOM = null;


public String getPOD() {
return POD;
}
public void setPOD(String pod) {
POD = pod;
}
public String getPON() {
return PON;
}
public void setPON(String pon) {
PON = pon;
}
public String getPOQ() {
return POQ;
}
public void setPOQ(String poq) {
POQ = poq;
}
public String getUOM() {
return UOM;
}
public void setUOM(String uom) {
UOM = uom;
}

}

My Action class:

arrBean = new ArrayList();
for(int i = 0;i<10;i++)
{
objAddPOBean = new AddPOBean();
arrBean.add(objAddPOBean);
}
objAddPOForm.setArrBean(arrBean);

My jsp page:
<tr>
<td>
<logic:iterate id="AddPOForm" name="AddPOForm">
<html:text name ="AddPOForm" property="arrBean"></html:text>
</logic:iterate>
</td>
<tr>


I am getting the following error:

javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot create iterator for this collection


Am i doing anything wrong? Please help me out

Thanks



Hey Ranchers...please help me out
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic