001: /**
002: * Copyright 2002 Sun Microsystems, Inc. All
003: * rights reserved. Use of this product is subject
004: * to license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users
006: * Subject to Standard License Terms and
007: * Conditions.
008: *
009: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010: * are trademarks or registered trademarks of Sun Microsystems,
011: * Inc. in the United States and other countries.
012: *
013: * Author: Anurag Gupta
014: */package com.sun.portal.rproxy.admin;
015:
016: // JDK classes
017: import java.io.Serializable;
018: import java.util.Iterator;
019: import java.util.Map;
020:
021: import javax.servlet.http.HttpServletRequest;
022:
023: import com.iplanet.am.console.base.AMMessageViewBean;
024: import com.iplanet.am.console.base.AMViewBeanBase;
025: import com.iplanet.am.console.components.view.html.IPlanetButton;
026: import com.iplanet.am.console.components.view.html.MessageBox;
027: import com.iplanet.jato.model.ModelControlException;
028: import com.iplanet.jato.view.View;
029: import com.iplanet.jato.view.ViewBean;
030: import com.iplanet.jato.view.event.ChildDisplayEvent;
031: import com.iplanet.jato.view.event.DisplayEvent;
032: import com.iplanet.jato.view.event.RequestInvocationEvent;
033: import com.iplanet.jato.view.html.HREF;
034: import com.iplanet.jato.view.html.HiddenField;
035: import com.iplanet.jato.view.html.StaticTextField;
036: import com.sun.portal.rproxy.admin.model.GatewayModel;
037: import com.sun.portal.rproxy.admin.model.GatewayModelImpl;
038:
039: public class GatewayViewBeanBase extends AMViewBeanBase {
040:
041: public static final String PAGE_DESCRIPTION = "serviceDescription";
042:
043: public static final String TITLE_HTML_PAGE = "titleHtmlPage";
044:
045: public static final String CHILD_SVCNAME = "serviceName";
046:
047: public static final String CHILD_SVCNAME_HREF = "serviceNameHref";
048:
049: public static final String CHILD_SVCNAME_ACTION = "serviceNameAction";
050:
051: public static final String CHILD_GWPROFILEFOR = "GatewayProfileFor";
052:
053: public static final String CHILD_PROFILENAME = "profileName";
054:
055: public static final String GLOBAL_LABEL = "lblGlobal";
056:
057: public static final String GLOBAL_DATA_VIEW = "GlobalDataView";
058:
059: public static final String CHILD_CC_MSGBOX = "ccMessageBox";
060:
061: public static final String SUBMIT_BTN = "SubmitButton";
062:
063: public static final String RESET_BTN = "ResetButton";
064:
065: public static final String CANCEL_BTN = "CancelButton";
066:
067: public static final String HIDDEN_CONFIG_NAME = "hiddenConfigName";
068:
069: public static final String CHILD_HREF_PROPS_1 = "hrefProps1";
070:
071: public static final String CHILD_HREF_PROPS_2 = "hrefProps2";
072:
073: public static final String CHILD_HREF_PROPS_3 = "hrefProps3";
074:
075: public static final String CHILD_HREF_PROPS_4 = "hrefProps4";
076:
077: public static final String CHILD_HREF_PROPS_4_2 = "hrefProps4_2";
078:
079: public static final String CHILD_HREF_PROPS_5 = "hrefProps5";
080:
081: public static final String CHILD_TEXT_PROPS_ONE = "textProps1";
082:
083: public static final String CHILD_TEXT_PROPS_TWO = "textProps2";
084:
085: public static final String CHILD_TEXT_PROPS_THREE = "textProps3";
086:
087: public static final String CHILD_TEXT_PROPS_FOUR = "textProps4";
088:
089: public static final String CHILD_TEXT_PROPS_FOUR_ONE = "textProps4_1";
090:
091: public static final String CHILD_TEXT_PROPS_FOUR_TWO = "textProps4_2";
092:
093: public static final String CHILD_TEXT_PROPS_FIVE = "textProps5";
094:
095: protected GatewayModel model = null;
096:
097: protected GatewayAdminModelManager modelManager = null;
098:
099: public GatewayViewBeanBase(String pageName) {
100: super (pageName);
101: }
102:
103: protected void registerChildren() {
104: registerChild(PAGE_DESCRIPTION, StaticTextField.class);
105: registerChild(TITLE_HTML_PAGE, StaticTextField.class);
106: registerChild(CHILD_SVCNAME, StaticTextField.class);
107: registerChild(CHILD_SVCNAME_HREF, HREF.class);
108: registerChild(CHILD_SVCNAME_ACTION, StaticTextField.class);
109: registerChild(CHILD_GWPROFILEFOR, StaticTextField.class);
110: registerChild(CHILD_PROFILENAME, StaticTextField.class);
111:
112: registerChild(GLOBAL_LABEL, StaticTextField.class);
113: registerChild(CHILD_CC_MSGBOX, MessageBox.class);
114: registerChild(SUBMIT_BTN, IPlanetButton.class);
115: registerChild(RESET_BTN, IPlanetButton.class);
116: registerChild(CANCEL_BTN, IPlanetButton.class);
117: registerChild(HIDDEN_CONFIG_NAME, HiddenField.class);
118:
119: registerChild(CHILD_HREF_PROPS_1, HREF.class);
120: registerChild(CHILD_HREF_PROPS_2, HREF.class);
121: registerChild(CHILD_HREF_PROPS_3, HREF.class);
122: registerChild(CHILD_HREF_PROPS_4, HREF.class);
123: registerChild(CHILD_HREF_PROPS_4_2, HREF.class);
124: registerChild(CHILD_HREF_PROPS_5, HREF.class);
125: registerChild(CHILD_TEXT_PROPS_ONE, StaticTextField.class);
126: registerChild(CHILD_TEXT_PROPS_TWO, StaticTextField.class);
127: registerChild(CHILD_TEXT_PROPS_THREE, StaticTextField.class);
128: registerChild(CHILD_TEXT_PROPS_FOUR, StaticTextField.class);
129: registerChild(CHILD_TEXT_PROPS_FOUR_TWO, StaticTextField.class);
130: registerChild(CHILD_TEXT_PROPS_FOUR_ONE, StaticTextField.class);
131: registerChild(CHILD_TEXT_PROPS_FIVE, StaticTextField.class);
132: }
133:
134: protected View createChild(String name) {
135: getGWModelMgr();
136: View child = null;
137:
138: if (name.equals(PAGE_DESCRIPTION)) {
139: child = new StaticTextField(this , PAGE_DESCRIPTION, "");
140: } else if (name.equals(TITLE_HTML_PAGE)) {
141: child = new StaticTextField(this , TITLE_HTML_PAGE,
142: modelManager.getString("HTMLPage.title"));
143: } else if (name.equals(CHILD_SVCNAME)) {
144: child = new StaticTextField(this , CHILD_SVCNAME,
145: modelManager.getString("service.name"));
146: } else if (name.equals(CHILD_SVCNAME_HREF)) {
147: child = new HREF(this , CHILD_SVCNAME_HREF, "");
148: } else if (name.equals(CHILD_SVCNAME_ACTION)) {
149: child = new StaticTextField(this , CHILD_SVCNAME_ACTION,
150: modelManager.getString("editprofile.title"));
151: } else if (name.equals(CHILD_PROFILENAME)) {
152: child = new StaticTextField(this , CHILD_PROFILENAME, "");
153:
154: } else if (name.equals(GLOBAL_LABEL)) {
155: child = new StaticTextField(this , GLOBAL_LABEL, "");
156: return new MessageBox(this , CHILD_CC_MSGBOX, "");
157: } else if (name.equals(SUBMIT_BTN)) {
158: child = new IPlanetButton(this , SUBMIT_BTN, "");
159: } else if (name.equals(RESET_BTN)) {
160: child = new IPlanetButton(this , RESET_BTN, "");
161: } else if (name.equals(CANCEL_BTN)) {
162: child = new IPlanetButton(this , CANCEL_BTN, "");
163: } else if (name.equals(HIDDEN_CONFIG_NAME)) {
164: return new HiddenField(this , HIDDEN_CONFIG_NAME, "");
165:
166: } else if (name.equals(CHILD_HREF_PROPS_1)) {
167: child = new HREF(this , CHILD_HREF_PROPS_1, "");
168: } else if (name.equals(CHILD_HREF_PROPS_2)) {
169: child = new HREF(this , CHILD_HREF_PROPS_2, "");
170: } else if (name.equals(CHILD_HREF_PROPS_3)) {
171: child = new HREF(this , CHILD_HREF_PROPS_3, "");
172: } else if (name.equals(CHILD_HREF_PROPS_4)) {
173: child = new HREF(this , CHILD_HREF_PROPS_4, "");
174: } else if (name.equals(CHILD_HREF_PROPS_4_2)) {
175: child = new HREF(this , CHILD_HREF_PROPS_4_2, "");
176: } else if (name.equals(CHILD_HREF_PROPS_5)) {
177: child = new HREF(this , CHILD_HREF_PROPS_5, "");
178: } else if (name.equals(CHILD_TEXT_PROPS_ONE)) {
179: child = new StaticTextField(this , CHILD_TEXT_PROPS_ONE,
180: modelManager.getString("props.1"));
181: } else if (name.equals(CHILD_TEXT_PROPS_TWO)) {
182: child = new StaticTextField(this , CHILD_TEXT_PROPS_TWO,
183: modelManager.getString("props.2"));
184: } else if (name.equals(CHILD_TEXT_PROPS_THREE)) {
185: child = new StaticTextField(this , CHILD_TEXT_PROPS_THREE,
186: modelManager.getString("props.3"));
187: } else if (name.equals(CHILD_TEXT_PROPS_FOUR)) {
188: child = new StaticTextField(this , CHILD_TEXT_PROPS_FOUR,
189: modelManager.getString("props.4"));
190: } else if (name.equals(CHILD_TEXT_PROPS_FOUR_ONE)) {
191: child = new StaticTextField(this ,
192: CHILD_TEXT_PROPS_FOUR_ONE, modelManager
193: .getString("props.4.1"));
194: } else if (name.equals(CHILD_TEXT_PROPS_FOUR_TWO)) {
195: child = new StaticTextField(this ,
196: CHILD_TEXT_PROPS_FOUR_TWO, modelManager
197: .getString("props.4.2"));
198: } else if (name.equals(CHILD_TEXT_PROPS_FIVE)) {
199: child = new StaticTextField(this , CHILD_TEXT_PROPS_FIVE,
200: modelManager.getString("props.5"));
201: } else {
202: child = super .createChild(name);
203: }
204: return child;
205: }
206:
207: public void beginDisplay(DisplayEvent event)
208: throws ModelControlException {
209: GatewayModel m = getModel();
210: setChildValues(model);
211: getGWModelMgr();
212: String[] configName = null;
213: String currentConfig = (String) getDisplayFieldValue(HIDDEN_CONFIG_NAME); // Read
214: // from
215: // the
216: // page
217: if ((currentConfig == null)
218: || (currentConfig.trim().length() == 0)) {
219: // First time - get from session
220: configName = modelManager
221: .getFromSession(GatewaySelectViewBean.SELECT_GATEWAY_SESSION_INFO);
222: } else {
223: // Use the page attribute
224: configName = new String[1];
225: configName[0] = currentConfig;
226: }
227: m.process(configName[0]);
228:
229: if (!m.hasSchema()) {
230: AMMessageViewBean vb = (AMMessageViewBean) getViewBean(com.iplanet.am.console.base.AMMessageViewBean.class);
231: vb.setMessageType(MessageBox.TYPE_INFORMATION);
232: vb.setTitle(modelManager.getString("noschema.msg"));
233: vb.setMessage("");
234: vb.addButton(modelManager.getString("ok.button"),
235: "../console/html/blank.html");
236: vb.forwardTo(getRequestContext());
237: }
238: setDisplayFieldValue(HIDDEN_CONFIG_NAME, configName[0]);
239: setDisplayFieldValue(CHILD_PROFILENAME, configName[0]);
240: setDisplayFieldValue(SUBMIT_BTN, modelManager
241: .getString("submit.button"));
242: setDisplayFieldValue(RESET_BTN, modelManager
243: .getString("reset.button"));
244: setDisplayFieldValue(CANCEL_BTN, modelManager
245: .getString("cancel.button"));
246: // setDisplayFieldValue(PAGE_DESCRIPTION,
247: // model.getServiceDisplayName());
248: setDisplayFieldValue(GLOBAL_LABEL, modelManager
249: .getString("global"));
250: setDisplayFieldValue(HELP_DOC_URL, modelManager
251: .getString(GatewayAdminService.SRA_BASE_HLP_URL));
252: setDisplayFieldValue(HELP_ANCHOR_TAG, model
253: .getHelpAnchorTag(GatewayAdminService.SRA_GW_HLP_URL));
254: }
255:
256: public boolean beginGlobalBlockDisplay(ChildDisplayEvent event) {
257: return (getModel().getSize() != 0);
258: }
259:
260: public void handleServiceNameHrefRequest(
261: RequestInvocationEvent event) throws ModelControlException {
262: ViewBean vb = getViewBean(GatewaySelectViewBean.class);
263: vb.forwardTo(getRequestContext());
264: }
265:
266: public void handleResetButtonRequest(RequestInvocationEvent event)
267: throws ModelControlException {
268: forwardTo();
269: }
270:
271: public void handleCancelButtonRequest(RequestInvocationEvent event)
272: throws ModelControlException {
273: ViewBean vb = getViewBean(GatewaySelectViewBean.class);
274: vb.forwardTo(getRequestContext());
275: }
276:
277: public void handleHrefProps1Request(RequestInvocationEvent event)
278: throws ModelControlException {
279: Gateway1ViewBean vb = (Gateway1ViewBean) getViewBean(Gateway1ViewBean.class);
280: passPgSessionMap(vb);
281: vb.forwardTo(getRequestContext());
282: }
283:
284: public void handleHrefProps2Request(RequestInvocationEvent event)
285: throws ModelControlException {
286: Gateway2ViewBean vb = (Gateway2ViewBean) getViewBean(Gateway2ViewBean.class);
287: passPgSessionMap(vb);
288: vb.forwardTo(getRequestContext());
289: }
290:
291: public void handleHrefProps3Request(RequestInvocationEvent event)
292: throws ModelControlException {
293: Gateway3ViewBean vb = (Gateway3ViewBean) getViewBean(Gateway3ViewBean.class);
294: passPgSessionMap(vb);
295: vb.forwardTo(getRequestContext());
296: }
297:
298: public void handleHrefProps4Request(RequestInvocationEvent event)
299: throws ModelControlException {
300: Gateway4ViewBean vb = (Gateway4ViewBean) getViewBean(Gateway4ViewBean.class);
301: passPgSessionMap(vb);
302: vb.forwardTo(getRequestContext());
303: }
304:
305: public void handleHrefProps4_2Request(RequestInvocationEvent event)
306: throws ModelControlException {
307: Gateway4_2ViewBean vb = (Gateway4_2ViewBean) getViewBean(Gateway4_2ViewBean.class);
308: passPgSessionMap(vb);
309: vb.forwardTo(getRequestContext());
310: }
311:
312: public void handleHrefProps5Request(RequestInvocationEvent event)
313: throws ModelControlException {
314: Gateway5ViewBean vb = (Gateway5ViewBean) getViewBean(Gateway5ViewBean.class);
315: passPgSessionMap(vb);
316: vb.forwardTo(getRequestContext());
317: }
318:
319: public GatewayAdminModelManager getGWModelMgr() {
320: if (modelManager == null) {
321: modelManager = (GatewayAdminModelManager) getRequestContext()
322: .getModelManager();
323: }
324: return modelManager;
325: }
326:
327: public GatewayModel getModel() {
328: if (model == null) {
329: HttpServletRequest req = getRequestContext().getRequest();
330: req
331: .setAttribute(
332: GatewayAdminModelManager.SRAP_GATEWAY_MODEL_MGR_KEY,
333: getGWModelMgr());
334: model = new GatewayModelImpl(req);
335: }
336: return model;
337: }
338:
339: public void passPgSessionMap(ViewBean other) {
340: Map attributes = getPageSessionAttributes();
341: if ((attributes != null) && (attributes.size() > 0)) {
342: Iterator iter = attributes.keySet().iterator();
343: while (iter.hasNext()) {
344: String key = (String) iter.next();
345: other.setPageSessionAttribute(key,
346: (Serializable) attributes.get(key));
347: }
348: }
349: }
350:
351: }
|