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.netfile.admin;
015:
016: // JDK classes
017: import java.util.HashMap;
018: import com.sun.portal.log.common.PortalLogger;
019: import java.util.Iterator;
020: import java.util.List;
021: import java.util.Map;
022: import java.util.Set;
023:
024: // iPlanet JATO classes
025: import com.iplanet.jato.model.ModelControlException;
026: import com.iplanet.jato.view.View;
027: import com.iplanet.jato.view.event.DisplayEvent;
028: import com.iplanet.jato.view.event.RequestInvocationEvent;
029: import com.iplanet.jato.view.html.StaticTextField;
030:
031: // iDS/AME classes
032: import com.iplanet.am.console.base.model.AMAdminConstants;
033: import com.iplanet.am.console.base.model.AMConsoleException;
034: import com.iplanet.am.console.components.view.html.DynamicGUI;
035: import com.iplanet.sso.SSOException;
036:
037: // NetFile admin console classes
038: import com.sun.portal.netfile.admin.model.NetFileModel;
039:
040: public class NetFileTotalOneDotTwoViewBean extends NetFileViewBeanBase
041: implements NetFileAdminService, AMAdminConstants {
042:
043: public static final String PAGE_NAME = "NetFileTotalOneDotTwo";
044: public static final String DEFAULT_DISPLAY_URL = "/ps/netfileadmin/NetFileTotalOneDotTwo.jsp";
045: public static final String PAGE_LABEL = "lblTotalOneDotTwo";
046:
047: public NetFileTotalOneDotTwoViewBean(String pageName) {
048: super (pageName);
049: registerChildren();
050: }
051:
052: public NetFileTotalOneDotTwoViewBean() {
053: super (PAGE_NAME);
054: setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
055: registerChildren();
056: }
057:
058: protected void registerChildren() {
059: super .registerChildren();
060: registerChild(GLOBAL_DATA_VIEW, NetFileTotalOneDotTwoView.class);
061: registerChild(ORG_DATA_VIEW, NetFileTotalOneDotTwoView.class);
062: registerChild(DYNAMIC_DATA_VIEW,
063: NetFileTotalOneDotTwoView.class);
064: registerChild(PAGE_LABEL, StaticTextField.class);
065: }
066:
067: /**
068: * creates child view/component
069: *
070: * @param name of view/component
071: * @return child view/component
072: */
073: protected View createChild(String name) {
074: /* get the model manager and model ready*/
075: getNetFileModelMgr();
076: View child = null;
077:
078: if (name.equals(GLOBAL_DATA_VIEW)) {
079: child = new NetFileTotalOneDotTwoView(this ,
080: GLOBAL_DATA_VIEW, NetFileModel.GLOBAL_TYPE);
081: } else if (name.equals(ORG_DATA_VIEW)) {
082: child = new NetFileTotalOneDotTwoView(this , ORG_DATA_VIEW,
083: NetFileModel.ORG_TYPE);
084: } else if (name.equals(DYNAMIC_DATA_VIEW)) {
085: child = new NetFileTotalOneDotTwoView(this ,
086: DYNAMIC_DATA_VIEW, NetFileModel.DYNAMIC_TYPE);
087: } else if (name.equals(PAGE_LABEL)) {
088: child = new StaticTextField(this , PAGE_LABEL, modelManager
089: .getString("props.total.one")
090: + " "
091: + modelManager.getString("for.label")
092: + " "
093: + modelManager.getString("props.total.one.two"));
094: } else {
095: child = super .createChild(name);
096: }
097: return child;
098: }
099:
100: public void beginDisplay(DisplayEvent event)
101: throws ModelControlException {
102: super .beginDisplay(event);
103: }
104:
105: public void handleSubmitButtonRequest(RequestInvocationEvent event)
106: throws ModelControlException, SSOException {
107: getModel();
108: NetFileTotalOneDotTwoView view = null;
109: view = (NetFileTotalOneDotTwoView) getChild(GLOBAL_DATA_VIEW);
110: if (view != null) {
111: store(view, NetFileModel.GLOBAL_TYPE);
112: }
113: view = (NetFileTotalOneDotTwoView) getChild(ORG_DATA_VIEW);
114: if (view != null) {
115: store(view, NetFileModel.ORG_TYPE);
116: }
117: view = (NetFileTotalOneDotTwoView) getChild(DYNAMIC_DATA_VIEW);
118: if (view != null) {
119: store(view, NetFileModel.DYNAMIC_TYPE);
120: }
121: showPropertiesSavedMessageBox();
122: forwardTo();
123: }
124:
125: private void store(NetFileTotalOneDotTwoView view, int type)
126: throws SSOException {
127: NetFileModel m = getModel();
128: m.process();
129: Map map = new HashMap(10);
130: List dynComps = view.getDynamicCompList();
131:
132: if (dynComps != null && !dynComps.isEmpty()) {
133: Iterator it = dynComps.iterator();
134: while (it.hasNext()) {
135: DynamicGUI dGui = (DynamicGUI) it.next();
136: if (dGui != null) {
137: Set dgValues = dGui.getValues();
138: if (dGui.getSyntax() == DynamicGUI.SYNTAX_DATE) {
139: try {
140: dgValues = m
141: .getDateInDefaultLocale(dgValues);
142: } catch (AMConsoleException ace) {
143: NetFileAdminModelManager
144: .debugError("Error in converting value to default locale : "
145: + ace);
146: // showMessage(MessageBox.TYPE_ERROR,
147: // m.getErrorTitle(),
148: // ace.getMessage());
149: continue;
150: }
151: }
152: map.put(dGui.getName(), dgValues);
153: }
154: }
155: }
156: if (type == NetFileModel.DYNAMIC_TYPE) {
157: String priority = (String) getDisplayFieldValue(PRIORITY_COMBOBOX);
158: if (!"".equals(priority))
159: map.put("priority", priority);
160: }
161:
162: if (!map.isEmpty()) {
163: m.store(type, map);
164: }
165: }
166:
167: }
|