struts question - using jsp to dynamically generate value for property attribute in <html:errors/> t

J

JB

I was wondering if anyone has seen something like this before.

It could be a struts issue with jsp.... maybe the property attribute
in the <html:errors /> tag doesn't work with dynamically generated
text?

----------------------------------

I'm trying to print out a message that's saved in an ActionErrors
object.


It DOES work if I hard code it like this.

<html:errors property="partCost0" />


(it prints out Part cost must be
a number )



and it does NOT work if I use this method.

<html:errors property="partCost<%= row
%>" />

( it just has a blank space )



I've done a System.out.println on the value partCost<%= row%> with the
code

<%System.out.println(" partCost"+ row ); %>

and it does print out partCost0, partCost1, etc, for each row, so
that's not a problem.


NOTE - row is an int.


Does anyone know why the dynamically generated text won't work when the
hardcoded value will, even though the dynamic value is correct?
 
T

Tim Slattery

JB said:
I was wondering if anyone has seen something like this before.

It could be a struts issue with jsp.... maybe the property attribute
in the <html:errors /> tag doesn't work with dynamically generated
text?

----------------------------------

I'm trying to print out a message that's saved in an ActionErrors
object.


It DOES work if I hard code it like this.

<html:errors property="partCost0" />


(it prints out Part cost must be
a number )



and it does NOT work if I use this method.

<html:errors property="partCost<%= row
%>" />

You can't nest Java code within a tag. This is not a STRUTS
limitation, it's inherent in the Java Tag specification.

Use the Struts -el taglibs, which allow you to use JSTL. Then your tag
would look something like this:

<html-el:errors property="partCost${row}"/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top