You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Frederic Simard <fs...@datacom.net> on 2001/11/26 17:38:32 UTC

A small idea tath could make our life easier

 
Hi my name is Frederic Simard, I am whroting to you, to show you a Idea
that I got for the next JSP specification:
 
The Idea consit to create taglib mecanism  similar to jsp to be able to
embed scrip in java code. To explain my self  I have  include a small 
Example  that will show you wath I mean.  That concept is very similar
to object oriented programming  because 
It make possible to reuse script like a object or to do scripting inside
a object. 
 
 
Fist you create a tsf (tag script file) file(something like a jsp page: 
 
<%@ page extends="javax.servlet.jsp.tagext.TagSupport" %>
<%@ page import="javax.servlet.jsp.JspException" %>
<%!
private String name;
 
public void setName(String name) {
    this.name = name;
}
 
public int doStartTag() throws JspException {
%>
<html>
<head>
<title>
<%= name%>
</title>
</head>
<body>
</body>
</html>
<%!
return SKIP_BODY;
}
%>
 
 
then you create a tld file:
 
 
<?xml version="1.0" encoding="ISO-8859-1" ?>
 
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library
1.1//EN" "http://java.sun.com/j2ee/web-jsptaglibrary_1_1.dtd">
 
<taglib>
  <tlibversion>1.0</tlibversion>
  <jspversion>1.1</jspversion>
  <shortname>Tag Library</shortname>
  <uri></uri>
  <info> ... </info>
 
  <tag>
    <name>html</name>
    <tagclass>there you could writhe the tsf file name </tagclass>
    <bodycontent>empty</bodycontent>
    <info></info>
 
    <attribute>
                    <name>name</name>
                    <required>true</required>
                    <rtexprvalue>true</rtexprvalue>
    </attribute>
 
  </tag>
</taglib>
 
 
after it you could use the tag in a Jsp file like this: 
 
<%@ page language="java" %>
<%@ taglib uri='../WEB-INF/taglib/demo.tld' prefix='util' %>
 
<util:html name="Example" />
 
 
and the generate file for the tsf file could look like this:
 
package ...;
 
import ...
 
 
public class demo extends javax.servlet.jsp.tagext.TagSupport{
        
        public void setName(String name) {
            this.name = name;
        }
        
        public int doStartTag() throws JspException {
            out.write("<html><head><title>"+ name
+"</title></head><body>/body>/html>");
            return SKIP_BODY;
        }
        
        private String name;
}
 
 
This is a simple example but for more complex object that tool could be
very useful to let the designer change le look 
And feel easily. 
 
ps: Excuse my English writing
 
 
Best regard

Re: A small idea tath could make our life easier

Posted by Konstantin Priblouda <kp...@yahoo.com>.
--- Frederic Simard <fs...@datacom.net> wrote:
>  
> Hi my name is Frederic Simard, I am whroting to you,
> to show you a Idea
> that I got for the next JSP specification:

This is better submited to JSP group at sun. 
They are in charge of JSP spec. 

I'm not sure that your proposal will made JSP easier.
It's already a mess which is very difficult to debug,
and understand for designers. 
( and has other problems best explained here:
http://jakarta.apache.org/velocity/ymtd/ymtd.html )


regards,


=====
Konstantin Priblouda ( ko5tik )    Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >

__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>