You read my mind. This does seem to work:
${formBean[prop1][prop2]}
where prop1 and prop2 are Strings defined in a scriptlet as "userInfo" and
"firstName", respectively.
Apparently the dot notation can't be used in a dynamic expression. Not sure
why, you would think that it would.
-Orig
Really the only way to do this is by modifying your own tag to
incorporate the functionality of the Struts tags. It's not possible to
output JSP code from a tag and have that evaluated. We had the same
discussion a couple of days ago in a separate thread:
http://www.mail-archive.com/taglibs-user%4
I wonder if you need something like this:
${formBean[layoutObject.property][layoutObject.property2]}
Where "layoutObject.property" is "userInfo" and "layoutObject.property2"
is "firstName".
That will obviously be a litter harder to construct, but determining
whether this works would be one ste
Yep.
Option 1:
I don't know where userInfo.firstName came from but
it says something about
operator[] (null)
like the getProperty method is returning null.
You could ensure what it's returning via a (and commenting the
problematic tag)
Option 2:
getProperty is returning "userInfo.firstName"
and
We must be close. I tried this:
(Assume that layoutObject.property evaluates to a String of
userInfo.firstName)
And the container threw this exception:
[ServletException in:/jsp/registration/registerDisplay.jsp] An error
occurred while evaluating custom action attribute "value" with value
from http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html | Chapter 12
| EL | Variables
The JSP expression language unifies the treatment of the . and []
operators. expr-a.expr-b is equivalent to a["expr-b"]; that is, the
expression expr-b is used to construct
if you have a property in any bean you can write this:
myBean.theProperty
or
myBean['theProperty']
(I didn't use it but reading a tutorial it was a big surprise for me).
So, you could change this:
String expr = "formBean." +
((app.LayoutObject)pageContext.getAttribute("layoutObject")).getProperty()
Hi Kalki,
I understood u r approach of programming. Some time back I have written
a
Custom that outputs a string like this "" .during
the servlet compilation time this will be evaluated as string not as a
tag.
You can achieve this by extending the struts tag Select and Override the
method render
Hello,
I'm using the Struts-EL and JSTL custom tag implementations in my Web app.
I want to use the c:out tag to output dynamic data. The tricky part is I
want to dynamically build the EL expression at runtime by building up a
String that should be evaluated. I don't want to output the String,
Hi,
I have written a customized taglib and there is a tag say ABC.
If my tag ABC returns a struts tag embedded in the writer output (here
in this example html taglib) for a page, then can JSP container evaluate
this tag?
Example... my tag ABC evaluates to:
I have used TagSu
10 matches
Mail list logo