1 package net.simya.ldap.taglib; 2 3 import javax.servlet.jsp.tagext.*; 4 import javax.servlet.jsp.*; 5 import javax.naming.Context ; 6 import javax.naming.directory.DirContext ; 7 import javax.naming.NamingException ; 8 import net.simya.ldap.beans.*; 9 10 public class Add 11 extends BodyTagSupport 12 { 13 private String dn = null; 14 private String name = null; 15 private String value= null; 16 private LdapAddEntryBean addBean = new LdapAddEntryBean(); 17 18 public int doStartTag() 19 throws JspException 20 { 21 Connect connectTag = (Connect) getParent(); 22 if ( connectTag == null ) 23 throw new JspTagException( "<add> tag should be child node of <connect> tag." ); 24 25 addBean.setDN( dn ); 26 addBean.setContext( connectTag.getContext() ); 27 28 if ( id != null ) 29 pageContext.setAttribute( id, addBean ); 30 31 return EVAL_BODY_TAG; 32 } 33 34 public int doAfterBody() 35 throws JspException 36 { 37 try 38 { 39 addBean.addEntry(); 40 41 } catch ( NamingException ex ) 42 { 43 throw new LdapTaglibException( ex ); 44 } 45 return SKIP_BODY; 47 } 48 49 public void release() 50 { 51 dn = null; 52 name= null; 53 value= null; 54 } 55 56 public String getDn() { return this.dn; } 57 public void setDn(String dn) { this.dn = dn; } 58 59 public void setAttribute(String name, String value) 60 { 61 addBean.setAddAttribute(name,value); 62 } 63 } 64 | Popular Tags |