• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

what is getValue(String) in custom tag?

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
}
}
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic