struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bueno Carlos M <>
Subject RE: [Q] Presentation of confirmation information that is meaningf ul to user?
Date Fri, 07 Mar 2003 20:22:43 GMT
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"
    <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

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. :) 


-- los

-----Original Message-----
From: Rick Reumann []
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:
For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message