Monday, May 19, 2008

HTML Tag Template - Interface

     This is my first try out of Enum since Java5 came out. The trigger of this idea is that we outsourced the use of Struts along with all it's tags. So there is no easy way for us to write forms in jsp files. I won't say that my code is competitive with Struts' or any other open/share source's tags, but it will come in handy in many ways, at least it is for me.

     I started out with a simple interface.

HTMLTagTemplate.java

package net.yw.html;

import java.util.Map;

/**
 * @author KWang
 *
 */
public interface HTMLTagTemplate {
    
    public String doStart(Map<String, Object> propertyMap) throws HTMLTagException;
    
    public String doEnd();
}


HTMLTagException.java

package net.yw.html;

/**
 * @author KWang
 *
 */
public class HTMLTagException extends Exception {

    /**
     * 
     */
    private static final long serialVersionUID = -1L;

    /**
     * 
     */
    public HTMLTagException() {
    }

    /**
     * @param message
     */
    public HTMLTagException(String message) {
        super(message);
    }

    /**
     * @param cause
     */
    public HTMLTagException(Throwable cause) {
        super(cause);
    }

    /**
     * @param message
     * @param cause
     */
    public HTMLTagException(String message, Throwable cause) {
        super(message, cause);
    }

}


     In my next post, I'll talk about how to implement HTMLTagTemplate for general form tag use.

No comments: