1 25 26 package net.killingar.forum.tags; 27 28 import net.killingar.forum.internal.Group; 29 import net.killingar.forum.internal.managers.ForumManager; 30 import net.killingar.forum.internal.managers.OptionsManager; 31 32 import javax.servlet.jsp.JspException ; 33 import javax.servlet.jsp.JspTagException ; 34 35 public class GroupTag extends webwork.view.taglib.WebWorkTagSupport 36 { 37 private String value = null; 38 39 public void setValue(String value) { this.value = value; } 40 41 public int doStartTag() throws JspException 42 { 43 try 44 { 45 ForumManager manager = (ForumManager)pageContext.getSession().getAttribute("manager"); 46 OptionsManager options = (OptionsManager)manager.getManager(OptionsManager.class.getName()); 47 48 Group group = null; 49 50 { 51 Object o = getStack().findValue(value); 52 53 if (o instanceof Group) 54 group = (Group)o; 55 else if (o instanceof String ) 56 { 57 try 58 { 59 group = manager.getGroup(Long.parseLong((String )o)); 60 } 61 catch (Exception e) 62 { 63 group = null; 64 } 65 } 66 else if (o instanceof Long ) 67 { 68 group = manager.getGroup(((Long )o).longValue()); 69 } 70 else if (o instanceof Integer ) 71 { 72 group = manager.getGroup(((Integer )o).intValue()); 73 } 74 } 75 76 if (group == null) 77 { 78 pageContext.getOut().print("all"); 79 } 80 else 81 { 82 pageContext.getOut().print("<a HREF=\"/groups.jsp?view="); 83 pageContext.getOut().print(group.getId()); 84 pageContext.getOut().print("\" target=\"_self\">"); 85 86 pageContext.getOut().print(group.getName()); 87 88 pageContext.getOut().print("</a>"); 89 } 90 } 91 catch (Exception ex) 92 { 93 ex.printStackTrace(new java.io.PrintWriter (pageContext.getOut())); 94 } 95 96 return SKIP_BODY; 97 } 98 99 public int doEndTag() throws JspTagException 100 { 101 return EVAL_PAGE; 102 } 103 } 104 | Popular Tags |