B
Boni Gopalan
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>
<mytagERSON 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("<mytagERSONAL_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</TABLE>");
//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;
}
}
##############################################################################
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>
<mytagERSON 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("<mytagERSONAL_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</TABLE>");
//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;
}
}
##############################################################################