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 Nic Werner <ni...@link11.net> on 2003/12/05 02:27:30 UTC

Indexing variables

Hi,
   I'm sure this is a forest for the trees problem, but I could use some
help here:

   I have an outlet table in my database, and each outlet has a color.
Typically, an outlet has three colors, meaning three entries with the
same outlet name, different info and different color.

I am creating an 'Update/Edit' page that has a forTokens loop to edit all
three colors on the same page

<c:forTokens items="B,O,G" delims="," var="color">

that queries the database for that color and displays the information
about it

Problem:
    I want to pass over this to another page that will take the
information and for the correct color, do an SQL update ie:

 update outlet set blah where outlet='###' and color='RESPECTIVE COLOR'

- Since the 'select' tags all have the same name, I thought about using a
paramValues loop and iterate through each one, but I would need a seperate
array for colors and have it iterate each time, how do I do that in JSTL?

- I also thought about throwing the color into the select tag:

<input type="text" name="<c:out value ="${color}"/>switch" value="<c:out
value="${result.rows[0].switchip}"/>">

and doing the same on the other end, which did not work:

<sql:param value="${param.<c:out value="${color}"/>switch}"/>




Or is there some way that I'm too frazzled to see?

Thanks,

- Nic







---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Indexing variables

Posted by Martin van Dijken <su...@windgazer.nl>.
Hey Nic,

First of all if you have some concrete code, please supply it. Helps a 
lot in understanding exactly what you mean...

>    I have an outlet table in my database, and each outlet has a color.
> Typically, an outlet has three colors, meaning three entries with the
> same outlet name, different info and different color.
> 
> I am creating an 'Update/Edit' page that has a forTokens loop to edit all
> three colors on the same page
> 
> <c:forTokens items="B,O,G" delims="," var="color">
> 
> that queries the database for that color and displays the information
> about it
> 
> Problem:
>     I want to pass over this to another page that will take the
> information and for the correct color, do an SQL update ie:
> 
>  update outlet set blah where outlet='###' and color='RESPECTIVE COLOR'
> 
> - Since the 'select' tags all have the same name, I thought about using a
> paramValues loop and iterate through each one, but I would need a seperate
> array for colors and have it iterate each time, how do I do that in JSTL?

What 'select' tags?

> - I also thought about throwing the color into the select tag:
> 
> <input type="text" name="<c:out value ="${color}"/>switch" value="<c:out
> value="${result.rows[0].switchip}"/>">
> 
> and doing the same on the other end, which did not work:
> 
> <sql:param value="${param.<c:out value="${color}"/>switch}"/>

This is a simple one. Using <c:out> in a html statement will work. On 
the server, the <c:out> is parsed and the web browser just sees the 
value it created. In the sql:param however, this cannot work. The JSP 
parser has to parse both the <c:out> and the <sql:param>. So you cannot 
nest tags within tags. What might work would be:

<sql:param value=""${param.color}switch"/>

> Or is there some way that I'm too frazzled to see?

Think the above way will work nicely, but you could also put the color 
you're currently editing in the session using <c:set/> and then retrieve 
it using <c:out> or something.

G'Luck!

Martin


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org