KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > improve > struts > taglib > layout > MenuItemTag


1 package fr.improve.struts.taglib.layout;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4 import fr.improve.struts.taglib.layout.util.MenuItem;
5 import fr.improve.struts.taglib.layout.util.Menu;
6
7 /**
8  * Menu tag used to specify the menu to display.
9  * The menu can be defined in the jsp page by nesting menuItem tag
10  * or taken from the repository by giving the menu name.
11  * @author: Jean-NoŽl Ribette
12  * @deprecated
13  */

14 public class MenuItemTag extends javax.servlet.jsp.tagext.TagSupport JavaDoc {
15     protected String JavaDoc key = null;
16     protected String JavaDoc link = null;
17     protected Menu menu = null;
18 public void addItem(MenuItem item) {
19     if (menu==null) menu = new Menu();
20     menu.addItem(item);
21 }
22 // TODO rewrite this
23
public int doEndTag() throws JspException JavaDoc {
24     MenuItem item = new MenuItem(key, link, menu);
25     try {
26         MenuTag menu = (MenuTag) getParent();
27         menu.addItem(item);
28     } catch (ClassCastException JavaDoc e) {
29         try {
30             MenuItemTag menu = (MenuItemTag) getParent();
31             menu.addItem(item);
32         } catch (ClassCastException JavaDoc f) {
33             try {
34                 DynMenuTag menu = (DynMenuTag) getParent();
35                 menu.addItem(item);
36             } catch (ClassCastException JavaDoc g) {
37                 throw new JspException JavaDoc("menuItem tag not in a menu or a menuItem tag");
38             }
39         }
40     }
41     return EVAL_PAGE;
42 }
43     public int doStartTag() {
44         return EVAL_BODY_INCLUDE;
45     }
46     public void release() {
47         key = null;
48         link = null;
49         menu = null;
50     }
51 public void setKey(String JavaDoc key) {
52     this.key = key;
53 }
54 public void setLink(String JavaDoc link) {
55     this.link = link;
56 }
57 }
58
Popular Tags