I've had the same problem a couple weeks ago (look for 'Same property, 3 textfields' in the archive), and using the OgnlList from Matt Ho solved the problem completely. The only issue is that you're going to have to start using a specific List implementation, and that can be troublesome in certain cases.

Here's the code, just in case you don't wanna look up the archives:

class MyAction ... {
        private List emails = new OgnlList();
        public List getEmails() { return this.emails ; }
        ...
    }

    class OgnlList extends ArrayList {
        private Class clazz;

        public OgnlList(Class clazz) {
            this.clazz = clazz;
        }

        public synchronized Object get(int index) {
            while (index >= this.size()) {
                try {
                    this.add(clazz.newInstance());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
            return super.get(index);
        }
    }

I'm +1 for including this in XWork, or even in OGNL. This is really a great addition. What do y'all think? :)

peace,
-cv

Jason Carreira wrote:

If you named your text fields something like:

field[0].name
field[1].name

It can do indexed properties for getters and setters like:

getField(int index)
setField(int index, Field field)


-----Original Message-----
From: Anoop Ranganath [mailto:[EMAIL PROTECTED] Sent: Friday, October 17, 2003 5:18 PM
To: [EMAIL PROTECTED]
Subject: [OS-webwork] editing lists of text fields



At first I thought this would be a pain in the ass, but after reading about OGNL, I think this may actually be a lot easier. Our domain objects have some properties that are lists. Right now, we can easily display them on screen by iterating through the lists in our velocity template. However, for editing them, we click an edit button next to it, and that brings up a page with the text in a text field, and we edit from there. The other solution we thought of was put a save button next to each text field all on separate forms in the HTML.


Ideally, we'd like to be able to have a list of text fields come up on the screen, and you can edit all of them at once, click save, and have all of them persisted. It seems to do that, though, it requires a lot of legwork in giving the fields unique names, figuring out which field maps to what, etc.

Does OGNL or WW2 provide any magic to do this?

Thanks,
Anoop



-------------------------------------------------------
This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo The Event For Linux Datacenter Solutions & Strategies in The Enterprise Linux in the Boardroom; in the Front Office; & in the Server Room http://www.enterpriselinuxforum.com
_______________________________________________
Opensymphony-webwork mailing list [EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork





-------------------------------------------------------
This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
The Event For Linux Datacenter Solutions & Strategies in The Enterprise Linux in the Boardroom; in the Front Office; & in the Server Room http://www.enterpriselinuxforum.com




-------------------------------------------------------
This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
The Event For Linux Datacenter Solutions & Strategies in The Enterprise Linux in the Boardroom; in the Front Office; & in the Server Room http://www.enterpriselinuxforum.com
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to