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.lang.*;
009:
010: import javax.servlet.*;
011: import javax.servlet.http.*;
012:
013: import com.sun.portal.search.admin.CSViewBeanBase;
014: import com.sun.portal.search.util.SearchConfig;
015:
016: import com.iplanet.jato.RequestContext;
017: import com.iplanet.jato.RequestHandler;
018:
019: import com.iplanet.jato.view.event.DisplayEvent;
020: import com.iplanet.jato.view.event.RequestInvocationEvent;
021:
022: import com.iplanet.jato.view.html.OptionList;
023: import com.iplanet.jato.view.html.Option;
024: import com.iplanet.jato.view.html.CheckBox;
025: import com.iplanet.jato.view.html.TextField;
026: import com.iplanet.jato.view.html.ListBox;
027: import com.iplanet.jato.view.html.StaticTextField;
028:
029: import com.iplanet.jato.view.View;
030: import com.iplanet.jato.view.ViewBean;
031: import com.iplanet.jato.view.ViewBeanBase;
032:
033: import com.iplanet.jato.ViewBeanManager;
034:
035: import com.iplanet.jato.model.ModelControlException;
036:
037: import com.iplanet.am.console.components.view.html.IPlanetButton;
038: import com.sun.portal.search.admin.model.ReindexModel;
039:
040: /**
041: * Schema Editor Wizard for editing database schema
042: * It extends from <code>CSViewBeanBase</code>.
043: */
044:
045: public class ReindexViewBean extends CSViewBeanBase implements
046: RequestHandler {
047:
048: // The "logical" name for this page.
049: public static final String PAGE_NAME = "Reindex";
050: public static final String DEFAULT_DISPLAY_URL = "/ps/searchadmin/Reindex.jsp";
051:
052: // String constants for child field names. This is simply good coding practice
053: // to minimize use of string literals.
054: public static final String CHK_REINDEX = "reindex";
055: public static final String BTN_OK = "ok";
056: public static final String STATUS1 = "status1";
057: public static final String STATUS2 = "status2";
058: public static final String STATUS3 = "status3";
059: public static final String STATUS4 = "status4";
060:
061: private ReindexModel model;
062:
063: /*
064: * Default constructor
065: *
066: */
067: public ReindexViewBean() {
068: super (PAGE_NAME);
069: setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
070: registerChildren();
071: }
072:
073: /**
074: * Child methods
075: */
076: protected void registerChildren() {
077: // Add an entry for each child. Note, the children are not instantiated
078: // at this time. Instead, child instantiation is handled in a lazy fashion.
079:
080: registerChild(CHK_REINDEX, CheckBox.class);
081: registerChild(BTN_OK, IPlanetButton.class);
082: registerChild(STATUS1, StaticTextField.class);
083: registerChild(STATUS2, StaticTextField.class);
084: registerChild(STATUS3, StaticTextField.class);
085: registerChild(STATUS4, StaticTextField.class);
086: }
087:
088: protected View createChild(String name) {
089: // Create HeaderView Child
090: View child = super .createChild(name);
091: if (child != null) {
092: return child;
093:
094: } else if (name.equals(BTN_OK)) {
095: return new IPlanetButton(this , BTN_OK, "");
096:
097: } else if (name.equals(CHK_REINDEX)) {
098: return new CheckBox(this , CHK_REINDEX, "true", "false",
099: true);
100:
101: } else if (name.equals(STATUS1)) {
102: return new StaticTextField(this , STATUS1, "");
103:
104: } else if (name.equals(STATUS2)) {
105: return new StaticTextField(this , STATUS2, "");
106:
107: } else if (name.equals(STATUS3)) {
108: return new StaticTextField(this , STATUS3, "");
109:
110: } else if (name.equals(STATUS4)) {
111: return new StaticTextField(this , STATUS4, "");
112:
113: } else
114: throw new IllegalArgumentException("Invalid child name \""
115: + name + "\"");
116:
117: }
118:
119: /*
120: * Begin displaying page. we set the required information
121: * @param event display event
122: * @throws ModelControlException if problem access value of component
123: **/
124: public void beginDisplay(DisplayEvent event)
125: throws ModelControlException {
126: setPageEncoding();
127: setDisplayFieldValue(BTN_OK, getLocalizedString("ok.text"));
128:
129: CheckBox c1 = (CheckBox) getChild(CHK_REINDEX);
130: c1.setChecked(false);
131: }
132:
133: /*
134: * Request event handler methods - for button and HREF fields
135: *
136: */
137: public void handleOkRequest(RequestInvocationEvent event)
138: throws ServletException {
139: model = getModel();
140:
141: if (!getDisplayFieldBooleanValue(CHK_REINDEX)) {
142: forwardTo();
143: } else {
144:
145: RequestContext rc = getRequestContext();
146: ViewBeanManager mgr = rc.getViewBeanManager();
147: ReindexViewBean target = (ReindexViewBean) mgr
148: .getViewBean(com.sun.portal.search.admin.ReindexViewBean.class);
149:
150: // Display status messages
151: model.initSearchConfig(); // Get SearchConfig handle
152:
153: // set the line3 static display field
154: if (model.indexCategories()) {
155: target.setDisplayFieldValue(ReindexViewBean.STATUS1,
156: getLocalizedString("category.reindex.status1"));
157: target.setDisplayFieldValue(ReindexViewBean.STATUS2,
158: getLocalizedString("category.reindex.status2"));
159: }
160:
161: // set the line4 static display field. Restart server reminder
162: target.setDisplayFieldValue(ReindexViewBean.STATUS3, model
163: .getOutput());
164:
165: target.forwardTo(rc);
166: }
167: }
168:
169: protected ReindexModel getModel() {
170: if (model == null) {
171: model = new ReindexModel();
172: }
173: return model;
174: }
175: }
|