Struts + logic:iterate + DynaActionForm + String[ ]

J

javaguy44

I have a question about the subject above, and was wondering if anyone
can help me.

I have a DynaActionForm with the following in struts-config.xml:
<form-bean name="myDynaValidateForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="testiterate" type="java.lang.String[]"/>
</form-bean>

In my action class, I have a the following:

DynaValidatorForm f = (DynaValidatorForm) form;
String[] s = new String[3];
s[0] = "a";
s[1] = "b";
s[2] = "c";
f.set("testiterate", s);

Now my question is how can I display the following using logic:iterate
in my jsp?

I have done the following, and it does not work so far:
<logic:iterate id="idx" name="myDynaValidateForm">
<bean:write name="idx" property="testiterate"/>
</logic:iterate>

I would appreciate any help you can give me!

As for problem 2:
I have implemented the same part above but in a different manner.
Rather than trying to f.set("testiterate",s); I do the following in my
action form

DynaValidatorForm f = (DynaValidatorForm) form;
String[] s = new String[3];
s[0] = "a";
s[1] = "b";
s[2] = "c";
request.setAttribute("RESULTSTRING", s);

Now I can get this to display in the .jsp, but my question 2 is
this...in order to get it to display, I had to include <logic:present>
tags like so:

<logic:present name="RESULTSTRING" scope="request">
<logic:iterate id="list" name="RESULTSTRING">
<bean:write name="list"/>
</logic:iterate>
</logic:present>

I could only find one link that says I had to include <logic:present>
on the web, and I was just hoping that someone could confirm that I
had to use <logic:present>???

I am using Struts 1.1, and Tomcat 5.0.19

Thanks,
Javaguy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top