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.net.URL;
010: import java.util.logging.Logger;
011:
012: import com.iplanet.jato.view.RequestHandlingTiledViewBase;
013: import com.iplanet.jato.view.View;
014: import com.iplanet.jato.view.ViewBean;
015: import com.iplanet.jato.view.ViewBeanBase;
016: import com.iplanet.jato.view.TiledView;
017: import com.iplanet.jato.RequestHandler;
018: import com.iplanet.jato.model.*;
019: import com.iplanet.jato.view.event.DisplayEvent;
020: import com.iplanet.jato.view.event.RequestInvocationEvent;
021: import com.iplanet.jato.view.event.TiledViewRequestInvocationEvent;
022: import com.iplanet.jato.view.event.ChildDisplayEvent;
023: import com.iplanet.jato.view.html.StaticTextField;
024: import com.iplanet.jato.view.html.ComboBox;
025: import com.iplanet.jato.view.html.TextField;
026: import com.iplanet.jato.view.html.OptionList;
027: import com.iplanet.jato.view.html.CheckBox;
028: import com.iplanet.jato.view.html.HREF;
029: import com.iplanet.jato.model.DatasetModel;
030: import javax.servlet.http.HttpServletRequest;
031: import javax.servlet.http.HttpServletResponse;
032:
033: import com.sun.portal.search.admin.resources.SearchResource;
034: import com.iplanet.am.console.components.view.html.IPlanetButton;
035:
036: import com.sun.portal.search.admin.model.RobotClassRuleListModel;
037: import com.sun.portal.log.common.PortalLogger;
038:
039: public class RobotClassRuleListView extends
040: RequestHandlingTiledViewBase implements TiledView,
041: RequestHandler {
042: public static final String SRC_TEXT = "Src";
043: public static final String METHOD_TEXT = "Method";
044: public static final String CRITERIA_TEXT = "Criteria";
045: public static final String CLASSIFICATION_TEXT = "Classification";
046: public static final String DEL_CHECKBOX = "Delete";
047: public static final String EDIT_HREF = "EditAction";
048:
049: private RobotClassRuleListModel model = null;
050:
051: // Create a Logger for this class
052: private static Logger debugLogger = PortalLogger
053: .getLogger(RobotClassRuleListView.class);
054:
055: public RobotClassRuleListView(View parent, String name) {
056: super (parent, name);
057: setPrimaryModel(getModel());
058: registerChildren();
059: }
060:
061: protected void registerChildren() {
062: registerChild(SRC_TEXT, StaticTextField.class);
063: registerChild(METHOD_TEXT, StaticTextField.class);
064: registerChild(CRITERIA_TEXT, StaticTextField.class);
065: registerChild(CLASSIFICATION_TEXT, StaticTextField.class);
066: registerChild(DEL_CHECKBOX, CheckBox.class);
067: registerChild(EDIT_HREF, HREF.class);
068: }
069:
070: protected View createChild(String name) {
071: if (name.equals(SRC_TEXT)) {
072: return new StaticTextField(this , getModel(), SRC_TEXT,
073: RobotClassRuleListModel.FIELD_SRC, "");
074: }
075: if (name.equals(METHOD_TEXT)) {
076: return new StaticTextField(this , getModel(), METHOD_TEXT,
077: RobotClassRuleListModel.FIELD_METHOD, "");
078: }
079: if (name.equals(CRITERIA_TEXT)) {
080: return new StaticTextField(this , getModel(), CRITERIA_TEXT,
081: RobotClassRuleListModel.FIELD_CRITERIA, "", null);
082: }
083: if (name.equals(CLASSIFICATION_TEXT)) {
084: return new TextField(this , getModel(), CLASSIFICATION_TEXT,
085: RobotClassRuleListModel.FIELD_CLASSIFICATION, "",
086: null);
087: }
088: if (name.equals(DEL_CHECKBOX)) {
089: return new CheckBox(this , getModel(), DEL_CHECKBOX,
090: RobotClassRuleListModel.FIELD_DELETE, "true",
091: "false", false, null);
092: }
093: if (name.equals(EDIT_HREF)) {
094: return new HREF(this , EDIT_HREF, "");
095: }
096: throw new IllegalArgumentException("Invalid child name: "
097: + name);
098: }
099:
100: /**
101: *
102: *
103: */
104: public void beginDisplay(DisplayEvent event)
105: throws ModelControlException {
106: // Ensure the primary model is non-null; if null, it would cause
107: // havoc with the various methods dependent on the primary model
108: RobotClassRuleListModel model = (RobotClassRuleListModel) getPrimaryModel();
109: if (model == null) {
110: debugLogger.finer("PSSH_CSPSA0023");
111: throw new ModelControlException("Primary model is null");
112: }
113:
114: // The model will be executed automatically here by the base class
115: super .beginDisplay(event);
116:
117: resetTileIndex();
118: }
119:
120: /**
121: *
122: *
123: */
124: public Model[] getWebActionModels(int modelType) {
125: // Mark the BasicCustomModel instance we're bound to as auto-retrieving.
126: // This means it will automatically be executed via its retrieve()
127: // method when the tiled view begins display.
128:
129: switch (modelType) {
130: case MODEL_TYPE_RETRIEVE:
131: case MODEL_TYPE_DELETE:
132: /*case MODEL_TYPE_UPDATE:
133: case MODEL_TYPE_INSERT:*/
134: RobotClassRuleListModel model = getModel();
135: return new Model[] { model };
136: }
137:
138: return new Model[0];
139: }
140:
141: /**
142: *
143: *
144: */
145: public RobotClassRuleListModel getModel() {
146: if (model == null) {
147: model = (RobotClassRuleListModel) getRequestContext()
148: .getModelManager().getModel(
149: RobotClassRuleListModel.class);
150: CSViewBeanBase pvb = (CSViewBeanBase) getParentViewBean();
151: model.userLocale = pvb.getUserLocale();
152: }
153: return model;
154: }
155:
156: public void handleEditActionRequest(RequestInvocationEvent event)
157: throws ModelControlException {
158:
159: TiledViewRequestInvocationEvent tiledEvent = (TiledViewRequestInvocationEvent) event;
160: int index = tiledEvent.getTileNumber();
161: ViewBean pvb = getParentViewBean();
162: HttpServletResponse response = (pvb.getRequestContext())
163: .getResponse();
164: try {
165: response
166: .sendRedirect("RobotClassRuleEditor?Index=" + index);
167: } catch (IOException e) {
168: //TOFIX: handle this
169: }
170: }
171:
172: }
|