View Javadoc
1 package com.fc.taglibs.castor; 2 3 import java.io.*; 4 import java.util.ArrayList; 5 6 import javax.naming.*; 7 8 import javax.servlet.jsp.*; 9 import javax.servlet.jsp.tagext.*; 10 11 12 import javax.naming.InitialContext; 13 import org.exolab.castor.jdo.DataObjects; 14 15 16 public class CastorJdoTag extends TagSupport { 17 18 /*** 19 * The id by which we will refer to the JDO object in the JSP page. 20 */ 21 private String id; 22 23 /*** 24 * The JNDI name of the JDO object we will use. 25 */ 26 private String jndiName; 27 28 /*** 29 * Sets the id by which this JDO instance will be referred to in the page 30 */ 31 public void setId(String _id) 32 { 33 this.id = _id; 34 } 35 36 /*** 37 * Sets the JNDI name of the JDO object so that in can be retrieved 38 */ 39 public void setJndiName(String _jndiName) 40 { 41 this.jndiName = _jndiName; 42 } 43 44 public int doStartTag() throws JspException 45 { 46 try 47 { 48 DataObjects jdo = null; 49 InitialContext ic = new InitialContext(); 50 jdo = (DataObjects) ic.lookup(this.jndiName); 51 pageContext.setAttribute(this.id, jdo); 52 } 53 catch(Exception e) 54 { 55 System.out.println(e.getMessage()); 56 e.printStackTrace(); 57 } 58 59 return EVAL_PAGE; 60 } 61 62 63 }

This page was automatically generated by Maven