Source Code Cross Referenced for WmlSubmit.java in  » J2EE » Sofia » com » salmonllc » wml » 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 » J2EE » Sofia » com.salmonllc.wml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //** Copyright Statement ***************************************************
002:        //The Salmon Open Framework for Internet Applications (SOFIA)
003:        // Copyright (C) 1999 - 2002, Salmon LLC
004:        //
005:        // This program is free software; you can redistribute it and/or
006:        // modify it under the terms of the GNU General Public License version 2
007:        // as published by the Free Software Foundation;
008:        //
009:        // This program is distributed in the hope that it will be useful,
010:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
011:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:        // GNU General Public License for more details.
013:        //
014:        // You should have received a copy of the GNU General Public License
015:        // along with this program; if not, write to the Free Software
016:        // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:        //
018:        // For more information please visit http://www.salmonllc.com
019:        //** End Copyright Statement ***************************************************
020:
021:        package com.salmonllc.wml;
022:
023:        /////////////////////////
024:        //$Archive: /SOFIA/SourceCode/com/salmonllc/wml/WmlSubmit.java $
025:        //$Author: Dan $
026:        //$Revision: 5 $
027:        //$Modtime: 6/12/03 12:46p $
028:        /////////////////////////
029:
030:        import java.io.PrintWriter;
031:        import java.util.Hashtable;
032:        import java.util.Vector;
033:
034:        import com.salmonllc.html.events.SubmitEvent;
035:        import com.salmonllc.html.events.SubmitListener;
036:        import com.salmonllc.jsp.JspContainer;
037:        import com.salmonllc.jsp.JspController;
038:        import com.salmonllc.jsp.tags.PageTag;
039:        import com.salmonllc.sql.*;
040:        import com.salmonllc.util.MessageLog;
041:        import com.salmonllc.util.Util;
042:
043:        /**
044:         * This container will construct an anchor tag with a html link (HREF) reference.
045:         */
046:        public class WmlSubmit extends JspContainer {
047:            private DataStoreEvaluator _dsEval;
048:            private int _rowNo = -1;
049:            private String _class;
050:            private String _title;
051:            private WmlCard _card;
052:            private Vector _listeners;
053:
054:            /**
055:             * WmlSubmit constructor comment.
056:             * @param name The name of the link
057:             * @param p The page the link will go in.
058:             */
059:
060:            public WmlSubmit(String name, com.salmonllc.html.HtmlPage p) {
061:                super (name, p);
062:            }
063:
064:            /**
065:             *Does the binding for the component. This method is called by the framework and should not be called directly
066:             */
067:            public void doBinding() throws Exception {
068:                String dataSource = getDataSource();
069:                String dsName = null;
070:                String dsExp = null;
071:
072:                if (dataSource == null)
073:                    return;
074:
075:                int pos = dataSource.indexOf(":");
076:                if (pos == -1)
077:                    dsName = dataSource;
078:                else {
079:                    dsName = dataSource.substring(0, pos);
080:                    dsExp = dataSource.substring(pos + 1);
081:                }
082:
083:                DataStoreBuffer ds = ((JspController) getPage())
084:                        .getDataSource(dsName);
085:                if (ds == null)
086:                    return;
087:
088:                if (!ds.getAutoBind())
089:                    return;
090:
091:                setTitleExpression(ds, ((JspController) getPage())
092:                        .convertExpressionOperators(dsExp));
093:            }
094:
095:            /**
096:             *Generates the Html for the component. This method is called by the framework and should not be called directly
097:             */
098:            public void generateHTML(PrintWriter p, int rowNo)
099:                    throws java.io.IOException {
100:                StringBuffer sb = new StringBuffer();
101:
102:                if (!_visible)
103:                    return;
104:                StringBuffer title = null;
105:                try {
106:                    if (_dsEval != null) {
107:                        if (rowNo > -1) {
108:                            _title = _dsEval.evaluateRowFormat(rowNo);
109:                        } else {
110:                            _title = _dsEval.evaluateRowFormat();
111:                        }
112:                    }
113:                } catch (Exception e) {
114:                }
115:                // sr 12-08-2000 was getting a null pointer exception
116:                if (!Util.isNull(_title)) {
117:                    title = new StringBuffer(_title);
118:                    int titleLength = title.length();
119:                    for (int i = 0; i < titleLength; i++) {
120:                        if (title.charAt(i) == ' ') {
121:                            title.setCharAt(i, '+');
122:                        }
123:                    }
124:                }
125:                String row = "";
126:                if (rowNo != -1)
127:                    row = "_" + row + new Integer(rowNo).toString();
128:                String href = getPage().getCurrentRequest().getRequestURI();
129:                int iSlashIndex = href.lastIndexOf('/');
130:                if (iSlashIndex >= 0)
131:                    href = href.substring(iSlashIndex + 1);
132:                StringBuffer sbQuery = new StringBuffer();
133:
134:                if (getPage().isWMLMaintained())
135:                    sbQuery.append(PageTag.getSessionIdentifier() + "="
136:                            + PageTag.getWmlSessId(getPage().getSession())
137:                            + "&amp;");
138:                if (_card != null) {
139:                    WmlFormComponent[] wfca = _card.getInputComponents();
140:                    if (wfca != null) {
141:                        for (int i = 0; i < wfca.length; i++) {
142:                            String sParameter = wfca[i].getName() + "=$("
143:                                    + wfca[i].getName() + ")";
144:                            sbQuery.append(sParameter + "&amp;");
145:                        }
146:                    }
147:                }
148:                sbQuery.append("method=post&amp;");
149:                sbQuery.append(getName() + row + "=1&amp;");
150:                if (sbQuery.toString().endsWith("&amp;"))
151:                    sbQuery.delete(sbQuery.length() - 5, sbQuery.length());
152:
153:                sb.append("<a");
154:                sb.append(" id=\"" + getName() + row + "\"");
155:                if (!sbQuery.toString().trim().equals(""))
156:                    sb
157:                            .append(" href=\""
158:                                    + encodeURL(href + "?" + sbQuery.toString())
159:                                    + "\"");
160:                else
161:                    sb.append(" href=\"" + encodeURL(href) + "\"");
162:                if (_title != null)
163:                    sb.append(" title=\"" + _title + "\"");
164:                if (_class != null)
165:                    sb.append(" class=\"" + _class + "\"");
166:                sb.append(">");
167:                sb.append(_title);
168:                sb.append("</a>");
169:
170:                p.print(sb.toString());
171:
172:            }
173:
174:            /**
175:             * This method gets the DataStoreEvaluator being used for href expressions.
176:             * @return DataStoreEvaluator
177:             * @see DataStoreEvaluator
178:             */
179:            public DataStoreEvaluator getTitleExpression() {
180:                return _dsEval;
181:            }
182:
183:            /**
184:             * Use this method to get the class of the submit link
185:             */
186:            public String getClassName() {
187:                return _class;
188:            }
189:
190:            /**
191:             * Use this method to get the title for the submit link
192:             */
193:            public String getTitle() {
194:                return _title;
195:            }
196:
197:            /**
198:             * This method sets a datastore expression that will be used to compute the href for the link.
199:             * @param ds com.salmonllc.sql.DataStoreBuffer
200:             * @param expression The expression to evaluate
201:             */
202:            public void setTitleExpression(DataStoreBuffer ds,
203:                    DataStoreExpression expression) throws Exception {
204:                try {
205:                    _dsEval = new DataStoreEvaluator(ds, expression);
206:                } catch (Exception e) {
207:                    MessageLog
208:                            .writeErrorMessage(
209:                                    "setHrefExpression(DataStoreBuffer ds, DataStoreExpression expression )",
210:                                    e, this );
211:                    throw e;
212:                }
213:            }
214:
215:            /**
216:             * This method sets a datastore expression that will be used to compute the href for the link.
217:             * @param ds com.salmonllc.sql.DataStoreBuffer
218:             * @param expression java.lang.String
219:             */
220:            public void setTitleExpression(DataStoreBuffer ds, String expression)
221:                    throws Exception {
222:                try {
223:                    _dsEval = new DataStoreEvaluator(ds, expression);
224:                } catch (Exception e) {
225:                    MessageLog
226:                            .writeErrorMessage(
227:                                    "setHrefExpression(DataStoreBuffer ds, String expression )",
228:                                    e, this );
229:                    throw e;
230:                }
231:            }
232:
233:            /**
234:             * This method sets the class for the submit link.
235:             */
236:            public void setClassName(String className) {
237:                _class = className;
238:            }
239:
240:            /**
241:             * This method sets the title for the submit link.
242:             */
243:            public void setTitle(String title) {
244:                _title = title;
245:            }
246:
247:            /**
248:             *Processes the submitted parameters. This method is called by the framework and should not be called directly
249:             */
250:            public boolean processParms(Hashtable parms, int rowNo)
251:                    throws Exception {
252:                String name = getName();
253:                if (rowNo > -1)
254:                    name += "_" + rowNo;
255:
256:                if (parms.get(name) != null) {
257:                    _rowNo = rowNo;
258:                    return true;
259:                }
260:
261:                return false;
262:            }
263:
264:            /**
265:             * This method sets the card the submit belongs to.
266:             */
267:            public void setCard(WmlCard card) {
268:                _card = card;
269:            }
270:
271:            /**
272:             * This method adds a listener the will be notified when this button causes the page to be submitted.
273:             * @param l The listener to add.
274:             */
275:            public void addSubmitListener(SubmitListener l) {
276:                if (_listeners == null)
277:                    _listeners = new Vector();
278:
279:                for (int i = 0; i < _listeners.size(); i++) {
280:                    if (((SubmitListener) _listeners.elementAt(i)) == l)
281:                        return;
282:                }
283:
284:                _listeners.addElement(l);
285:            }
286:
287:            /**
288:             *Executes any events for the component. This method is called by the framework and should not be called directly
289:             */
290:            public boolean executeEvent(int type) throws Exception {
291:                if (type != EVENT_SUBMIT)
292:                    return true;
293:
294:                if (_listeners == null)
295:                    return true;
296:
297:                SubmitEvent e = new SubmitEvent(getPage(), this , getName(),
298:                        getFullName(), _rowNo);
299:
300:                for (int i = 0; i < _listeners.size(); i++) {
301:                    SubmitListener l = (SubmitListener) _listeners.elementAt(i);
302:                    e.setNextListener(_listeners.size() > (i + 1) ? _listeners
303:                            .elementAt(i + 1) : null);
304:                    if (!l.submitPerformed(e))
305:                        return false;
306:                }
307:
308:                return true;
309:            }
310:
311:            /**
312:             * This method removes a listener from the list that will be notified if this button causes the page to be submitted.
313:             * @param l The listener to remove.
314:             */
315:            public void removeSubmitListener(SubmitListener l) {
316:                if (_listeners == null)
317:                    return;
318:
319:                for (int i = 0; i < _listeners.size(); i++) {
320:                    if (((SubmitListener) _listeners.elementAt(i)) == l) {
321:                        _listeners.removeElementAt(i);
322:                        return;
323:                    }
324:                }
325:            }
326:
327:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.