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 com.sun.portal.search.admin.model.PopularSearchModel;
010:
011: import com.iplanet.jato.view.RequestHandlingTiledViewBase;
012: import com.iplanet.jato.view.View;
013: import com.iplanet.jato.view.ViewBean;
014: import com.iplanet.jato.view.ViewBeanBase;
015: import com.iplanet.jato.view.TiledView;
016: import com.iplanet.jato.RequestHandler;
017: import com.iplanet.jato.model.*;
018: import com.iplanet.jato.view.event.DisplayEvent;
019: import com.iplanet.jato.view.event.RequestInvocationEvent;
020: import com.iplanet.jato.view.event.TiledViewRequestInvocationEvent;
021: import com.iplanet.jato.view.event.ChildDisplayEvent;
022: import com.iplanet.jato.view.html.StaticTextField;
023: import com.iplanet.jato.view.html.HREF;
024: import com.iplanet.jato.model.DatasetModel;
025: import javax.servlet.http.HttpServletRequest;
026: import javax.servlet.http.HttpServletResponse;
027:
028: /**
029: * This view uses model of type AMIndentedListModel to display a tree like
030: * heirarchichal data structure in expanded tree form. So when a tree is
031: * expanded its nodes are displayed as indented rows. The indentation is
032: * relative to the parent node.
033: * Each row has this structure: [checkbox]name[link]
034: * The checkbox and link can be turned on or off. Thus,those nodes which are only
035: * for labeling purpose, can have only the name displayed in the row. This view
036: * uses TiledView of JATO, and hence each row is a tile.
037: * Typicaly, the subclasses will use the link to display the properties
038: * associated with the name, and checkbox may be used for add/delete operations.
039: */
040: public class PopularSearchListView extends RequestHandlingTiledViewBase
041: implements TiledView, RequestHandler {
042: public static final String FREQ_TEXT = "FreqText";
043: public static final String SCOPE_TEXT = "ScopeText";
044:
045: private PopularSearchModel model = null;
046:
047: public PopularSearchListView(View parent, String name) {
048: super (parent, name);
049: //this.setPrimaryModelClass(PopularSearchModel.class);
050: setPrimaryModel((DatasetModel) getDefaultModel());
051: registerChildren();
052: }
053:
054: protected void registerChildren() {
055: registerChild(FREQ_TEXT, StaticTextField.class);
056: registerChild(SCOPE_TEXT, StaticTextField.class);
057: }
058:
059: protected View createChild(String name) {
060: View child = null;
061: if (name.equals(FREQ_TEXT)) {
062: return new StaticTextField(this , FREQ_TEXT, "");
063: }
064: if (name.equals(SCOPE_TEXT)) {
065: return new StaticTextField(this , SCOPE_TEXT, "");
066: }
067: throw new IllegalArgumentException("Invalid child name: "
068: + name);
069: }
070:
071: /**
072: *
073: *
074: */
075: public void beginDisplay(DisplayEvent event)
076: throws ModelControlException {
077: // Ensure the primary model is non-null; if null, it would cause
078: // havoc with the various methods dependent on the primary model
079: if (model != null) {
080: this .getPrimaryModel().setSize(model.getSize());
081: }
082: resetTileIndex();
083: }
084:
085: /**
086: * return "false" when no more entries to display.
087: * return true to display the Tile, false don't display the tile
088: */
089: public boolean nextTile() throws ModelControlException {
090: boolean movedToRow = super .nextTile();
091: if (movedToRow) {
092: int index = getTileIndex();
093: setDisplayFieldValue(FREQ_TEXT, model.getFreq(index));
094: setDisplayFieldValue(SCOPE_TEXT, model.getScope(index));
095:
096: }
097: return movedToRow;
098: }
099:
100: public void setModel(PopularSearchModel m) {
101: model = m;
102: }
103:
104: }
|