1 13 package info.magnolia.cms.taglibs; 14 15 import info.magnolia.cms.beans.config.ContentRepository; 16 import info.magnolia.cms.gui.control.Button; 17 import info.magnolia.cms.util.Resource; 18 19 import javax.servlet.http.HttpServletRequest ; 20 import javax.servlet.jsp.JspException ; 21 import javax.servlet.jsp.tagext.TagSupport ; 22 23 24 28 public class ButtonTag extends TagSupport { 29 30 33 private static final long serialVersionUID = 222L; 34 35 38 private String dialogName = "xxx"; 39 40 43 private String label; 44 45 48 private String position; 49 50 54 public void setDialogName(String dialogName) { 55 this.dialogName = dialogName; 56 } 57 58 62 public void setLabel(String label) { 63 this.label = label; 64 } 65 66 70 public void setPosition(String position) { 71 this.position = position; 72 } 73 74 77 public int doEndTag() throws JspException { 78 79 BarTag bartag = (BarTag) findAncestorWithClass(this, BarTag.class); 80 if (bartag == null) { 81 throw new JspException ("button tag should be enclosed in a mainbar or newbar tag"); 82 } 83 84 HttpServletRequest request = (HttpServletRequest ) pageContext.getRequest(); 85 86 Button button = new Button(); 87 button.setLabel(label); 88 button.setOnclick("mgnlOpenDialog('" 89 + Resource.getActivePage(request).getHandle() 90 + "','','','" 91 + dialogName 92 + "','" 93 + ContentRepository.WEBSITE 94 + "')"); 95 96 if ("right".equalsIgnoreCase(position)) { 97 bartag.addButtonRight(button); 98 } 99 else { 100 bartag.addButtonLeft(button); 101 } 102 103 return EVAL_PAGE; 104 } 105 106 109 public void release() { 110 super.release(); 111 this.dialogName = null; 112 this.label = null; 113 this.position = null; 114 } 115 116 } 117 | Popular Tags |