1 package org.jahia.taglibs.html.actions; 2 3 import java.io.IOException ; 4 import java.util.Map ; 5 import javax.servlet.ServletRequest ; 6 import javax.servlet.jsp.JspException ; 7 import javax.servlet.jsp.JspWriter ; 8 import javax.servlet.jsp.tagext.BodyTagSupport ; 9 10 import org.jahia.data.beans.RequestBean; 11 import org.jahia.params.ParamBean; 12 import org.jahia.gui.GuiBean; 13 import org.jahia.gui.HTMLToolBox; 14 15 29 30 public class ActionMenuTag extends BodyTagSupport { 31 32 private static org.apache.log4j.Logger logger = 33 org.apache.log4j.Logger.getLogger(ActionMenuTag.class); 34 35 private boolean useFieldSet = true; 36 private String namePostFix = null; 37 private String name = null; 38 private Map actionURIBeans = null; 39 private RequestBean requestBean = null; 40 private ParamBean paramBean = null; 41 private GuiBean guiBean = null; 42 private HTMLToolBox htmlToolBox = null; 43 private String resourceBundle = null; 44 private String lockIcon = null; 45 private String actionIcon = null; 46 private String labelKey = null; 47 48 public ActionMenuTag() { 49 } 50 51 public boolean isUseFieldSet() { 52 return useFieldSet; 53 } 54 public void setUseFieldSet(boolean useFieldSet) { 55 this.useFieldSet = useFieldSet; 56 } 57 public String getNamePostFix() { 58 return namePostFix; 59 } 60 public void setNamePostFix(String namePostFix) { 61 this.namePostFix = namePostFix; 62 } 63 public String getName() { 64 return name; 65 } 66 public void setName(String name) { 67 this.name = name; 68 } 69 public String getResourceBundle() { 70 return resourceBundle; 71 } 72 public void setResourceBundle(String resourceBundle) { 73 this.resourceBundle = resourceBundle; 74 } 75 public String getLockIcon() { 76 return lockIcon; 77 } 78 public void setLockIcon(String lockIcon) { 79 this.lockIcon = lockIcon; 80 } 81 public String getActionIcon() { 82 return actionIcon; 83 } 84 public void setActionIcon(String actionIcon) { 85 this.actionIcon = actionIcon; 86 } 87 public String getLabelKey() { 88 return labelKey; 89 } 90 public void setLabelKey(String labelKey) { 91 this.labelKey = labelKey; 92 } 93 94 public int doStartTag () { 95 96 ServletRequest request = pageContext.getRequest(); 97 98 requestBean = (RequestBean) pageContext.findAttribute("currentRequest"); 99 paramBean = requestBean.getParamBean(); 100 guiBean = new GuiBean(paramBean); 101 htmlToolBox = new HTMLToolBox(guiBean, paramBean); 102 Object contentObject = pageContext.findAttribute(name); 103 if (contentObject == null) { 104 logger.error("Couldn't find any object with name " + name); 105 return EVAL_BODY_BUFFERED; 106 } 107 108 JspWriter out = pageContext.getOut(); 109 try { 110 111 htmlToolBox.drawBeginActionMenu(contentObject, lockIcon, actionIcon, useFieldSet, namePostFix, resourceBundle, labelKey, out); 112 113 } catch (IOException ioe) { 114 logger.error("IO exception while trying to display action menu for object " + name, ioe); 115 } 116 117 return EVAL_BODY_BUFFERED; 118 } 119 120 public int doAfterBody () { 122 123 JspWriter out = bodyContent.getEnclosingWriter(); 124 try { 125 bodyContent.writeOut(out); 126 } catch (IOException ioe) { 127 logger.error("Error:", ioe); 128 } 129 130 131 Object contentObject = pageContext.findAttribute(name); 132 if (contentObject == null) { 133 logger.error("Couldn't find any object with name " + name); 134 return SKIP_BODY; 135 } 136 137 try { 138 139 htmlToolBox.drawEndActionMenu(contentObject, lockIcon, actionIcon, useFieldSet, namePostFix, resourceBundle, labelKey, out); 140 141 } catch (IOException ioe) { 142 logger.error("IO exception while trying to display action menu for object " + name, ioe); 143 } 144 145 return SKIP_BODY; 146 } 147 148 public int doEndTag () 149 throws JspException { 150 useFieldSet = true; 153 namePostFix = null; 154 name = null; 155 actionURIBeans = null; 156 paramBean = null; 157 requestBean = null; 158 guiBean = null; 159 htmlToolBox = null; 160 resourceBundle = null; 161 lockIcon = null; 162 actionIcon = null; 163 labelKey = null; 164 return EVAL_PAGE; 165 } 166 167 168 } | Popular Tags |