At 5:36 PM +0000 2/23/05, Daniel Perry wrote:
I've spent the last couple of hours trying to debug a page with mapped
properties.

I found a section of the faq about it:
http://struts.apache.org/faqs/indexedprops.html

It says:
"The signature of the "get" and "set" methods for a mapped property are
different from the same methods for an indexed property. In particular,
instead of an "int" for the index, there is a "String" for the key." and the
example shows these methods...

But this doesnt work!!!!!!!!

That's not true; what is specified there works for the commons-beanutils tool, which is the thing that knows how to find mapped properties with introspection.


To read the field, it requires a get method like:
    public Map getDate() {
        return dateMap;
    }

For it to write the fields it needs a set method like:
    public void setDate(Map date) {
        this.dateMap=date;
    }

This may be the case if you want to use JSTL expressions to retrieve values from the map, as in
<c:out value="${myObj.date['key']" /> but it doesn't impact commons-beanutil's introspection. I know this because I've used "mapped properties" as a cheap way to parameterize date formatting, back before the JSTL and before even the Struts tags supported a 'format' attribute.


public String getFormattedDate(String pattern) {
        ... typical SimpleDateFormat stuff
}

<bean:write name="myObj" property="formattedDate(YYYY-mm-dd)" />

Joe

--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "Narrow minds are weapons made for mass destruction" -The Ex


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



Reply via email to