1 package fr.improve.struts.taglib.layout; 2 3 import javax.servlet.jsp.JspException ; 4 import fr.improve.struts.taglib.layout.util.MenuItem; 5 import fr.improve.struts.taglib.layout.util.Menu; 6 7 14 public class MenuItemTag extends javax.servlet.jsp.tagext.TagSupport { 15 protected String key = null; 16 protected String 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 public int doEndTag() throws JspException { 24 MenuItem item = new MenuItem(key, link, menu); 25 try { 26 MenuTag menu = (MenuTag) getParent(); 27 menu.addItem(item); 28 } catch (ClassCastException e) { 29 try { 30 MenuItemTag menu = (MenuItemTag) getParent(); 31 menu.addItem(item); 32 } catch (ClassCastException f) { 33 try { 34 DynMenuTag menu = (DynMenuTag) getParent(); 35 menu.addItem(item); 36 } catch (ClassCastException g) { 37 throw new JspException ("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 key) { 52 this.key = key; 53 } 54 public void setLink(String link) { 55 this.link = link; 56 } 57 } 58 | Popular Tags |