0,0 → 1,64 |
package ak.hostadmiral.core.taglib; |
|
import javax.servlet.http.HttpServletRequest; |
import javax.servlet.jsp.JspException; |
import javax.servlet.jsp.tagext.TagSupport; |
|
import org.apache.struts.util.RequestUtils; |
|
import ak.hostadmiral.core.model.User; |
import ak.hostadmiral.core.model.ModelObject; |
|
public abstract class RightTagBase |
extends TagSupport |
{ |
protected User user; |
protected ModelObject object; |
|
protected String name; |
|
public String getName() |
{ |
return name; |
} |
|
public void setName(String name) |
{ |
this.name = name; |
} |
|
public void release() |
{ |
super.release(); |
name = null; |
user = null; |
} |
|
public int doStartTag() |
throws JspException |
{ |
user = (User)RequestUtils.lookup(pageContext, "user", "session"); |
|
Object obj = RequestUtils.lookup(pageContext, name, null); |
if(obj == null) |
throw new JspException(name + " is null"); |
if(!(obj instanceof ModelObject)) |
throw new JspException(name + " must be a ModelObject, but is " + obj.getClass()); |
|
object = (ModelObject)obj; |
|
if(condition()) |
return EVAL_BODY_INCLUDE; |
else |
return SKIP_BODY; |
} |
|
public int doEndTag() |
throws JspException |
{ |
return EVAL_PAGE; |
} |
|
protected abstract boolean condition() |
throws JspException; |
} |