KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > simya > ldap > taglib > Add


1 package net.simya.ldap.taglib;
2
3 import javax.servlet.jsp.tagext.*;
4 import javax.servlet.jsp.*;
5 import javax.naming.Context JavaDoc;
6 import javax.naming.directory.DirContext JavaDoc;
7 import javax.naming.NamingException JavaDoc;
8 import net.simya.ldap.beans.*;
9
10 public class Add
11        extends BodyTagSupport
12 {
13     private String JavaDoc dn = null;
14     private String JavaDoc name = null;
15     private String JavaDoc 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 JavaDoc ex )
42         {
43             throw new LdapTaglibException( ex );
44         }
45         //body.clearBody();
46
return SKIP_BODY;
47     }
48
49     public void release()
50     {
51         dn = null;
52         name= null;
53         value= null;
54     }
55
56     public String JavaDoc getDn() { return this.dn; }
57     public void setDn(String JavaDoc dn) { this.dn = dn; }
58
59     public void setAttribute(String JavaDoc name, String JavaDoc value)
60     {
61         addBean.setAddAttribute(name,value);
62     }
63 }
64
Popular Tags