File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is getValue(String) in custom tag?

 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3226
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The J2EE Javadoc documentation is a separate download... The online Doc is in
http://java.sun.com/j2ee/j2sdkee/techdocs/api/index.html
 
Dani Mazzuca
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic