Murray Collingwood wrote:
Hello all
Has anybody successfully used Stuts tags and Custom tags together?
For example:
Consider a custom tag with the following code:
out.println("<html:link action=\"Update.do\">" + entry[ix] + "</html:link>");
>
The custom tag appears to write the output directly to the socket without further Struts
tag evaluation, consequently the HTML source on the browser includes "html:link" which
it doesn't understand.
This says 'write the text "<html:link ..." to the HTTP response', as you
say. It seems that what you are trying to do is create a custom tag which
outputs JSP source, which you then want processed as if it had appeared
literally in the JSP page. In other words, you want to write '<x:mytag/>'
in the JSP and have the rendered result be as if you'd actually written
'<html:link ...'. Is that right?
1. How about writing the link using <a href=/WEB-INF/pages/update.jsp>....</a>
When I do this I lose the connection to my current session. Not a solution.
What do you mean by 'loose the connection to my current session?' Do you
mean that when the link is clicked the resulting request isn't associated
with the session? If cookies are enabled it should be, but if cookies are
turned off you need to include the session ID in the URL the same as Struts
and JSTL tags do.
2. Try return true in the "theBodyShouldBeEvaluatedAgain" method.
I tried this and the code got into a loop (I believe this simply recurses back through my
code). If I am supposed to use this somebody will need to tell me a simple way of
stopping the recursion.
Evaluate Body is used when you want the body of the tag to be evaluated,
not when you want the /output/ of the tag to be evaluated. Think, for
example, of forEach and the like.
3. The only other alternative I have is to look into the Struts source code and try and
find some internal method to call to evaluate the generated code before I print it to the
socket.
I think it would help to take a step back and describe the overall problem
you're trying to solve. If I understand you correctly, you're trying to
write a custom tag that generates JSP source code and have that generated
JSP code evaluated inline as part of the same processing cycle that calls
your custom tag. I suspect there are easier ways to do what you need...
If all you want to do is include a link in the HTML (not JSP) markup
generated by your tag and ensure that link includes JSESSIONID when needed,
try looking at the code for the <html:link/> tag to see how the session ID
and URL rewriting is handled.
HTH,
L.
--
Laurie Harper
Open Source advocate, Java geek: http://www.holoweb.net/laurie
Founder, Zotech Software: http://www.zotechsoftware.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]