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 NetFileTotalThreeViewBean extends NetFileViewBeanBase
041: implements NetFileAdminService, AMAdminConstants {
042:
043: public static final String PAGE_NAME = "NetFileTotalThree";
044: public static final String DEFAULT_DISPLAY_URL = "/ps/netfileadmin/NetFileTotalThree.jsp";
045: public static final String PAGE_LABEL = "lblTotalThree";
046:
047: public NetFileTotalThreeViewBean(String pageName) {
048: super (pageName);
049: registerChildren();
050: }
051:
052: public NetFileTotalThreeViewBean() {
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, NetFileTotalThreeView.class);
061: registerChild(ORG_DATA_VIEW, NetFileTotalThreeView.class);
062: registerChild(DYNAMIC_DATA_VIEW, NetFileTotalThreeView.class);
063: registerChild(PAGE_LABEL, StaticTextField.class);
064: }
065:
066: /**
067: * creates child view/component
068: *
069: * @param name of view/component
070: * @return child view/component
071: */
072: protected View createChild(String name) {
073: /* get the model manager and model ready*/
074: getNetFileModelMgr();
075: View child = null;
076:
077: if (name.equals(GLOBAL_DATA_VIEW)) {
078: child = new NetFileTotalThreeView(this , GLOBAL_DATA_VIEW,
079: NetFileModel.GLOBAL_TYPE);
080: } else if (name.equals(ORG_DATA_VIEW)) {
081: child = new NetFileTotalThreeView(this , ORG_DATA_VIEW,
082: NetFileModel.ORG_TYPE);
083: } else if (name.equals(DYNAMIC_DATA_VIEW)) {
084: child = new NetFileTotalThreeView(this , DYNAMIC_DATA_VIEW,
085: NetFileModel.DYNAMIC_TYPE);
086: } else if (name.equals(PAGE_LABEL)) {
087: child = new StaticTextField(this , PAGE_LABEL, modelManager
088: .getString("props.total.three"));
089: } else {
090: child = super .createChild(name);
091: }
092: return child;
093: }
094:
095: public void handleSubmitButtonRequest(RequestInvocationEvent event)
096: throws ModelControlException, SSOException {
097: getModel();
098: NetFileTotalThreeView view = null;
099: view = (NetFileTotalThreeView) getChild(GLOBAL_DATA_VIEW);
100: if (view != null) {
101: store(view, NetFileModel.GLOBAL_TYPE);
102: }
103: view = (NetFileTotalThreeView) getChild(ORG_DATA_VIEW);
104: if (view != null) {
105: store(view, NetFileModel.ORG_TYPE);
106: }
107: view = (NetFileTotalThreeView) getChild(DYNAMIC_DATA_VIEW);
108: if (view != null) {
109: store(view, NetFileModel.DYNAMIC_TYPE);
110: }
111: showPropertiesSavedMessageBox();
112:
113: forwardTo();
114: }
115:
116: public void beginDisplay(DisplayEvent event)
117: throws ModelControlException {
118: super .beginDisplay(event);
119: }
120:
121: private void store(NetFileTotalThreeView view, int type)
122: throws SSOException {
123: NetFileModel m = getModel();
124: m.process();
125: Map map = new HashMap(10);
126: List dynComps = view.getDynamicCompList();
127:
128: if (dynComps != null && !dynComps.isEmpty()) {
129: Iterator it = dynComps.iterator();
130: while (it.hasNext()) {
131: DynamicGUI dGui = (DynamicGUI) it.next();
132: if (dGui != null) {
133: Set dgValues = dGui.getValues();
134: if (dGui.getSyntax() == DynamicGUI.SYNTAX_DATE) {
135: try {
136: dgValues = m
137: .getDateInDefaultLocale(dgValues);
138: } catch (AMConsoleException ace) {
139: NetFileAdminModelManager
140: .debugError("Error in converting value to default locale : "
141: + ace);
142: // showMessage(MessageBox.TYPE_ERROR,
143: // m.getErrorTitle(),
144: // ace.getMessage());
145: continue;
146: }
147: }
148: map.put(dGui.getName(), dgValues);
149: }
150: }
151: }
152: if (type == NetFileModel.DYNAMIC_TYPE) {
153: String priority = (String) getDisplayFieldValue(PRIORITY_COMBOBOX);
154: if (!"".equals(priority))
155: map.put("priority", priority);
156: }
157:
158: if (!map.isEmpty()) {
159: m.store(type, map);
160: }
161: }
162:
163: }
|