So *thats* what a "map-backed" actionform is! lol, Ive been doing something like that for a while and been wondering if I should investigate these mysterious "map-backed" forms I keep hearing about as a potentially better alternative.
<snip> However, moving forward, JSDK version 1.4 supports LinkedHashMap, which allows the elements to be retrieved in the order they were added. If you are using Struts under Java version 1.4 and later, you can simply replace LinkedHashMap for HashMap in map-backed form and make the ordering work without adding the additional List for ordering. </snip> For those that are still stuck with 1.3 (or want to maintain compatibility with it) there is a "SequencedHashMap" class in commons-collections they can use that does pretty much the same thing. If I recall correctly commons-collections is already bundled as part of the struts distribution? :-) -----Original Message----- From: Sharad Acharya [mailto:[EMAIL PROTECTED] Sent: Thursday, 11 December 2003 12:47 To: [EMAIL PROTECTED] Subject: Handle dynamic contents using map backed form Hi all; >From Ted and others comments, it looks like some of you are trying to implement forms that should handle 'real' dynamic contents. In my recent project, I had pleasure to work handling dynamic contents in which the contents to render were not available until the time to render. DynaActionForm does not help because we need to fix form attributes in configuration element. Sooo the solution? we implemented map backed forms. I have discussed the technique in my recent JavaPro article, which you can read online in the following links: Part I: http://www.fawcette.com/javapro/2003_11/online/dynamic_sacharya_11_11_03/ Part II: http://www.fawcette.com/javapro/2003_11/online/dynamic_sacharya_11_17_03/ If you have any question about my approach, please let me know. Thanks Sharad Acharya >From: Ted Husted <[EMAIL PROTECTED]> >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >To: Struts Users Mailing List <[EMAIL PROTECTED]> >Subject: Re: When HashMap will replace ActionForm ? >Date: Wed, 10 Dec 2003 13:01:55 -0500 > >As mentioned, you can use a map-backed ActionForm to store whatever fields >you need without defining them elsewhere. > >http://tinyurl.com/ymkr > >You do need to code the forms a little differently, and your forms still >need to know what properties/entries to ask for. > >Personally, I would strongly recommnend using DynaActionForms. The overhead >of defining the elements in the configuration is negligable in practice, >and it clearly defines which properties are used with which forms. > >In practice, what really costs projects time is miscommunication. For >example, is the entry name in the Map userName or username? With >DynaActionForms all the entry names are documented in the configuration. >Otherwise, you will have to document them elsewhere and redo what has >already been done. > >I *am* a big fan of using Maps for Contexts, especially between application >layers, and with the Commons Chain influence, we're sure to see more of >that. The thing about DynaActionForms is that you get the agility of a Map >with the documentation of a JavaBean. > >HTH, Ted. > > >Antony Paul wrote: >>but it prints the form field name like this map(username). I want to get >>the >>key as name of form field. here username. possible ? >> >>rgds >>Antony Paul. >> >>----- Original Message ----- >>From: "Fullam, Jonathan" <[EMAIL PROTECTED]> >>To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> >>Sent: Wednesday, December 10, 2003 7:30 PM >>Subject: RE: When HashMap will replace ActionForm ? >> >> >> >>>That's where a map-backed Hashmap is useful. >>> >>>-----Original Message----- >>>From: Antony Paul [mailto:[EMAIL PROTECTED] >>>Sent: Wednesday, December 10, 2003 6:02 AM >>>To: Struts Users Mailing List >>>Subject: Re: When HashMap will replace ActionForm ? >>> >>> >>>I know that but one have to define 10 to 30 elements in struts-config.xml >>>for that. With a hash map one have to say whether it is needed ot not. It >>>could be accessed like DynaValidator form. And my requirement is to store >>>simple text field values. >>> >>>rgds >>>Antony Paul. >>> >>>----- Original Message ----- >>>From: "Kalra, Ashwani" <[EMAIL PROTECTED]> >>>To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >>>Sent: Wednesday, December 10, 2003 4:05 PM >>>Subject: RE: When HashMap will replace ActionForm ? >>> >>> >>> >>>>DynaValidator forms stores data in Hashmap internally if you dont want >> >>to >> >>>>define norma action forms. >>>> >>>> >>>> >>>> >>>> >>>>>-----Original Message----- >>>>>From: Antony Paul [mailto:[EMAIL PROTECTED] >>>>>Sent: Wednesday, December 10, 2003 2:40 PM >>>>>To: struts >>>>>Subject: When HashMap will replace ActionForm ? >>>>> >>>>> >>>>>Hi, >>>>> Is there any move to support HashMap in place of >>>>>ActionForm ?. I dont >>>>>want to start any argument. I have read a lot on ActionForm in >>>>>this archive. >>>>> >>>>>rgds >>>>>Antony Paul. >>>>> >>>>>--------------------------------------------------------------------- >>>>>To unsubscribe, e-mail: [EMAIL PROTECTED] >>>>>For additional commands, e-mail: [EMAIL PROTECTED] >>>>> >>>> >>>>____________________________________________________ >>>>This message contains information that may be privileged or confidential >>> >>>and >>> >>>>is the property of the Cap Gemini Ernst & Young Group. It is intended >> >>only >> >>>>for the person to whom it is addressed. If you are not the intended >>>>recipient, you are not authorised to read, print, retain, copy, >>> >>>disseminate, >>> >>>>distribute, or use this message or any part thereof. If you receive this >>>>message in error, please notify the sender immediately and delete all >>> >>>copies >>> >>>>of this message. >>>> >>>>--------------------------------------------------------------------- >>>>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] > _________________________________________________________________ Get holiday tips for festive fun. http://special.msn.com/network/happyholidays.armx --------------------------------------------------------------------- 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]