"lisa ward" <[EMAIL PROTECTED]>

> Hi again,
>
> The values in your hash map have been hardcoded in, which works fine.  But
> what do I if I do not know what the user's selection will be in advance.
> Take for instance, if I have a set of checkboxes on my page, I would like
to
> be able to initialize the map with the values that the user has selected.
> Or am I just missing the point here?

Hold on. You have to have all necessary information, when you are generating
the link. It does not matter, whether the keys in the map are hardcoded or
determined during the runtime. Important is that you are creating the link
on the server side, before the user clicks on any checkboxes.

If you want to use user's input, you can do it when serving the next page.
You can then generate the map in an Action and generate the link for the
next displayed page (so you will know all paramaters in advance, since
the checkboxes have been submitted already)

Or your Action can use the checkboxes to determine what to do or to
determine where to forward to. You don't need to use constant strings
in findForward.

Another possibility would be using JavaScript on the client, but since
many browsers have JavaScript disabled, you should not rely on it.

--
gR

>
> Please explain further and thank you very much for your patience.
>
> Thanks
> Lisa



>
>
> >From: "Gregor Rayman" <[EMAIL PROTECTED]>
> >Reply-To: [EMAIL PROTECTED]
> >To: <[EMAIL PROTECTED]>
> >CC: "lisa ward" <[EMAIL PROTECTED]>
> >Subject: Re: dynamic forwards
> >Date: Wed, 26 Sep 2001 20:55:34 +0200
> >
> >"lisa ward" <[EMAIL PROTECTED]> wrote:
> >
> > > Another quick question.  How would I be able to initialize the
hashMap.
> >the
> > > problem Im facing is that when I use a forward the submit is not
called
> >so
> > > the values are not initialized in my bean.
> >
> >Here an quick and dirty example. (Dirty beacuse it uses scriplte. Custom
> >tag
> >would be somehow more apprpriate.)
> >
> ><%
> >   HashMap linkParams = new HashMap(); // create the map
> >   linkParams.put("areaId", "a"); // set the values
> >   linkParams.put("aspectId", "b");
> >   pageContext.setAttribute("linkParams", linkParams); // make the map an
> >attribute of page
> >%>
> >
> ><html:link page="/deleteaspect.do" name="linkParams">
> >   <bean:message key="button.delete"/>
> ></html:link>
> >
> >The generated URL will be: .../deleteaspect.do?areaId=a&aspectId=b
> >
> >The map does not have to be the attribute itself. It can be a property of
> >an
> >attribute. Then the <html:link> tag would look like this:
> >
> ><html:link page="/deleteaspect.do" name="linkAttribute"
> >property="propertyName">
> >
> >--
> >gR
> >
> >
> >
> >
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>

Reply via email to