01: package org.gridsphere.provider.portletui.tags;
02:
03: import org.gridsphere.provider.portletui.beans.ActionMenuItemBean;
04:
05: import javax.servlet.jsp.JspException;
06: import javax.servlet.jsp.JspWriter;
07: import javax.servlet.jsp.tagext.Tag;
08:
09: /*
10: * @author <a href="mailto:oliver.wehrens@aei.mpg.de">Oliver Wehrens</a>
11: * @version $Id: ActionMenuItemTag.java 6385 2007-10-25 14:02:26Z wehrens $
12: */
13:
14: public class ActionMenuItemTag extends ContainerTag {
15:
16: protected boolean isSelected = false;
17: protected boolean seperator = false;
18: protected ActionMenuItemBean actionMenuItemBean = null;
19:
20: public boolean isSelected() {
21: return isSelected;
22: }
23:
24: public void setSelected(boolean selected) {
25: isSelected = selected;
26: }
27:
28: public boolean isSeperator() {
29: return seperator;
30: }
31:
32: public void setSeperator(boolean seperator) {
33: this .seperator = seperator;
34: }
35:
36: public int doStartTag() throws JspException {
37:
38: if (!beanId.equals("")) {
39: actionMenuItemBean = (ActionMenuItemBean) getTagBean();
40: if (actionMenuItemBean == null) {
41: actionMenuItemBean = new ActionMenuItemBean();
42: }
43: } else {
44: actionMenuItemBean = new ActionMenuItemBean();
45: }
46:
47: // set info if not already set and we have something to set
48: //if (info!=null && actionMenuItemBean.getInfo()==null) actionMenuItemBean.setInfo(info);
49:
50: Tag parent = getParent();
51: if (parent instanceof ActionMenuTag) {
52: ActionMenuTag actionMenuTag = (ActionMenuTag) parent;
53: if (actionMenuTag.getLayout() != null)
54: actionMenuItemBean.setAlign(actionMenuTag.getLayout());
55: if (actionMenuTag.getMenutype() != null)
56: actionMenuItemBean.setMenutype(actionMenuTag
57: .getMenutype());
58: actionMenuItemBean.setSelected(isSelected);
59: }
60: String beanString = actionMenuItemBean.toStartString();
61: // Print the string
62: try {
63: pageContext.getOut().print(beanString);
64: } catch (Exception e) {
65: throw new JspException(e.getMessage());
66: }
67:
68: return EVAL_BODY_INCLUDE;
69: }
70:
71: public int doEndTag() throws JspException {
72:
73: try {
74: JspWriter out = pageContext.getOut();
75: out.print(actionMenuItemBean.toEndString());
76: } catch (Exception e) {
77: throw new JspException(e.getMessage());
78: }
79:
80: return EVAL_PAGE;
81: }
82: }
|