001: /*
002: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005:
006: package com.sun.portal.search.admin;
007:
008: import java.io.IOException;
009: import java.util.logging.Logger;
010:
011: import com.sun.portal.search.admin.model.URLListModel;
012: import com.sun.portal.log.common.PortalLogger;
013:
014: import com.iplanet.jato.view.RequestHandlingTiledViewBase;
015: import com.iplanet.jato.view.View;
016: import com.iplanet.jato.view.ViewBean;
017: import com.iplanet.jato.view.ViewBeanBase;
018: import com.iplanet.jato.view.TiledView;
019: import com.iplanet.jato.RequestHandler;
020: import com.iplanet.jato.model.*;
021: import com.iplanet.jato.view.event.DisplayEvent;
022: import com.iplanet.jato.view.event.RequestInvocationEvent;
023: import com.iplanet.jato.view.event.TiledViewRequestInvocationEvent;
024: import com.iplanet.jato.view.event.ChildDisplayEvent;
025: import com.iplanet.jato.view.html.StaticTextField;
026: import com.iplanet.jato.view.html.HREF;
027: import com.iplanet.jato.model.DatasetModel;
028: import javax.servlet.http.HttpServletRequest;
029: import javax.servlet.http.HttpServletResponse;
030:
031: /**
032: * This view uses model of type AMIndentedListModel to display a tree like
033: * heirarchichal data structure in expanded tree form. So when a tree is
034: * expanded its nodes are displayed as indented rows. The indentation is
035: * relative to the parent node.
036: * Each row has this structure: [checkbox]name[link]
037: * The checkbox and link can be turned on or off. Thus,those nodes which are only
038: * for labeling purpose, can have only the name displayed in the row. This view
039: * uses TiledView of JATO, and hence each row is a tile.
040: * Typicaly, the subclasses will use the link to display the properties
041: * associated with the name, and checkbox may be used for add/delete operations.
042: */
043: public class URLListView extends RequestHandlingTiledViewBase implements
044: TiledView, RequestHandler {
045: public static final String STARTPOINT_HREF = "URLText";
046: public static final String SITE_LABEL = "SiteLabel";
047:
048: // Create a Logger for this class
049: private static Logger debugLogger = PortalLogger
050: .getLogger(URLListView.class);
051:
052: public URLListView(View parent, String name) {
053: super (parent, name);
054: this .setPrimaryModelClass(URLListModel.class);
055: //setPrimaryModel((DatasetModel) getDefaultModel());
056: registerChildren();
057: }
058:
059: protected void registerChildren() {
060: registerChild(STARTPOINT_HREF, HREF.class);
061: registerChild(SITE_LABEL, StaticTextField.class);
062: }
063:
064: protected View createChild(String name) {
065: View child = null;
066:
067: if (name.equals(SITE_LABEL)) {
068: return new StaticTextField(this , SITE_LABEL, "URL:");
069: }
070: if (name.equals(this .STARTPOINT_HREF)) {
071: return new HREF(this , getURLListModel(),
072: this .STARTPOINT_HREF,
073: URLListModel.FIELD_STARTPOINT, "", null);
074: }
075:
076: throw new IllegalArgumentException("Invalid child name: "
077: + name);
078: }
079:
080: /**
081: *
082: *
083: */
084: public void beginDisplay(DisplayEvent event)
085: throws ModelControlException {
086: // Ensure the primary model is non-null; if null, it would cause
087: // havoc with the various methods dependent on the primary model
088: URLListModel model = (URLListModel) getPrimaryModel();
089: if (model == null) {
090: debugLogger.finer("PSSH_CSPSA0023");
091: throw new ModelControlException("Primary model is null");
092: }
093:
094: // The model will be executed automatically here by the base class
095: super .beginDisplay(event);
096:
097: resetTileIndex();
098: }
099:
100: /**
101: *
102: *
103: */
104: public Model[] getWebActionModels(int modelType) {
105: // Mark the BasicCustomModel instance we're bound to as auto-retrieving.
106: // This means it will automatically be executed via its retrieve()
107: // method when the tiled view begins display.
108:
109: switch (modelType) {
110: case MODEL_TYPE_RETRIEVE:
111: debugLogger.finer("PSSH_CSPSA0036");
112: return new Model[] { getURLListModel() };
113: }
114:
115: return new Model[0];
116: }
117:
118: /**
119: *
120: *
121: */
122: public URLListModel getURLListModel() {
123: return (URLListModel) getRequestContext().getModelManager()
124: .getModel(URLListModel.class);
125: }
126:
127: /**
128: * Subclasses may override to handle appropriately. This implementation
129: * forwards to itself.
130: */
131:
132: public String[] getData() {
133: URLListModel model = getURLListModel();
134: return model.getData();
135: }
136: }
|