Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Ron McLeod
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Struts
Struts Tag inside a Custom Tag
Monoj Roy
Ranch Hand
Posts: 98
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have created one custom tag and I want to use one or two
struts
tag also
inside the custom tag .
Is there any way to make use of struts tags inside of Custom tag .
I just wanted to know a way to include any tag which is inbuild in
Java
,if can be incorporated inside my custom Tag ?
Bear Bibeault
Sheriff
Posts: 67756
173
I like...
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What happened when you tried it?
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Monoj Roy
Ranch Hand
Posts: 98
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
package myTags; import javax.servlet.jsp.tagext.*; import javax.servlet.jsp.*; import javax.servlet.http.*; import java.text.*; import java.util.*; public class DateTag extends TagSupport { public int doStartTag() throws javax.servlet.jsp.JspException { HttpServletRequest req; Locale locale; HttpJspPage g; DateFormatdf; Stringdate; JspWriterout; req = ( HttpServletRequest )pageContext.getRequest(); locale = req.getLocale(); df = SimpleDateFormat.getDateInstance( SimpleDateFormat.FULL,locale ); date = df.format( new java.util.Date() ); try { out = pageContext.getOut(); out.print( date ); } catch( Exception ioe ) { throw new JspException( "I/O Error : " + ioe.getMessage() ); }//end try/catch return Tag.SKIP_BODY; }//end doStartTag() }//end DateTag
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"> <taglib> <tlibversion>1.0</tlibversion> <jspversion>1.1</jspversion> <shortname>test</shortname> <uri>http://jakarta.apache.org/struts/tags-logic</uri> <info>A simple tag library</info> <tag> <name>displayDate</name> <tagclass>myTags.DateTag</tagclass> <bodycontent>JSP</bodycontent> <info>Display Date</info> </tag> </taglib>
Following is working ... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/dateTagLib.tld" prefix="myTag" %> <html:html> <HEAD> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <META name="GENERATOR" content="IBM WebSphere Studio"> <META http-equiv="Content-Style-Type" content="text/css"> <LINK href="theme/Master.css" rel="stylesheet" type="text/css"> <TITLE></TITLE> </HEAD> <BODY> <P>Place content here.</P> <myTag:displayDate> </myTag:displayDate> </BODY> </html:html>
Following
jsp
is not working means TESTUPPER button is showing but the page
is not showing the
TEST
button ..Only one button is appearing in the page instead of two .
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/dateTagLib.tld" prefix="myTag" %> <html:html> <HEAD> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <META name="GENERATOR" content="IBM WebSphere Studio"> <META http-equiv="Content-Style-Type" content="text/css"> <LINK href="theme/Master.css" rel="stylesheet" type="text/css"> <TITLE></TITLE> </HEAD> <BODY> <P>Place content here.</P> <html:button property="TESTUPPER"></html:button> <myTag:displayDate> <html:button property="TEST"></html:button> </myTag:displayDate> </BODY> </html:html>
Pedro Erencia
Ranch Hand
Posts: 70
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
return Tag.SKIP_BODY;
A lot of people cry when they cut onions. The trick is not to form an emotional bond. This tiny ad told me:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Equal Symbol Expected?
which custom tags in struts are the most important and the most necessary?
Allow Only include
how to use 2 fmt tags? fmt:message in fmt:formatDate
tld question
More...