JSP and JSTL Tutorials - Tutorial Addendum - JSP Tag Aspect Administration

arcadegamesios wordgamesios lifestyleappsios
 31 December 18:00   

    



    



    

(Continued from antecedent part...)

    



    

Tag Aspect Amount Blazon Conversion

    



    

In my antecedent example, the aspect amount is anesthetized to the tag item property

    

as a cord data type. Can we canyon aspect ethics to tag item as additional data types

    

or objects? The acknowledgment is yes. JSP tag addendum ability will try to catechumen attribute

    

values to the data types of the tag item properties. I couldn t acquisition any official

    

specifications on the bout rules. The afterward is my guesses:

    



        

  • Match the aspect name to the setter adjustment of a acreage with the aforementioned name

        

    in the tag object.

        



  •     

  • If the data blazon of the ascribe constant of the setter adjustment is a archaic

        

    data type, like "long",

        

    give the aspect amount as accurate data to the ascribe parameter.

        



  •     

  • If the data blazon of the ascribe constant of the setter adjustment is the adhesive chic

        

    of a archaic data type, like "Long",

        

    instantiate an item of that chic with the aspect amount

        

    as a Cord ascribe to the constructor, and accord the new item to the ascribe parameter.

        



  •     

  • If the data blazon of the ascribe constant of the setter adjustment is the Cord class,

        

    give the aspect amount as cord accurate to the ascribe parameter.

        



  •     

  • If the data blazon of the ascribe constant of the setter adjustment is any additional class,

        

    unknown behavior.

        



  •     



    



    

Tag Aspect Amount Blazon About-face Archetype - AttValueTag.java

    



    

Here is an archetype of to appearance you how JSP tag addendum ability is converting the

    

attribute ethics to the tag s setter methods appropriate data types.

    



    

The tag class:

    

 

    

/**

    

* AttValueTag.java

    

* Absorb (c) 2003 by Dr. Yang. All rights reserved.

    

*/

    

package ;

    

import java.io.*;

    

import javax.servlet.jsp.*;

    

import javax.servlet.jsp.tagext.*;

    

public chic AttValueTag extends TagSupport {

    

clandestine continued longValue = 0;

    

clandestine Continued longObject = null;

    

clandestine bifold doubleValue = 0.0;

    

clandestine Bifold doubleObject = null;

    

clandestine boolean booleanValue = true;

    

clandestine Boolean booleanObject = null;

    

clandestine Cord stringObject = null;

    

accessible abandoned setLongValue(long val) {

    

longValue = val;

    

}

    

accessible abandoned setLongObject(Long obj) {

    

longObject = obj;

    

}

    

accessible abandoned setDoubleValue(double val) {

    

doubleValue = val;

    

}

    

accessible abandoned setDoubleObject(Double obj) {

    

doubleObject = obj;

    

}

    

accessible abandoned setBooleanValue(boolean val) {

    

booleanValue = val;

    

}

    

accessible abandoned setBooleanObject(Boolean obj) {

    

booleanObject = obj;

    

}

    

accessible abandoned setStringObject(String obj) {

    

stringObject = obj;

    

}

    

accessible int doStartTag() {

    

JspWriter out = pageContext.getOut();

    

try {

    

out.println("longValue = "+longValue+"<br/>");

    

out.println("longObject = "+longObject+"<br/>");

    

out.println("doubleValue = "+doubleValue+"<br/>");

    

out.println("doubleObject = "+doubleObject+"<br/>");

    

out.println("booleanValue = "+booleanValue+"<br/>");

    

out.println("booleanObject = "+booleanObject+"<br/>");

    

out.println("stringObject = "+stringObject+"<br/>");

    

} bolt (IOException e) {

    

System.err.println(e.toString());

    

}

    

acknowledgment SKIP_BODY;

    

}

    

}

    



    



    

The TLD file:

    

 

    

<?xml version="1.0"?>

    

<!DOCTYPE taglib Accessible

    

"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"

    

"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_2.dtd">

    

<!-- HyTaglib.tld

    

Absorb (c) 2003 by Dr. Yang

    

-->

    

<taglib>

    

<tlib-version>1</tlib-version>

    

<jsp-version>1.2</jsp-version>

    

<short-name> s Tag Library</short-name>

    

<tag>

    

<name>attValue</name>

    

<tag-class>.AttValueTag</tag-class>

    

<body-content>empty</body-content>

    

<attribute>

    

<name>longValue</name>

    

<required>false</required>

    

</attribute>

    

<attribute>

    

<name>longObject</name>

    

<required>false</required>

    

</attribute>

    

<attribute>

    

<name>doubleValue</name>

    

<required>false</required>

    

</attribute>

    

<attribute>

    

<name>doubleObject</name>

    

<required>false</required>

    

</attribute>

    

<attribute>

    

<name>booleanValue</name>

    

<required>false</required>

    

</attribute>

    

<attribute>

    

<name>booleanObject</name>

    

<required>false</required>

    

</attribute>

    

<attribute>

    

<name>stringObject</name>

    

<required>false</required>

    

</attribute>

    

</tag>

    



    

</taglib>

    



    

(Continued on next part...)

    



    

 


Tags: example, class, value, method, attribute, notes, facility, public, string, tutorial, tutorials, object

 attribute, required, public, input, class, println, private, parameter, false<, string, object, setter, value, method, version, booleanvalue, booleanobject, boolean, stringobject, longvalue, doubleobject, double, longobject, doublevalue, attvaluetag, taglib, example, import, , < attribute, attribute <, name <, < name, public void, false< required, required false<, required <, input parameter, data type, < required, attribute value, setter method, jsp tag, tag attribute, tag object, null private, give the, tag class, < tag, required false< required, < required false<, data type like, type like long, import javax servlet, primitive data type, tag extension facility, tutorials tutorial notes, tag attribute handling, tag attribute value, attribute value type, jstl tutorials tutorial,

Share JSP and JSTL Tutorials - Tutorial Addendum - JSP Tag Aspect Administration:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Permalink
Article In : Computers & Technology  -  jsp