Source Code Cross Referenced for EditRuleViewBean.java in  » Portal » Open-Portal » com » sun » portal » rewriter » admin » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.rewriter.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved. 
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms. 
004:         */
005:        package com.sun.portal.rewriter.admin;
006:
007:        import javax.servlet.http.HttpServletRequest;
008:
009:        import com.iplanet.jato.model.ModelControlException;
010:        import com.iplanet.jato.RequestContext;
011:        import com.iplanet.jato.view.event.DisplayEvent;
012:        import com.iplanet.jato.view.event.RequestInvocationEvent;
013:        import com.iplanet.jato.view.html.TextField;
014:        import com.iplanet.jato.view.html.StaticTextField;
015:        import com.iplanet.jato.view.html.HiddenField;
016:        import com.iplanet.jato.view.html.HREF;
017:        import com.iplanet.jato.view.View;
018:        import com.iplanet.jato.view.ViewBean;
019:        import com.iplanet.am.console.base.AMMessageViewBean;
020:        import com.iplanet.am.console.base.AMViewBeanBase;
021:        import com.iplanet.am.console.components.view.html.MessageBox;
022:
023:        import com.iplanet.am.console.components.view.html.IPlanetButton;
024:
025:        import com.sun.portal.rewriter.admin.model.RewriterModel;
026:        import com.sun.portal.rewriter.admin.model.RewriterModelImpl;
027:
028:        /**
029:         * The viewbean that provides the edit ruleset functionality.
030:         */
031:        public class EditRuleViewBean extends AMViewBeanBase {
032:
033:            public static final String PAGE_NAME = "EditRule";
034:            public static final String DEFAULT_DISPLAY_URL = "/ps/rwadmin/EditRule.jsp";
035:            public static final String CHILD_CC_MSGBOX = "ccMessageBox";
036:            public static final String CHILD_HTMLPAGE_TITLE = "titleHtmlPage";
037:            public static final String CHILD_EDIT_RULE_TITLE = "EditRuleTitle";
038:            public static final String CHILD_RULE_NAME_TEXT = "ruleName";
039:            public static final String CHILD_HIDDEN_RULE_NAME = "hiddenRuleName";
040:            public static final String CHILD_RULESET_XML = "ruleSetXML";
041:            public static final String CHILD_SUBMIT_BUTTON = "submitButton";
042:            public static final String CHILD_CANCEL_BUTTON = "cancelButton";
043:            public static final String CHILD_SERVICE_TITLE_TEXT = "serviceTitle";
044:            public static final String CHILD_SERVICE_TITLE_HREF = "titleHref";
045:            public static final String CHILD_TITLE_ACTION_TEXT = "titleAction";
046:
047:            private RewriterModel model = null;
048:            public String currentRuleSetName = "";
049:
050:            /**
051:             * Default Constructor
052:             */
053:            public EditRuleViewBean() {
054:                super (PAGE_NAME);
055:                setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
056:                registerChildren();
057:            }
058:
059:            /**
060:             * Creates the child view objects for this viewbean.
061:             * @param name the name of the child view object to be created.
062:             * @return the child view object.
063:             */
064:            protected View createChild(String name) {
065:                View child = null;
066:                if (name.equals(CHILD_CC_MSGBOX)) {
067:                    child = new MessageBox(this , CHILD_CC_MSGBOX, "");
068:                } else if (name.equals(CHILD_SERVICE_TITLE_HREF)) {
069:                    child = new HREF(this , CHILD_SERVICE_TITLE_HREF, "");
070:                } else if (name.equals(CHILD_SERVICE_TITLE_TEXT)) {
071:                    child = new StaticTextField(this , CHILD_SERVICE_TITLE_TEXT,
072:                            "");
073:                } else if (name.equals(CHILD_TITLE_ACTION_TEXT)) {
074:                    child = new StaticTextField(this , CHILD_TITLE_ACTION_TEXT,
075:                            "");
076:                } else if (name.equals(CHILD_HTMLPAGE_TITLE)) {
077:                    child = new StaticTextField(this , CHILD_HTMLPAGE_TITLE, "");
078:                } else if (name.equals(CHILD_EDIT_RULE_TITLE)) {
079:                    child = new StaticTextField(this , CHILD_EDIT_RULE_TITLE, "");
080:                } else if (name.equals(CHILD_RULE_NAME_TEXT)) {
081:                    child = new StaticTextField(this , CHILD_RULE_NAME_TEXT, "");
082:                } else if (name.equals(CHILD_HIDDEN_RULE_NAME)) {
083:                    child = new HiddenField(this , CHILD_HIDDEN_RULE_NAME, "");
084:                } else if (name.equals(CHILD_RULESET_XML)) {
085:                    child = new TextField(this , CHILD_RULESET_XML, "");
086:                } else if (name.equals(CHILD_SUBMIT_BUTTON)) {
087:                    child = new IPlanetButton(this , CHILD_SUBMIT_BUTTON, "");
088:                } else if (name.equals(CHILD_CANCEL_BUTTON)) {
089:                    child = new IPlanetButton(this , CHILD_CANCEL_BUTTON, "");
090:                } else {
091:                    child = super .createChild(name);
092:                }
093:
094:                return child;
095:            }
096:
097:            /**
098:             * To register all the child view objects and their classes.
099:             */
100:            protected void registerChildren() {
101:                super .registerChildren();
102:                registerChild(CHILD_CC_MSGBOX, MessageBox.class);
103:                registerChild(CHILD_SERVICE_TITLE_HREF, HREF.class);
104:                registerChild(CHILD_SERVICE_TITLE_TEXT, StaticTextField.class);
105:                registerChild(CHILD_TITLE_ACTION_TEXT, StaticTextField.class);
106:                registerChild(CHILD_EDIT_RULE_TITLE, StaticTextField.class);
107:                registerChild(CHILD_RULE_NAME_TEXT, StaticTextField.class);
108:                registerChild(CHILD_HIDDEN_RULE_NAME, HiddenField.class);
109:                registerChild(CHILD_RULESET_XML, TextField.class);
110:                registerChild(CHILD_SUBMIT_BUTTON, IPlanetButton.class);
111:                registerChild(CHILD_CANCEL_BUTTON, IPlanetButton.class);
112:            }
113:
114:            /**
115:             * begins displaying page. we set the required information
116:             *
117:             * @param event   display event
118:             * @throws ModelControlException  if problem access value of component
119:             */
120:            public void beginDisplay(DisplayEvent event)
121:                    throws ModelControlException {
122:                RewriterModel rwm = getModel(getRequestContext().getRequest());
123:                setDisplayFieldValue(CHILD_SERVICE_TITLE_TEXT, rwm
124:                        .getLocalizedString("EditRuleJSP.serviceTitle"));
125:                setDisplayFieldValue(CHILD_TITLE_ACTION_TEXT, rwm
126:                        .getLocalizedString("EditRuleJSP.titleAction"));
127:                setDisplayFieldValue(CHILD_HTMLPAGE_TITLE, rwm
128:                        .getLocalizedString("HTMLPage.title"));
129:                setDisplayFieldValue(CHILD_EDIT_RULE_TITLE, rwm
130:                        .getLocalizedString("EditRuleJSP.title"));
131:                setDisplayFieldValue(CHILD_SUBMIT_BUTTON, rwm
132:                        .getLocalizedString("EditRuleJSP.submitButton"));
133:                setDisplayFieldValue(CHILD_CANCEL_BUTTON, rwm
134:                        .getLocalizedString("EditRuleJSP.cancelButton"));
135:                MessageBox msgBox = (MessageBox) getDisplayField(CHILD_CC_MSGBOX);
136:                if (!msgBox.isVisible() && currentRuleSetName != null) {
137:                    setDisplayFieldValue(CHILD_RULE_NAME_TEXT,
138:                            currentRuleSetName);
139:                    setDisplayFieldValue(CHILD_HIDDEN_RULE_NAME,
140:                            currentRuleSetName);
141:                    String ruleXML = rwm.getRulesetXML(currentRuleSetName);
142:                    if (ruleXML == null || !ruleXML.equals("")) {
143:                        setDisplayFieldValue(CHILD_RULESET_XML, ruleXML);
144:                    } else {
145:                        msgBox
146:                                .setTitle(rwm
147:                                        .getLocalizedString("loadruleerrormsgbox.title"));
148:                        msgBox.setMessage(rwm
149:                                .getLocalizedString("loadruleerrormsgbox.msg")
150:                                + currentRuleSetName);
151:                        msgBox.setType(0);
152:                        msgBox.setVisible(true);
153:                    }
154:                }
155:                setChildValues(rwm);
156:
157:                setDisplayFieldValue(HELP_DOC_URL, rwm
158:                        .getLocalizedString("help.toc"));
159:                setDisplayFieldValue(HELP_ANCHOR_TAG, rwm.getHelpUrl(rwm
160:                        .getLocalizedString("EditRuleJSP.help")));
161:            }
162:
163:            /**
164:             * Returns the model object for the create rule UI.
165:             * @return the model object for the create rule UI.
166:             */
167:            public RewriterModel getModel(HttpServletRequest req) {
168:                if (model == null) {
169:                    model = (RewriterModel) new RewriterModelImpl(req);
170:                }
171:                return model;
172:            }
173:
174:            /**
175:             * Handles the event to finish editing a ruleset XML.
176:             * @param event the event to finish editing a ruleset XML.
177:             * @exception throws ModelControlException when error(s) occurred.
178:             */
179:            public void handleSubmitButtonRequest(RequestInvocationEvent event)
180:                    throws ModelControlException {
181:                boolean hasChanged = false;
182:                /*  get the model object for this viewbean */
183:                RewriterModel rwm = getModel(getRequestContext().getRequest());
184:                String ruleSetName = (String) getDisplayFieldValue(CHILD_HIDDEN_RULE_NAME);
185:                String origRuleSetXML = rwm.getRulesetXML(ruleSetName);
186:                String editedRuleSetXML = (String) getDisplayFieldValue(CHILD_RULESET_XML);
187:                if ((origRuleSetXML != null)
188:                        && (!origRuleSetXML.equals(editedRuleSetXML))) {
189:                    hasChanged = true;
190:                }
191:
192:                try {
193:                    AMMessageViewBean msgVB = (AMMessageViewBean) getViewBean(com.iplanet.am.console.base.AMMessageViewBean.class);
194:                    msgVB.setMessageType(MessageBox.TYPE_WARNING);
195:                    msgVB.setTitle(rwm
196:                            .getLocalizedString("serverrestartwarning.title"));
197:                    msgVB
198:                            .addButton(
199:                                    rwm
200:                                            .getLocalizedString("serverrestartwarning.oklabel"),
201:                                    getModuleURL() + "/"
202:                                            + SelectRuleViewBean.PAGE_NAME);
203:
204:                    if (hasChanged) {
205:                        if (!rwm.isEditOverwrite(ruleSetName, editedRuleSetXML)) {
206:                            rwm.saveRulesetXML(editedRuleSetXML, true);
207:                            msgVB
208:                                    .setMessage(rwm
209:                                            .getLocalizedString("serverrestartwarning.msg"));
210:                            msgVB.forwardTo(getRequestContext());
211:                        } else {
212:                            MessageBox msgBox = (MessageBox) getDisplayField(CHILD_CC_MSGBOX);
213:                            msgBox.setType(0);
214:                            msgBox.setTitle(rwm
215:                                    .getLocalizedString("renameruleerr.title"));
216:                            msgBox.setMessage(rwm
217:                                    .getLocalizedString("renameruleerr.msg"));
218:                            msgBox.setVisible(true);
219:                            forwardTo(getRequestContext());
220:                        }
221:                    } else {
222:                        msgVB
223:                                .setMessage(rwm
224:                                        .getLocalizedString("nothingchangedwarning.msg"));
225:                        msgVB.forwardTo(getRequestContext());
226:                    }
227:
228:                } catch (Exception e) {
229:                    /* Displays an error msg using the common msg box control. */
230:                    MessageBox msgBox = (MessageBox) getDisplayField(CHILD_CC_MSGBOX);
231:                    msgBox.setTitle(rwm
232:                            .getLocalizedString("saveruleerrormsgbox.title"));
233:                    msgBox.setMessage(e.getMessage());
234:                    msgBox.setType(0);
235:                    msgBox.setVisible(true);
236:                    forwardTo();
237:                }
238:            }
239:
240:            /**
241:             * Handles the event to cancel editing a ruleset XML.
242:             * @param event the event to cancel editing a ruleset XML.
243:             * @exception throws ModelControlException when error(s) occurred.
244:             */
245:            public void handleCancelButtonRequest(RequestInvocationEvent event) {
246:
247:                /* Returns control back to the select rule UI. */
248:                ViewBean vb = getViewBean(SelectRuleViewBean.class);
249:                vb.forwardTo(getRequestContext());
250:            }
251:
252:            /**
253:             * Handles the event to display rulesets.
254:             * @param event the event to display available ruleset.
255:             * @exception throws ModelControlException when error(s) occurred.
256:             */
257:            public void handleTitleHrefRequest(RequestInvocationEvent event)
258:                    throws ModelControlException {
259:                /* Forward to the edit rule viewbean. */
260:                ViewBean vb = getViewBean(SelectRuleViewBean.class);
261:                vb.forwardTo(getRequestContext());
262:            }
263:
264:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.