Hi Bill,
Many thanks for your response, I think I got bogged down the email... It was
also late for me, so couldn't put the problem succinctly, but after a few
hours sleep it became clearer... What I was trying to do was retrieve a
value from the map-backed hash map to get a default value for a drop down
list (a html:select tag use), and the property name of the dropdown to be
retrieved is taken from another bean...
In essence the jsp becomes,
<%
String props = "value(" +
pageContext.getAttribute("filterName") + ")";
%>
where dropdown label/values are stored in array lists that are in turn
stored in a hashmap contained in the bean "dao". The FormBean contains a
hashmap that is accessed via setValue/getValue methods. This dynamically
produces dropdowns at runtime, with default parameters defined by the
mapbacked action form.
I was trying to use jstl stuff for dynamically setting the props string and
failing... Hope it didn't make your night much later.
Rgds,
John
-Original Message-
From: Bill Siggelkow [mailto:[EMAIL PROTECTED]
Sent: 02 July 2004 04:49
To: [EMAIL PROTECTED]
Subject: Re: Map backed ActionForm, and jstl expression language
John, I apologize -- it' late and I am tired but I was having a little
trouble following your post ... however, if you have a map-backed form
(property) that you want to expose to JSTL you will need to expose the
Map itself in a getter.
Map getValuesMap() { return values; }
Then you can access the values by key in JSTL as
... translates to
myForm.getValuesMap().get("theKey");
or the key can be dynamic ...
... translates to
myForm.getValuesMap().get("foo");
HTH ... Bill Siggelkow
John Martin wrote:
> Hi all,
>
> Any help on the following problem would be most appreciated.
>
> What i am trying to do is produce a report of data in tabular form
> with filters that will reduce the report set. There can be 100's of
> different reports but by passing in a report id to a database the
> query, filters, columns and row values can be determined.
>
> So i use a map backed action form for the filter property and there
> values, this contains the methods
>
> public void setValue(String key, Object value) {
> values.put(key, value);
> }
>
> public Object getValue(String key) {
> return values.get(key);
> }
>
> For example, i want the first filter to have a value of 1, so i
> setValue("filter1","1") and the second filter to be value 2
> (setValue("filter1","1")).
>
> Now i populate another bean with the filter labels and values, that
> gets stored in the request. These are filter lists are stored as array
lists in a hashmap with the the key, being the filter property, in this case
"filter1" and "filter2".
>
> So in the jsp i write
>
>
>
>
>
>
>
>
> this gets me the all the filters that have been stored in the hashmap
> from the object "dao" via the property hmOfLists, with the key in the
> hashmap being the filter property. However, i want to set the defaults
> on the filters via the map backed action form, but if i write
> , i get an error of "No getter
> method available for property filter2..etc". So i try an access
> the value, in the html-el:select using the expression
> value="${testForm.props}", but this shouldn't (and doesn't work) as
> label is actually the variable props from the hashmap, not the
> property props from the testForm. How i can i make it use the var
> props instead of the string literal, in order to determine the
> property to retrieve from the map based action form ?
>
> Thanks,
>
> John
>
>
>
>
>
>
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]