1 13 package info.magnolia.cms.taglibs; 14 15 import info.magnolia.cms.gui.inline.BarNew; 16 import info.magnolia.cms.i18n.MessagesManager; 17 import info.magnolia.cms.util.Resource; 18 19 import java.io.IOException ; 20 21 import javax.servlet.http.HttpServletRequest ; 22 import javax.servlet.jsp.tagext.TagSupport ; 23 24 import org.apache.commons.lang.StringUtils; 25 import org.apache.log4j.Logger; 26 27 28 32 public class NewBar extends TagSupport { 33 34 37 private static final long serialVersionUID = 222L; 38 39 private static final String DEFAULT_NEW_LABEL = "buttons.new"; 41 44 private static Logger log = Logger.getLogger(NewBar.class); 45 46 private String contentNodeCollectionName; 47 48 private String paragraph; 49 50 private String newLabel; 51 52 55 public int doStartTag() { 56 return EVAL_BODY_INCLUDE; 57 } 58 59 62 public int doEndTag() { 63 67 try { 68 this.display(); 69 } 70 catch (Exception e) { 71 log.debug("Exception caught: " + e.getMessage(), e); } 73 return EVAL_PAGE; 74 } 75 76 82 public void setContentNodeCollectionName(String name) { 83 this.contentNodeCollectionName = name; 84 } 85 86 public String getContentNodeCollectionName() { 87 return this.contentNodeCollectionName; 88 } 89 90 96 private String getPath() { 97 HttpServletRequest request = (HttpServletRequest ) pageContext.getRequest(); 98 try { 99 return Resource.getCurrentActivePage(request).getHandle(); 100 } 101 catch (Exception re) { 102 return StringUtils.EMPTY; 103 } 104 } 105 106 113 public void setParFiles(String list) { 114 this.paragraph = list; 115 } 116 117 123 public void setParagraph(String list) { 124 this.paragraph = list; 125 } 126 127 130 private String getParagraph() { 131 return this.paragraph; 132 } 133 134 140 public void setNewLabel(String label) { 141 this.newLabel = label; 142 } 143 144 147 private String getNewLabel() { 148 String defStr = MessagesManager.getMessages(this.pageContext).get(DEFAULT_NEW_LABEL); 149 return StringUtils.defaultString(this.newLabel, defStr); 151 } 152 153 159 private void display() throws IOException { 160 HttpServletRequest request = (HttpServletRequest ) pageContext.getRequest(); 161 BarNew bar = new BarNew(request); 162 bar.setPath(this.getPath()); 163 bar.setParagraph(this.getParagraph()); 164 bar.setNodeCollectionName(this.getContentNodeCollectionName()); 165 bar.setNodeName("mgnlNew"); bar.setDefaultButtons(); 167 if (this.getNewLabel() != null) { 168 if (StringUtils.isEmpty(this.getNewLabel())) { 169 bar.setButtonNew(null); 170 } 171 else { 172 bar.getButtonNew().setLabel(this.getNewLabel()); 173 } 174 } 175 bar.placeDefaultButtons(); 176 bar.drawHtml(pageContext.getOut()); 177 } 178 179 182 public void release() { 183 super.release(); 184 this.contentNodeCollectionName = null; 185 this.paragraph = null; 186 this.newLabel = null; 187 } 188 } 189 | Popular Tags |