I know but I couldn't get the iterator tag to give me what I needed, maybe
someone out there could help us both with this. I think the problem with the
tag was that I couldn't cast the exposed object to a String[]. maybe it
assumes that you are giving it a list of Strings.

-----Original Message-----
From: Zeltser, Mark [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 25, 2000 1:20 PM
To: '[EMAIL PROTECTED]'
Subject: RE: How to create bean from dynamic JSP page


I thought I could build a site without using scriplets. You are
introducing them which defeats the purpose of using struts and its tags.

-----Original Message-----
From: Aur Gal [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 25, 2000 2:09 PM
To: '[EMAIL PROTECTED]'
Subject: RE: How to create bean from dynamic JSP page


I tried to use the iterate tag to do something similar and failed. what
I
did in the end was this:
//expose the property containing the list, in this case an iterator in
which
the objects are String[].
<struts:getProperty id="packs" name="PackageForm" property="packs"/>
//iterate through it. 
<%
        Iterator itr=(Iterator)pageContext.getAttribute("packs");
        String[] p=null;
        while(itr.hasNext())
        {
        p=(String[])itr.next();
        %>
                <tr>
                        <td><struts:radio name="PackageForm"
property="packid" value="<%=p[0]%>"/></td>
<td><%=p[1]%></td><td><%=p[2]%></td><td><%=p[3]%></td><td><%=p[4]%></td>
                </tr>
        <%}
%>

so in the ActionForm ( the bean ) I have this get method:
public Iterator getPacks(){ return packs.iterator(); }
//packs is an ArrayList of String[] 
-----Original Message-----
From: Zeltser, Mark [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 25, 2000 12:57 PM
To: '[EMAIL PROTECTED]'
Subject: RE: How to create bean from dynamic JSP page



Is FormBean supports indexed properties? Where can I find this?

-----Original Message-----
From: Aur Gal [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 25, 2000 1:49 PM
To: '[EMAIL PROTECTED]'
Subject: RE: How to create bean from dynamic JSP page


why not use a List (ArrayList) to store the questions?

the getter and setter methods could be told which cells to set and
return
from this list.

-----Original Message-----
From: Zeltser, Mark [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 25, 2000 12:41 PM
To: '[EMAIL PROTECTED]'
Subject: RE: How to create bean from dynamic JSP page


Here is my situation:

I have questionnaire where the number of questions depends on user type.
Each question has multiple choices presented to user as radio buttons. 

I have collection of questions and I am going to use Iterator tag to
display them. However, I need QuestionsForm which will have n ( where n
is number of questions) Strings that will correspond to each question. 

Struts is using reflection to match each element's name to QuestionsForm
instance variable. I don't know how to build this QuestionsForm with
variable # of instance variable. I can assume the max number of
questions but this doesn't look clean to me.

Thanks, Mark.

-----Original Message-----
From: Basile Andrea [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 25, 2000 12:10 PM
To: '[EMAIL PROTECTED]'
Subject: RE: How to create bean from dynamic JSP page


I don't know what is your applications's architecture, but I think the
Iterate tag could accomplish this. You could set a Collection of
questions
in the Action Form and let it pick them up in the JSP.
If you have something like a bean "Question" with some properties set,
this
could be very easy to do.

Andrea

-----Original Message-----
From: Zeltser, Mark [mailto:[EMAIL PROTECTED]]
Sent: mercoledì 25 ottobre 2000 17.21
To: [EMAIL PROTECTED]
Subject: How to create bean from dynamic JSP page


Hello,

We are trying to migrate existing application from JSP/Servlets to
struts. I have a JSP page which should display dynamically different
questions. I don't know how to create a form bean with all
setters/getters since I don't know in advance all the names. Anyone
knows how to accomplish this?

Thanks, Mark.

Reply via email to