aspose file tools*
The moose likes Servlets and the fly likes what is getValue(String) in custom tag? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "what is getValue(String) in custom tag?" Watch "what is getValue(String) in custom tag?" New topic
Author

what is getValue(String) in custom tag?

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
This is a class from the Sun J2EE reference example. It extends TagSupport and makes several calls to getValue(String) and setValue(String, Object). What are these methods doing and/or what are they get/setting? It looks like some session or request scoped objects, but where are they coming from? Any ideas where I can find docs for classes like TagSupport (javax classes)? Thanks

public class CreateTemplateTag extends TagSupport {
public int doStartTag() {
Hashtable screens = null;
try{
// check for the template and create if it does not exist
if (templateName != null){
screens = (Hashtable)getValue("screens");
if (screens == null) {
setValue("screens", new Hashtable());
} else Debug.println("CreateTemplateTag: screens exits ");
}
} catch (Exception e){
Debug.println("CreateTemplateTag: Error in doStartTag: " + e);
}
return EVAL_BODY_INCLUDE;
}
}
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
The javax.servlet.jsp.tagext.TagSupport class has a built in Hashtable called values. Just a convenience item so that your tag can keep stuff around.
I am working from the doc files and source files included with the Tomcat servlet engine release (jakarta.apache.org) to find this out. Doesn't the J2EE release include these docs?
Bill
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
The J2EE Javadoc documentation is a separate download... The online Doc is in
http://java.sun.com/j2ee/j2sdkee/techdocs/api/index.html


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Dani Mazzuca
Ranch Hand

Joined: May 21, 2003
Posts: 70
Hi,
The TagSupport setValue(), getValue(), etc. methods are intended to be used for nested cooperating tags, to share some dynamically created objects. The enclosing tag creates an objects an puts it using setValue(). The object is available to all inner tag handlers through the use of ((TagSupport)getParent()).getValue(name). It is the same as using pageContext.getAttribute() or pageContext.setAttribute(), however, in this case it uses a private namespace for the nested tags handlers, instead of a common general one.

See “Cooperating Tags” in the J2ee tutorial http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPAdvanced8.html

Dani
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is getValue(String) in custom tag?