struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <k...@dotech.com>
Subject Re: Re[2]: Using the "key" of a HashMap in an html:option tag ?
Date Tue, 10 Dec 2002 22:06:26 GMT
Rick,

Glad it's working, but I don't understand why you'd have a problem with the JSP
expression. IIRC, it's equivalent to the following code getting generated within
the page's _jspService method:

// out is a javax.servlet.jsp.JspWriter instance
out.print( ((java.util.Map.Entry)element).getKey() );

Which, for an Obect argument to the print method, JspWriter treats as:

String s = String.valueOf( ((java.util.Map.Entry)element).getKey() );
byte[] buffer = s.getBytes();
for (int i = 0, n = buffer.length; i < n; i++) {
  out.write(buffer[i]);
}

Quoting Rick Reumann <maillist@reumann.net>:

> On Tuesday, December 10, 2002, 2:21:36 PM, Kris wrote:
> 
> KS> You may have to cast "element":
> 
> KS> <%= ((java.util.Map.Entry)element).getKey() %>
> 
>     Thanks Kris! Yes that's exactly what I had to do (mostly). I say
>     mostly, because so many times I've been bitten in the butt by this
>     and I'm not sure why it works this way but...
>     for some reason I often can't just use the scriplet: <%=
>     to force a String conversion, when inside of a tag. I forget
>     I have to do:
>     <% String.valueOf( ) %>.
>     So in the above I think I tried something
>     like you mentioned but then realized it only works for me when I
>     do:
>     value="<% String.valueOf( ((java.util.Map.Entry)element).getKey() ) %>"
> 
>     Appreciate you coming up with the solution. I was pulling my hair
>     out over this.
> 
> -- 
> 
> Rick
> mailto:maillist@reumann.net
> 
> 
> --
> To unsubscribe, e-mail:  
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
> 


-- 
Kris Schneider <mailto:kris@dotech.com>
D.O.Tech       <http://www.dotech.com/>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message