Being a JavaScript weenie, I would do it with the hidden field and onchange. :) Easier than anything else.
--joe > -----Original Message----- > From: Bueno Carlos M [mailto:[EMAIL PROTECTED] > Sent: Friday, March 07, 2003 12:23 PM > To: 'Struts Users Mailing List' > Subject: RE: [Q] Presentation of confirmation information that is > meaningful to user? > > > Perl/PHP/TCL weenies who take good string parsing support for granted > usually stuff the value field like so: > > <option value="501|||Accounting">Accounting</option> > > You can do this in Java with the nifty org.apache.regexp package (or > javax.regexp if you like crappy Sun JSR implementations). It > works but it > ain't pretty and it ain't bulletproof. > > Javascript weenies take the display value and put it in a > hidden field: > > <input type="hidden" name="deptName" /> > <select name="dept" > onchange="this.form.deptName.value=this.selected.text;"> > <option value="501">Accounting</option> > > Works ok, but is somewhat fragile on the browser end. > > Newbies of any language go back to the database or hard-code > the mappings > because you just don't learn unless you paint yourself into a > corner a few > times. > > If you want to be really clever, you cache it in memory. Since you are > getting the mappings from the database anyway to build your > form, stick it > in a hashtable/hashmap in session scope. Once you have that > working, figure > out how to share that cache across sessions so you don't > bloat your memory > space. Then count the number of lines you wrote and finally > realize why the > Perl/Javascript weenies do it the way they do. :) > > KISS. > > -- los > > -----Original Message----- > From: Rick Reumann [mailto:[EMAIL PROTECTED] > Sent: Friday, March 07, 2003 11:08 AM > To: Struts Users Mailing List > Subject: [Q] Presentation of confirmation information that is > meaningful > to user? > > > I'm wondering how many of you handles a typical situation > that comes up > for me: > > Say you are working on an application that requires the user > to enter in > Employee information so that it could be inserted into a database. > > You have a select options field created which displays the list of > departments and the user needs to select the appropriate one for the > Employee. Since the database cares about the department ID and not the > department name it makes sense to have the value for your options be > this "ID" and then you just display the department names from your > colleciton so that a typical option viewed as source would look like: > > <option value="501">Accounting</option> > > Obviously I then have a form bean which will hold this department ID > when the form is submitted. > > The problem I run into though is that I often want to display back > confirmation information that might include the actual department name > the user selected (displaying the id would mean nothing to the user). > > How do you guys accomplish this? > > There are several ways I can accomplish it but none of them that I'm > aware of are very pretty. > > -- > Rick Reumann > > --------------------------------------------------------------------- > 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]