Source Code Cross Referenced for SelectRuleTiledView.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 java.util.List;
008:        import java.io.UnsupportedEncodingException;
009:        import javax.servlet.http.HttpServletRequest;
010:
011:        import com.iplanet.jato.RequestHandler;
012:        import com.iplanet.jato.util.Encoder;
013:        import com.iplanet.jato.model.Model;
014:        import com.iplanet.jato.model.DatasetModel;
015:        import com.iplanet.jato.model.ModelControlException;
016:        import com.iplanet.jato.view.RequestHandlingTiledViewBase;
017:        import com.iplanet.jato.view.TiledView;
018:        import com.iplanet.jato.view.View;
019:        import com.iplanet.jato.view.ViewBean;
020:        import com.iplanet.jato.view.event.DisplayEvent;
021:        import com.iplanet.jato.view.event.RequestInvocationEvent;
022:        import com.iplanet.jato.view.event.TiledViewRequestInvocationEvent;
023:        import com.iplanet.jato.view.html.HiddenField;
024:        import com.iplanet.jato.view.html.HREF;
025:        import com.iplanet.jato.view.html.CheckBox;
026:        import com.iplanet.jato.view.html.StaticTextField;
027:        import com.iplanet.jato.view.html.TextField;
028:
029:        import com.sun.portal.rewriter.admin.model.RewriterModel;
030:        import com.iplanet.am.console.base.AMViewBeanBase;
031:
032:        /**
033:         * The tileview that lists each rule in the select rule admin UI.
034:         * The SelectRuleViewBean is the parent of this tileview where
035:         * all the tile(s)/rule(s) are displayed.
036:         */
037:        public class SelectRuleTiledView extends RequestHandlingTiledViewBase
038:                implements  TiledView, RequestHandler {
039:
040:            public static final String CHILD_CB_SELECT_RULE = "cbSelectRule";
041:            public static final String CHILD_HREF_EDIT_RULE = "hrefEditRule";
042:            public static final String CHILD_RULENAME_LABEL = "ruleNameLabel";
043:            public static final String CHILD_HIDDEN_RULE_NAME = "ruleNameHidden";
044:            public static final String CHILD_EDIT_LABEL = "editLabel";
045:            public static final String CHILD_UPLOAD_URL_TEXT = "ruleSetUploadURL";
046:            public static final String CHILD_DOWNLOAD_URL_TEXT = "ruleSetDownloadURL";
047:            public static final String CHILD_UPLOAD_LABEL_TEXT = "ruleSetUploadLinkLabel";
048:            public static final String CHILD_DOWNLOAD_LABEL_TEXT = "ruleSetDownloadLinkLabel";
049:
050:            /* the maximum number of tiles per page */
051:            private static final int MAX_DISPLAY_TILES = 200;
052:
053:            private List ruleNames = null;
054:            private String url = "";
055:            private String pgEncoding = "UTF-8";
056:
057:            /**
058:             * Default constructor.
059:             * @param parent the parent view of this tileview.
060:             * @param name the name of this tileview.
061:             */
062:            public SelectRuleTiledView(View parent, String name) {
063:                super (parent, name);
064:                setMaxDisplayTiles(MAX_DISPLAY_TILES);
065:                setPrimaryModel((DatasetModel) getDefaultModel());
066:                registerChildren();
067:            }
068:
069:            /**
070:             * Register the child objects of the tileview.
071:             */
072:            protected void registerChildren() {
073:                registerChild(CHILD_CB_SELECT_RULE, CheckBox.class);
074:                registerChild(CHILD_HREF_EDIT_RULE, HREF.class);
075:                registerChild(CHILD_RULENAME_LABEL, StaticTextField.class);
076:                registerChild(CHILD_EDIT_LABEL, StaticTextField.class);
077:                registerChild(CHILD_HIDDEN_RULE_NAME, HiddenField.class);
078:                registerChild(CHILD_UPLOAD_URL_TEXT, StaticTextField.class);
079:                registerChild(CHILD_UPLOAD_LABEL_TEXT, StaticTextField.class);
080:                registerChild(CHILD_DOWNLOAD_URL_TEXT, StaticTextField.class);
081:                registerChild(CHILD_DOWNLOAD_LABEL_TEXT, StaticTextField.class);
082:            }
083:
084:            /**
085:             * Creates and return the child view objects for the specified name.
086:             * @param name the child view name.
087:             * @return the child view object that corresponds to the given name.
088:             */
089:            protected View createChild(String name) {
090:                View child = null;
091:                if (name.equals(CHILD_CB_SELECT_RULE)) {
092:                    child = new CheckBox(this , CHILD_CB_SELECT_RULE, "true",
093:                            "false", false);
094:                } else if (name.equals(CHILD_HREF_EDIT_RULE)) {
095:                    child = new HREF(this , CHILD_HREF_EDIT_RULE, "");
096:                } else if (name.equals(CHILD_UPLOAD_URL_TEXT)) {
097:                    child = new StaticTextField(this , CHILD_UPLOAD_URL_TEXT, "");
098:                } else if (name.equals(CHILD_UPLOAD_LABEL_TEXT)) {
099:                    child = new StaticTextField(this , CHILD_UPLOAD_LABEL_TEXT,
100:                            "");
101:                } else if (name.equals(CHILD_DOWNLOAD_URL_TEXT)) {
102:                    child = new StaticTextField(this , CHILD_DOWNLOAD_URL_TEXT,
103:                            "");
104:                } else if (name.equals(CHILD_DOWNLOAD_LABEL_TEXT)) {
105:                    child = new StaticTextField(this ,
106:                            CHILD_DOWNLOAD_LABEL_TEXT, "");
107:                } else if (name.equals(CHILD_RULENAME_LABEL)) {
108:                    child = new StaticTextField(this , CHILD_RULENAME_LABEL, "");
109:                } else if (name.equals(CHILD_EDIT_LABEL)) {
110:                    child = new StaticTextField(this , CHILD_EDIT_LABEL, "");
111:                } else if (name.equals(CHILD_HIDDEN_RULE_NAME)) {
112:                    child = new HiddenField(this , CHILD_HIDDEN_RULE_NAME, "");
113:                } else {
114:                    throw new IllegalArgumentException(name);
115:                }
116:                return child;
117:            }
118:
119:            /**
120:             * begins displaying page. we set the required information
121:             *
122:             * @param event   display event
123:             * @throws ModelControlException  if problem access value of component
124:             */
125:            public void beginDisplay(DisplayEvent event)
126:                    throws ModelControlException {
127:                if (getPrimaryModel() == null) {
128:                    throw new ModelControlException("Primary model is null");
129:                }
130:
131:                RewriterModel rwm = getModel(getRequestContext().getRequest());
132:                ruleNames = rwm.getRuleSetNames();
133:                pgEncoding = (String) getParentViewBean().getDisplayFieldValue(
134:                        AMViewBeanBase.PAGE_ENCODING);
135:                String reqURI = getRequestContext().getRequest()
136:                        .getRequestURI();
137:                url = reqURI.substring(0, reqURI.indexOf('/', 1))
138:                        + "/RuleSetServlet?" + AMViewBeanBase.PAGE_ENCODING
139:                        + "=" + pgEncoding + "&RuleSetName=";
140:
141:                if (ruleNames.size() > 0) {
142:                    getPrimaryModel().setSize(ruleNames.size());
143:                } else {
144:                    getPrimaryModel().setSize(0);
145:                }
146:                super .beginDisplay(event);
147:                resetTileIndex();
148:            }
149:
150:            /**
151:             * moves the current tile position to the next available tile.
152:             *
153:             * @return true if another tile was available, false if the position
154:             *         remained unchanged because no next tile was available.
155:             *
156:             * @throws ModelControlException if manipulation of model fails.
157:             */
158:            public boolean nextTile() throws ModelControlException {
159:                boolean movedToRow = super .nextTile();
160:                RewriterModel rwm = getModel(getRequestContext().getRequest());
161:                if (movedToRow) {
162:                    String rule = (String) ruleNames.get(getTileIndex());
163:                    String encodedRule = "";
164:                    if (rule != null && rule.length() > 0) {
165:                        try {
166:                            encodedRule = Encoder.encode(rule
167:                                    .getBytes(pgEncoding));
168:                        } catch (UnsupportedEncodingException uee) {
169:                            // NOP
170:                            uee.printStackTrace();
171:                        }
172:                    }
173:
174:                    String fullUrl = url + encodedRule;
175:                    setDisplayFieldValue(CHILD_DOWNLOAD_URL_TEXT, fullUrl
176:                            + "&action=getRuleSet");
177:                    setDisplayFieldValue(CHILD_UPLOAD_LABEL_TEXT, rwm
178:                            .getLocalizedString("SelectRuleJSP.uploadLabel"));
179:                    setDisplayFieldValue(CHILD_DOWNLOAD_LABEL_TEXT, rwm
180:                            .getLocalizedString("SelectRuleJSP.downloadLabel"));
181:                    setDisplayFieldValue(CHILD_UPLOAD_URL_TEXT, fullUrl);
182:                    setDisplayFieldValue(CHILD_HREF_EDIT_RULE, rule);
183:                    setDisplayFieldValue(CHILD_RULENAME_LABEL, rule);
184:                    setDisplayFieldValue(CHILD_EDIT_LABEL, rwm
185:                            .getLocalizedString("SelectRuleJSP.editLabel"));
186:                    setDisplayFieldValue(CHILD_UPLOAD_LABEL_TEXT, rwm
187:                            .getLocalizedString("SelectRuleJSP.uploadLabel"));
188:                    setDisplayFieldValue(CHILD_DOWNLOAD_LABEL_TEXT, rwm
189:                            .getLocalizedString("SelectRuleJSP.downloadLabel"));
190:                    setDisplayFieldValue(CHILD_HIDDEN_RULE_NAME, rule);
191:                }
192:                return movedToRow;
193:            }
194:
195:            /**
196:             * Returns the model object for the select rule UI.
197:             * @return the model object for the select rule UI.
198:             */
199:            public RewriterModel getModel(HttpServletRequest req) {
200:                SelectRuleViewBean svb = (SelectRuleViewBean) getParentViewBean();
201:                return (RewriterModel) svb.getModel(req);
202:            }
203:
204:            /**
205:             * Handles the event to edit a given ruleset.
206:             * @param event the event to edit a given ruleset.
207:             * @exception throws ModelControlException when error(s) occurred.
208:             */
209:            public void handleHrefEditRuleRequest(RequestInvocationEvent event)
210:                    throws ModelControlException {
211:
212:                int tileNum = ((TiledViewRequestInvocationEvent) event)
213:                        .getTileNumber();
214:                getPrimaryModel().setLocation(tileNum);
215:
216:                /* Forward to the edit rule viewbean. */
217:                EditRuleViewBean vb = (EditRuleViewBean) getViewBean(EditRuleViewBean.class);
218:                vb.currentRuleSetName = (String) getDisplayFieldValue(CHILD_HREF_EDIT_RULE);
219:                vb.forwardTo(getRequestContext());
220:            }
221:
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.