1 23 24 package org.dbforms.taglib; 25 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 import org.dbforms.config.ResultSetVector; 30 31 import org.dbforms.util.MessageResources; 32 33 import javax.servlet.http.HttpServletRequest ; 34 import javax.servlet.jsp.JspException ; 35 36 37 38 45 public class DbDeleteButtonTag extends DbBaseButtonTag 46 implements javax.servlet.jsp.tagext.TryCatchFinally { 47 private static Log logCat = LogFactory.getLog(DbDeleteButtonTag.class); 48 private static int uniqueID; 49 50 static { 51 uniqueID = 1; 52 } 53 54 private String associatedRadio; 55 private String confirmMessage = null; 56 57 62 public void setAssociatedRadio(String associatedRadio) { 63 this.associatedRadio = associatedRadio; 64 } 65 66 67 72 public String getAssociatedRadio() { 73 return associatedRadio; 74 } 75 76 77 82 public void setConfirmMessage(String confirmMessage) { 83 this.confirmMessage = confirmMessage; 84 } 85 86 87 92 public String getConfirmMessage() { 93 return confirmMessage; 94 } 95 96 97 100 public void doCatch(Throwable t) throws Throwable { 101 throw t; 102 } 103 104 105 108 public void doFinally() { 109 confirmMessage = null; 110 associatedRadio = null; 111 super.doFinally(); 112 } 113 114 115 123 public int doStartTag() throws javax.servlet.jsp.JspException { 124 super.doStartTag(); 125 126 DbDeleteButtonTag.uniqueID++; 128 if (getConfirmMessage() != null) { 129 String onclick = (getOnClick() != null) ? getOnClick() 130 : ""; 131 132 if (onclick.lastIndexOf(";") != (onclick.length() - 1)) { 133 onclick += ";"; } 135 136 String message = getConfirmMessage(); 137 138 if (getParentForm() 139 .hasCaptionResourceSet()) { 140 try { 141 message = MessageResources.getMessage((HttpServletRequest ) pageContext 142 .getRequest(), 143 getConfirmMessage()); 144 } catch (Exception e) { 145 logCat.debug("confirm(" + getCaption() + ") Exception : " 146 + e.getMessage()); 147 } 148 } 149 150 setOnClick(onclick + "return confirm('" + message + "');"); 151 } 152 153 if (getParentForm() 154 .isFooterReached() 155 && ResultSetVector.isNull(getParentForm().getResultSetVector())) { 156 return SKIP_BODY; 158 } 159 160 try { 161 StringBuffer tagNameBuf = new StringBuffer ("ac_delete"); 163 164 if (associatedRadio != null) { 165 tagNameBuf.append("ar"); 166 } 167 168 tagNameBuf.append("_"); 169 tagNameBuf.append(getTable().getId()); 170 171 if (associatedRadio == null) { 172 tagNameBuf.append("_"); 173 tagNameBuf.append(getParentForm().getPositionPath()); 174 } 175 176 tagNameBuf.append("_"); 178 tagNameBuf.append(uniqueID); 179 180 String tagName = tagNameBuf.toString(); 181 182 StringBuffer tagBuf = new StringBuffer (); 184 185 if (associatedRadio != null) { 186 tagBuf.append(getDataTag(tagName, "arname", associatedRadio)); 187 } 188 189 if (getFollowUp() != null) { 190 tagBuf.append(getDataTag(tagName, "fu", getFollowUp())); 191 } 192 193 if (getFollowUpOnError() != null) { 194 tagBuf.append(getDataTag(tagName, "fue", getFollowUpOnError())); 195 } 196 197 tagBuf.append(getButtonBegin()); 198 tagBuf.append(" name=\""); 199 tagBuf.append(tagName); 200 tagBuf.append(getButtonEnd()); 201 202 pageContext.getOut() 203 .write(tagBuf.toString()); 204 } catch (java.io.IOException ioe) { 205 throw new JspException ("IO Error: " + ioe.getMessage()); 206 } 207 208 if (getChoosenFlavor() == FLAVOR_MODERN) { 209 return EVAL_BODY_BUFFERED; 210 } else { 211 return SKIP_BODY; 212 } 213 } 214 } 215 | Popular Tags |