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.robot.FilterLog;
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.OptionList;
023: import com.iplanet.jato.view.html.ImageField;
024: import com.iplanet.jato.view.html.StaticTextField;
025: import com.iplanet.jato.view.html.RadioButtonGroup;
026: import com.iplanet.jato.view.html.HREF;
027: import com.iplanet.jato.view.html.Button;
028: import com.iplanet.jato.model.DatasetModel;
029: import javax.servlet.http.HttpServletRequest;
030: import javax.servlet.http.HttpServletResponse;
031:
032: import com.iplanet.am.console.components.view.html.IPlanetButton;
033:
034: public class ExReasonListView extends RequestHandlingTiledViewBase
035: implements TiledView, RequestHandler {
036: public static final String TOTAL_TEXT = "SubTotal";
037: public static final String REASON_HREF = "ReasonLink";
038: public static final String REASON_TEXT = "ReasonText";
039:
040: private String[] reasons = null;
041: private FilterLog flog = null;
042: private int selectedIndex = -1;
043:
044: public ExReasonListView(View parent, String name) {
045: super (parent, name);
046: setPrimaryModel((DatasetModel) getDefaultModel());
047: registerChildren();
048: }
049:
050: protected void registerChildren() {
051: registerChild(REASON_HREF, HREF.class);
052: registerChild(TOTAL_TEXT, StaticTextField.class);
053: registerChild(REASON_TEXT, StaticTextField.class);
054: }
055:
056: protected View createChild(String name) {
057: if (name.equals(TOTAL_TEXT)) {
058: return new StaticTextField(this , TOTAL_TEXT, "");
059: }
060: if (name.equals(REASON_HREF)) {
061: return new HREF(this , REASON_HREF, "");
062: }
063: if (name.equals(REASON_TEXT)) {
064: return new StaticTextField(this , REASON_TEXT, "");
065: }
066: throw new IllegalArgumentException("Invalid child name ["
067: + name + "]");
068: }
069:
070: /**
071: *
072: *
073: */
074: public void beginDisplay(DisplayEvent event)
075: throws ModelControlException {
076:
077: ExcludedURLsViewBean parent = (ExcludedURLsViewBean) getParentViewBean();
078: flog = parent.getFilterLog();
079: if (flog != null) {
080: reasons = flog.getReasons();
081: if (reasons != null) {
082: getPrimaryModel().setSize(reasons.length);
083: }
084: }
085: resetTileIndex();
086: }
087:
088: public boolean nextTile() throws ModelControlException {
089: boolean movedToRow = super .nextTile();
090: if (movedToRow) {
091: // Put row specific logic here
092: int index = getTileIndex();
093: setDisplayFieldValue(REASON_HREF, index);
094: setDisplayFieldValue(REASON_TEXT, reasons[index]);
095: setDisplayFieldValue(TOTAL_TEXT, flog
096: .getReasonSubTotal(reasons[index]));
097: }
098: return movedToRow;
099: }
100:
101: public void handleReasonLinkRequest(RequestInvocationEvent event)
102: throws ModelControlException {
103: TiledViewRequestInvocationEvent tiledEvent = (TiledViewRequestInvocationEvent) event;
104: selectedIndex = tiledEvent.getTileNumber();
105: ViewBean pvb = getParentViewBean();
106: pvb.forwardTo(getRequestContext());
107: }
108:
109: public int getSelectedIndex() {
110: return selectedIndex;
111: }
112:
113: }
|