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:
html:select
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
Hi Kalki,
I understood u r approach of programming. Some time back I have written
a
Custom that outputs a string like this bean:message key=/ .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
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();
We must be close. I tried this:
c:out value=${formBean[layoutObject.property]}/
(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
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 c:out / (and commenting the
problematic tag)
Option 2:
getProperty is returning
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:
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.