Sun Java System Portal Server Mobile Access 7.1 Developer's Guide

ProcedureTo Extend the Current Tag Library:

  1. Extend the Context class.


    public class NewCalContext extends CalContext {
    
      public static String CONTEXT_CLASS_NAME=
      “com.sun.portal.wireless.taglibs.cal.NewCalContext”;
    
      public static final String CONTEXT_CACHE_CLASS_NAME=
      “com.sun.portal.wireless.taglibs.cal.NewCalContextCache”;
    
      public static final String CONTEXT_TYPE = “Calendar”;
    
      protected boolean newProp = false;
    
      public void setNewProp(boolean newProp){
        Util.logMessage(“NewCalContext.setNewProp():” +
        “Setting New to” + newProp + “, instance =”+ this);
        this.newProp = newProp;
      }
    
      public boolean isNewProp(){
        Util.logMessage(“NewCalContext.isNewProp():Retrieving New=”
        + newProp + “, instance =” + this); return newProp;
      }
    
      public static CalContext getContext(PageContext pageContext)
         throws Exception {
        return (NewCalContext) Context.getContext(pageContext,
       CONTEXT_CLASS_NAME,CONTEXT_CACHE_CLASS_NAME,CONTEXT_TYPE);
      }
  2. Optionally, extend the ContextCache class.

    If your application does not need access to the original context object, extending the ContextCache class is not necessary.

    However, if your application needs access to both the new and original context, you must create a new ContextCache subclass. You do not need to override any methods.

    public class NewCalContextCache extends CalContextCache { }

  3. Write a ContextTag class that refers to the new Context subclass.

    public class NewCalContextTag extends CalContextTag {

    public NewCalContextTag()

    super();

    }

    public Context findContext() throws Exception {

    String configNameKey = NewCalContext.CONTEXT_TYPE +

    "configName";

    String ssoAdapterKey = NewCalContext.CONTEXT_TYPE +

    "ssoAdapter";

    computeConfigName(pageContext, configNameKey, ssoAdapterKey,”

    CalContext.SSO_CONFIG_TYPE);

    return NewCalContext.getContext(pageContext);

    }

    }

    Use this new ContextTag in the tld to refer to the Tag class.


    <name>context</name>
      <tagclass>
      com.sun.portal.wireless.taglibs.cal.new.NewCalContextTag
      </tagclass>
      <bodycontent>JSP</bodycontent>
      <info> New Calendar context tag </info>
      <attribute>
        <name>config</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
      </attribute>
    </tag>