1 package net.simya.ldap.taglib; 2 3 import javax.servlet.jsp.tagext.*; 4 import javax.servlet.jsp.*; 5 import javax.naming.NamingException ; 6 import javax.naming.directory.DirContext ; 7 import javax.naming.directory.Attribute ; 8 import net.simya.ldap.beans.*; 9 import net.simya.ldap.servlet.*; 10 11 public class ModifyAttribute 12 extends TagSupport 13 { 14 private static final String DEFAULT_DELIMITER = ", "; 15 private static final String DEFAULT_MIMETYPE = "text/plain"; 16 private static final String DEFAULT_MIMETEXT = "text"; 17 private static final int DEFAULT_INDEX = -1; 18 private static final String DEFAULT_VALUE = ""; 19 20 private String name = null; 21 private String value = null; 22 private String modType= null; 23 private String mimeType = DEFAULT_MIMETYPE; 24 25 public int doStartTag() 26 throws JspException 27 { 28 Modify modifyTag = (Modify) getParent(); 29 30 if ( modifyTag == null ) 31 throw new JspTagException( "<modify attribute> tag should be child node of <modify> tag." ); 32 33 if (modType.equalsIgnoreCase("add")) 34 modifyTag.setAttribute(name,value, DirContext.ADD_ATTRIBUTE); 35 if (modType.equalsIgnoreCase("replace")) 36 modifyTag.setAttribute(name,value, DirContext.REPLACE_ATTRIBUTE); 37 if (modType.equalsIgnoreCase("remove")) 38 modifyTag.setAttribute(name,value, DirContext.REMOVE_ATTRIBUTE); 39 40 return EVAL_BODY_INCLUDE; 41 } 42 43 public void release() 44 { 45 name = null; 46 value = null; 47 modType = null; 48 mimeType = DEFAULT_MIMETYPE; 49 } 50 51 public String getName() { return this.name; } 52 public void setName(String name) { this.name = name; } 53 54 public String getValue() { return this.value; } 55 public void setValue(String value) { this.value = value; } 56 57 public String getType() { return this.modType; } 58 public void setType(String modType) { this.modType = modType; } 59 60 public String getMimeType() { return this.mimeType; } 61 public void setMimeType(String mimeType) { this.mimeType = mimeType; } 62 } | Popular Tags |