lol don't be to hard with yourself ;p

--
Alexandre Jaquet

----- Original Message ----- 
From: "James Mitchell" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Thursday, March 06, 2003 1:11 AM
Subject: RE: Accepting arrays as values in mapped-backed ActionForms


> Wow, I'm glad I could help ;D
> 
> 
> --
> 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: Wednesday, March 05, 2003 3:34 PM
> > To: 'Struts Users Mailing List'
> > Subject: RE: Accepting arrays as values in mapped-backed ActionForms
> > 
> > 
> > Solved:
> > 
> > On the form bean I now include:
> > 
> >    public String[] getExGroups(String key){
> >       return (String[]) existingGroups.get(key);
> >    }
> > 
> >    public void setExGroups(String key, String[] values){
> >       existingGroups.put(key,values);
> >    }
> > 
> > and use exGroups(primaryKey) as the multibox property.
> > 
> > I had tried something similar earlier but I had 
> > 
> >    public Object getExGroups(String key){
> >       return existingGroups.get(key);
> >    }
> > 
> >    public void setExGroups(String key, Object values){
> >       existingGroups.put(key,values);
> >    }
> > 
> > which I had seen in another example and that accepted only the first
> > input from each of the rows of checkboxes as a String and ignored the
> > others.
> > 
> > If you have similar examples that can do the job more elegantly (or
> > differently even), I'd love to see them. Ideas can only help.
> > 
> > 
> > -- John
> > 
> > 
> > 
> > -----Original Message-----
> > From: John Devine [mailto:[EMAIL PROTECTED] 
> > Sent: Wednesday, March 05, 2003 2:10 PM
> > To: 'Struts Users Mailing List'
> > Subject: RE: Accepting arrays as values in mapped-backed ActionForms
> > 
> > Okay, yes the actual business process is not very well explained.
> > Probably I should have used generic object names, but since it's
> > started:
> > 
> > I have a bunch of "story" objects.
> > Each story object can belong to 0 or more groups.
> > 
> > The functionality of this page is to show the user which groups their
> > stories belong to as well as to change the groups to which each story
> > belongs.
> > 
> > So the user can page through the list of her stories 
> > (generated through
> > the search bean, which is actually an attribute on the ActionForm Bean
> > (submitToGroupForm)). For each list of 10 stories, the 
> > submitToGroupForm
> > sets up a map called "existingGroups" which contains a String array of
> > the group id's associated with each story. 
> > 
> > "availableGroups" is an array of String group id's put into
> > actionFormBean which contains all the groups the user has 
> > permission to
> > access.
> > 
> > So, in addition to the regular info on each story (title, id, plus the
> > tile "storyDetailswithBlurb.jsp"), the generated page is a matrix of
> > checkboxes:
> > One row of "availableGroups" checkboxes for each story.
> > 
> > The idea was to use the map on the actionForm to receive changes to
> > groups, with the key of the map being the storyId, and the value being
> > the array of groups Id's that were checked off for each story. Then my
> > Action will pass that info off to a bean that will do the 
> > reassignment.
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > -----Original Message-----
> > From: James Mitchell [mailto:[EMAIL PROTECTED] 
> > Sent: Wednesday, March 05, 2003 4:22 AM
> > To: 'Struts Users Mailing List'
> > Subject: RE: Accepting arrays as values in mapped-backed ActionForms
> > 
> > Ok, I've had time to look over your notes.
> > 
> > I may be missing some pieces to the puzzle here.
> > 
> > If I understand you correctly, you've got a bean (searchBean) 
> > that has a
> > List of Story beans, each with id and title.
> > 
> > You have a formbean (submitToGroupForm) that returns a Map of Groups
> > (getExistingGroups) keyed off of the id from an iteration of the first
> > bean (searchBean).
> > 
> > Is this correct so far?
> > Which bean is the form associated with this action? (I am assuming
> > submitToGroupForm)
> > Why do you iterate over the formbean, then iterate over a 
> > field on that
> > bean?
> > 
> > Can you post more details on what you are wanting to accomplish here?
> > 
> > 
> > 
> > --
> > 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: James Mitchell [mailto:[EMAIL PROTECTED] 
> > > Sent: Tuesday, March 04, 2003 6:38 PM
> > > To: 'Struts Users Mailing List'
> > > Subject: RE: Accepting arrays as values in mapped-backed ActionForms
> > > 
> > > 
> > > John, sorry for not getting back sooner.  I've been in 
> > meetings since
> > > lunch.  I'll see what I can work up tonight.
> > > 
> > > 
> > > --
> > > 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 2:41 PM
> > > > To: 'Struts Users Mailing List'
> > > > Subject: RE: Accepting arrays as values in mapped-backed 
> > ActionForms
> > > > 
> > > > 
> > > > Sure I'd love to see an example!
> > > > 
> > > > But like I said, I ended up using the scriptlets for 
> > > iteration because
> > > > within the iteration of "storyList" I call a tile like so:
> > > > 
> > > >   <td>
> > > > <tile:insert 
> > > page="/WEB-INF/tilestemplates/storyDetailwithBlurb.jsp" >
> > > >  <tile:put name="story" beanName="story" />
> > > >  <tile:put name="counter" beanName="counter" />
> > > > </tile:insert>
> > > >   </td>
> > > > 
> > > > and I couldn't get the tile to be called properly when it was 
> > > > within an
> > > > <logic:iterate> tag. (and I haven't boned up on the nested 
> > > tags enough
> > > > to be comfortable with them yet).
> > > > 
> > > > If you have an example of naming the property of the multibox 
> > > > to accept
> > > > a set of options for each story in the iteration, that's 
> > > where my real
> > > > problem lies right now. The way I have it now works fine for 
> > > > <html:text>
> > > > and single parameter inputs, but I can't get it to work 
> > for multiple
> > > > parameter inputs.
> > > > 
> > > > Thanks,
> > > > 
> > > > John
> > > > 
> > > > 
> > > > -----Original Message-----
> > > > From: James Mitchell [mailto:[EMAIL PROTECTED] 
> > > > Sent: Tuesday, March 04, 2003 1:28 PM
> > > > To: 'Struts Users Mailing List'
> > > > Subject: RE: Accepting arrays as values in mapped-backed 
> > ActionForms
> > > > 
> > > > 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]
> > > > 
> > > > 
> > > > 
> > > 
> > ---------------------------------------------------------------------
> > > > 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]
> > 
> > 
> > ---------------------------------------------------------------------
> > 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]
> 

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

Reply via email to