01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.desktop.taglib.container.table;
06:
07: import javax.servlet.jsp.JspException;
08: import javax.servlet.http.HttpServletRequest;
09: import java.util.List;
10: import java.util.Map;
11:
12: import com.sun.portal.desktop.util.Integers;
13:
14: import com.sun.portal.desktop.taglib.BaseDesktopTagSupport;
15: import com.sun.portal.desktop.taglib.DesktopTaglibException;
16: import com.sun.portal.desktop.taglib.DesktopTaglibConstants;
17: import com.sun.portal.providers.ProviderException;
18: import com.sun.portal.providers.containers.jsp.table.JSPTableContainerProvider;
19:
20: public class GetColumnsTag extends BaseTableContainerTagSupport {
21: private int m_column = 0;
22:
23: public void setColumn(String column) throws JspException {
24: column = resolveParameter(column).toString();
25: if (column.equalsIgnoreCase("left")) {
26: m_column = JSPTableContainerProvider.LEFT;
27: } else if (column.equalsIgnoreCase("right")) {
28: m_column = JSPTableContainerProvider.RIGHT;
29: } else if (column.equalsIgnoreCase("center")) {
30: m_column = JSPTableContainerProvider.CENTER;
31: } else if (column.equalsIgnoreCase("top")) {
32: m_column = JSPTableContainerProvider.TOP;
33: } else if (column.equalsIgnoreCase("bottom")) {
34: m_column = JSPTableContainerProvider.BOTTOM;
35: } else {
36: throw new DesktopTaglibException(
37: DesktopTaglibException.INVALID_PARAMETER, column);
38: }
39: }
40:
41: public int doStartTag() throws JspException {
42: List result = null;
43: Integer index = Integers.get(m_column);
44: Map columnMap = getColumnMap();
45: result = (List) columnMap.get(index);
46:
47: processResult(result);
48: return SKIP_BODY;
49: }
50:
51: private Map getColumnMap() throws DesktopTaglibException {
52: JSPTableContainerProvider tcp = (JSPTableContainerProvider) getCurrentObj();
53: Map columnMap = (Map) getCachedObj(_ColumnMap);
54:
55: if (columnMap == null) {
56: try {
57: columnMap = tcp
58: .setupColumns((HttpServletRequest) pageContext
59: .getRequest());
60: } catch (ProviderException pe) {
61: throw new DesktopTaglibException(pe);
62: }
63: cacheObj(_ColumnMap, columnMap);
64: }
65: return columnMap;
66: }
67:
68: }
|