1 25 26 package net.killingar.forum.tags; 27 28 import net.killingar.forum.internal.managers.ForumManager; 29 import net.killingar.forum.internal.managers.OptionsManager; 30 31 import javax.servlet.jsp.JspException ; 32 import javax.servlet.jsp.JspTagException ; 33 import javax.servlet.jsp.tagext.TagSupport ; 34 35 public class SettingTag extends TagSupport 36 { 37 private String name = null, defaultValue = ""; 38 39 public int doStartTag() throws JspException 40 { 41 return SKIP_BODY; 42 } 43 44 public void setName(String name) 45 { 46 this.name = name; 47 } 48 49 public void setDefault(String d) 50 { 51 this.defaultValue = d; 52 } 53 54 public int doEndTag() throws JspTagException 55 { 56 try 57 { 58 ForumManager manager = (ForumManager)pageContext.getSession().getAttribute("manager"); 59 String s = ((OptionsManager)manager.getManager(OptionsManager.class.getName())).get(name); 60 if (s != null) 61 pageContext.getOut().print(s); 62 else 63 pageContext.getOut().print(defaultValue); 64 } 65 catch(Exception e) 66 { 67 throw new JspTagException ("Exception thrown: " + e); 68 } 69 return EVAL_PAGE; 70 } 71 } 72 | Popular Tags |