AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Nested Tags : Jakarta Taglibs

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language Programming
View previous topic :: View next topic  
Author Message
Boni Gopalan
Guest





PostPosted: Thu Apr 29, 2004 8:55 pm    Post subject: Nested Tags : Jakarta Taglibs Reply with quote



Hi All,

I am very confused with Jakarta Documentation. It says that if I
return EVAL_BODY_AGAIN, or some other constant like that from
doAfterBody(), The Tag Body will be 'evaluated' again. What I am
expecting is, If By Tag Body Has some more custom tags, those will be
Processed by the System, and finally I will get my beautiful HTML
output. How ever it is not happening. My Inner Tags are ignored by
the system, and I get no HTML output. Evaluation of the custom Tag
happens only for one level.

Is this the expected behaviour ?, Or I am doing some blunder ?. I
feel it is a blunder from my side.

Please let me know.

Thanks
Boni



My Tag Lib File (. tld) looks like this,

##############################################################################
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag
Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>customlibrary</shortname>
<description>My controls taglibrary.</description>
<uri>/mytaglib</uri>
<tag>
<name>PERSON</name>
<tag-class>com.controltest.PersonControl</tag-class>
<description></description>
<bodycontent>JSP</bodycontent>
<attribute>
<name>name</name>
<required>false</required>
</attribute>
<attribute>
<name>age</name>
<required>true</required>
</attribute>
<attribute>
<name>phone</name>
<required>true</required>
</attribute>
</tag>
<tag>
<name>PERSONAL_INFO</name>
<tag-class>com.controltest.PersonalInfo</tag-class>
<description></description>
<bodycontent>JSP</bodycontent>
<attribute>
<name>name</name>
<required>false</required>
</attribute>
<attribute>
<name>age</name>
<required>true</required>
</attribute>
</tag>
<tag>
<name>CONTACT_INFO</name>
<tag-class>com.controltest.ContactInfo</tag-class>
<description></description>
<bodycontent>JSP</bodycontent>
<attribute>
<name>phone</name>
<required>false</required>
</attribute>
</tag>
</taglib>
##############################################################################

My JSP File is like this,

##############################################################################


<!--Generated by WebLogic Workshop-->
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
<%@ taglib uri="netui-tags-html.tld" prefix="netui"%>
<%@ taglib uri="netui-tags-template.tld" prefix="netui-template"%>
<%@ taglib uri="mytag.tld" prefix="mytag"%>
<netui:html>
<head>
<title>Web Application Page</title>
</head>
<body>
<p>
<mytag:PERSON name="Neeraj" age="64" phone="732-227-5753"/>
</p>
</body>
</netui:html>

##############################################################################

My PersonControl.java Looks like,

##############################################################################

package com.controltest;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class PersonControl extends BodyTagSupport
{
private String name = "";
private String age = "";
private String phone = "";
private BodyContent bodyContent = null;
private int check = 0;

public void setName(String name)
{
this.name = name;
}
public void setAge(String age)
{
this.age = age;
}
public void setPhone(String phone)
{
this.phone = phone;
}

public int doStartTag() throws JspException//, java.io.IOException,
Exception
{
JspWriter out = pageContext.getOut();
try
{
//out.println(" <custom:CONTACT_INFO name = " + name + " age =
" + age +"/>");
out.println("<%@ page language='java'
cont'entType='text/html;charset=UTF-8'%>");
out.println("<%@ taglib uri='netui-tags-databinding.tld'
prefix='netui-data'%>");
out.println("<%@ taglib uri='netui-tags-html.tld'
prefix='netui'%>");
out.println("<%@ taglib uri='netui-tags-template.tld'
prefix='netui-template'%>");
out.println("<%@ taglib uri='mytag.tld' prefix='mytag'%>");
out.println("<netui:html>");
out.println("<mytag:PERSONAL_INFO name='Neeraj' age='64'/>");
}
catch (Exception e){}
if (check == 0)
check = 1;
else
check = 0;
return EVAL_BODY_TAG;
}

public int doEndTag() throws JspException
{
JspWriter out = pageContext.getOut();
try
{
//out.println("</TD></TR //pageContext.getOut().write("<table border='1'><tr><td><h3>" +
name + "</h3></td></tr><tr><td>");
//out.println("</custom:CONTACT_INFO>");
//bodyContent.flush();
}
catch (Exception e)
{
throw new JspTagException(e.getMessage());
}
if (count < 2) return EVAL_BODY_AGAIN;
return SKIP_BODY;
}
private BodyContent body = getBodyContent();
public void doInitBody()
{
body = getBodyContent();
}
public void setBodyContent (BodyContent b)
{
body = b;
}
int count = 0;
public int doAfterBody()
{
count++;
if (count < 2) return EVAL_BODY_AGAIN;
return SKIP_BODY;
}

}
##############################################################################
Back to top
Christophe Vanfleteren
Guest





PostPosted: Thu Apr 29, 2004 9:10 pm    Post subject: Re: Nested Tags : Jakarta Taglibs Reply with quote



Boni Gopalan wrote:

Quote:
Hi All,

I am very confused with Jakarta Documentation. It says that if I
return EVAL_BODY_AGAIN, or some other constant like that from
doAfterBody(), The Tag Body will be 'evaluated' again. What I am
expecting is, If By Tag Body Has some more custom tags, those will be
Processed by the System, and finally I will get my beautiful HTML
output. How ever it is not happening. My Inner Tags are ignored by
the system, and I get no HTML output. Evaluation of the custom Tag
happens only for one level.

Is this the expected behaviour ?, Or I am doing some blunder ?. I
feel it is a blunder from my side.

Yes, tags don't work that way. As far as the server is concerned, anything
the tags outputs is ordinary HTML, and will not get reinterpreted.

Quote:
Please let me know.

Thanks
Boni

snip code


--
Kind regards,
Christophe Vanfleteren

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.