Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use Struts2 Tag inside custom tag

 
joel mathew
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I have a custom tag and in its TagHandler class if i use
String data= "<h2>Test</h2>";
JspWriter out=pageContext.getOut();
out.print(data);
This will render the html. But in my case i want to render a struts or Jsf tag.
String data= "<s:text name=empname>Test</s:text>";
It will not render the tag!!!How can i render the tag.
In the jsp I have included <%@ taglib prefix="s" uri="/struts-tags" %>
Can somebody point me in the right direction?
Any help will be greatly appreciated!!!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, that won't render the tag; that shouldn't be surprising: *you're* creating the output for the page--it's not going to be run through the JSP processor *again*.

In your case I would go about it differently, from one of two different angles, depending your requirements. First, if you're going to be embedding custom tags, why not just use JSP 2.0 JSP-based custom tags? Then you can use whatever custom tags you want, and it's usually quite a bit easier.

Second, if that isn't an option (although it's probably the cleanest), use the getText() call within the action itself, set a scoped variable with either the results of the resource lookup or the default text, and render that inside the Java-based custom tag.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic