You can accomplish all of this with tags and elimate your scriptlets.

I have something close to that, let me know if you want an example.


--
James Mitchell
Web Developer/Struts Evangelist
http://jakarta.apache.org/struts/

"People demand freedom of speech to make up for the freedom of thought
which they avoid."
    - Soren Aabye Kierkegaard (1813-1855)




> -----Original Message-----
> From: John Devine [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, March 04, 2003 1:52 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Accepting arrays as values in mapped-backed ActionForms
> 
> 
> Hello Struts community!
> 
> No one's picked up on this thread and I just wonder whether it's a
> stupid or unclear question or whether it's just not of interest. 
> 
> If the question's been answered before, could someone let me know and
> I'll go back to searching lists. I didn't find any answers earlier.
> 
> Basically what I'm trying to is set up a form that will 
> contain a Map of
> String arrays. At this point, when Struts populates the Map, 
> it assumes
> the map elements will be plain strings. Does anyone know of a way to
> tell it that the members of the map should be populated as arrays
> (because multiple request parameters will have the same name).
> 
> Thanks in advance for any response,
> 
> John Devine
> 
> 
> 
> 
> -----Original Message-----
> From: John Devine [mailto:[EMAIL PROTECTED] 
> Sent: Monday, March 03, 2003 5:10 PM
> To: [EMAIL PROTECTED]
> Subject: Accepting arrays as values in mapped-backed ActionForms
> 
> Does anyone know how to specify that the value of the HashMap in a
> mapped-backed ActionForm should be an array of Strings rather 
> than just
> a single String?
> 
> I'm having a problem in trying to set up a page of several rows of
> indexed multi-boxes:
> 
> I have a regular action form that includes:
> 
>    public Map existingGroups = new HashMap();
> 
>    public Map getExistingGroups(){
>       return existingGroups;
>    }
> 
>    public void setExistingGroups(Map map){
>       this.existingGroups = map;
>    }
> 
> On my JSP, I include several different rows of multiboxes, and I want
> the user to be able to choose different groups for each object:
> 
> <%
> List storyList = searchBean.getList();
> int counter = 1; 
> for (Iterator i = storyList.iterator(); i.hasNext(); counter++ ) { 
>    Story story = (Story)i.next(); 
>    pageContext.setAttribute("story", story); 
>    pageContext.setAttribute("counter", new Integer(counter)); 
> %>
> 
> <tr>
>   <td>
>    <bean:write name="story" property="title" />
>   </td>
> <logic:iterate id="group" name="submitToGroupForm"
> property="availableGroups" type="com.rd.Group" >
>   <td>
>    <html:multibox 
> property='<%="existingGroups("+story.getId()+")"%>'  >
>     <bean:write name="group" property="id" />
>    </html:multibox>
>     <bean:write name="group" property="name" />
>   </td>
> </logic:iterate>
> </tr>
> 
> <% } %>
> 
> (Oh, and I use the scriptlet iteration because there's a tile being
> called within that loop that I edited out for readability.)
> 
> What happens is that value of "existingGroups(primaryKey1)" 
> is a String
> instead of an array of Strings. So that if I try to cast it 
> to String[],
> I get a ClassCastException.
> 
> Is this a limitation of using maps in forms, or is there a 
> way to return
> arrays of strings as entries of the Map on your ActionForm?
> 
> Thanks,
> 
> John
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to