[Help] Struts/JSP -- easy way associate an "ID" to a "Value"?

From: Russ Perry Jr (slapdash_at_rcn.com)
Date: 06/25/04


Date: 25 Jun 2004 07:52:49 -0700


(Argh, accidentally posted this to comp.lang.java instead of here...
Sorry if you've seen both posts)

I'm using "ID" and "Value" in the generic sense here...

Let's say one page I had a <html:select> with a collection like this:

<html:options collection="items" property="key" labelProperty="value"/>

In this case "key" is what I mean by "ID", and "value" is what I mean
by "Value" -- the "Value" is shown to the user, but the "ID" is what
I plan to keep, to be saved to a database (as a reference in a table
to a common table as a part of normalization). Oh, and "items" is
just a vector of a simple object with key, value & extraValue fields,
and extraValue isn't always used.

Now, what I'm running into is that they want a confirmation screen
(let's call that "Page X") -- print out the values the user has input
(on what we'll call "Page 1" and "Page 2" since we're combining two
screens for confirmation (our business model requires this as two
separate steps) and confirm before processing (i.e. saving to the
database and started business flow on it) all the data.

Now, I have easy access to the "ID" on the Page2ActionForm, but I
want to show the "Value" instead. Obviously, I can read through the
original "items" object, compare the "key" values and return the
"value" value (ugh, sorry) when found, but that seems tedious.

Is there an easy/better way to do this? Some way I can easily do
this with JSP tags? It seems <logic:iterate> is going output
everything (as I don't think I can put a <bean:write> of the
Page2ActionForm property "ID" as a value in a <logic:equal> inside
the <logic:iterate> as, from experience, it seems struts doesn't
like nesting tags :-), and I don't see any other logic or bean tag
examples that do what I'm looking for.

On the off chance the above makes sense to anyone, does anyone have
a quick & easy way, or I should I get around to writing my find
routines?



Relevant Pages

  • [Help] Struts/JSP -- easy way associate an "ID" to a "Value"?
    ... I'm using "ID" and "Value" in the generic sense here... ... to be saved to a database (as a reference in a table ... this with JSP tags? ... Page2ActionForm property "ID" as a value in a inside ...
    (comp.lang.java)
  • Re: ObjectDataSource and Linq. Please, help! I dont know what else to try. Thank You.
    ... MyDbDataContext database = new MyDbDataContext; ... 'GetTags' that has no parameters. ... in LabDataContext class using the following: ... Dim tags = From t In database.Tags _ ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: HTML doc save dialog
    ... After getting the string from database do not set the string to ... > and end html tags. ... In the document complete event of browser, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Help needed on custom tag
    ... > I need to develop a Custom tag that retrieves the values from ... > two database tables. ... > here display data from second table here display data from second table ... Although I wouldn't recommend it for production the JSTL tags provide ...
    (comp.lang.java.developer)
  • Re: LINQ. Who knows how to do this?
    ... In your database do you have relationships setup. ... When you create your LINQ ... to SQL class including all of the tables. ... Files> FilesTags> Tags ...
    (microsoft.public.dotnet.languages.csharp)