You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Lev Pelekh <pe...@digitalroot.com> on 2002/04/02 03:29:14 UTC

Question on processing forms with dynamic field names using taglibs

Hello everyone,

I am new, so the usual preemptive apologies are in order. I am attempting to
process a form in which I am constructing field names at runtime. I can't
seem to be able to do that with any of Jakarta Taglibs without resorting to
scriplets. Request taglib seems to have no capability for dynamic parameter
names. JSTL has dynamic parameter names, but the expression language lacks
any kind of string manipulation, including concatenation, thus rendering it
useless for my application.

The answer may be that determining field names at runtime is bad design.
Consider the following example:

A form allows the user to choose from a list of sandwiches. Multiple can be
chosen. For each, the user can check options like lettuce and tomato (man,
sounds good :) ). Thus there's a list with "Select", "Lettuce" and "Tomato"
checkboxes next to each.

The simplest way to process such form, it seems, is to name all "Select"
boxes the same, e.g. "sandIDs", and assign the actual sandID as values.
Lettuce and tomato is named "letuce"+sandID and "tomato"+sandID accordingly.

Thus when processing the form, we can iterate over the values of the field
"sandIDs" to determine which sandwiches were selected, and retrieve
properties of each sandwich via concatenation of the current sandID and
proper suffix (e.g. "tomato").

Pseudocode just in case:

for each foo in parameter "sandID"
	retrieve value of parameter named ("sandID"+foo);

As I have mentioned, I was unable to express pseudocode above neither via
Request Taglib nor JSTL. Any help is highly appreciated.

Lev.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>