Source Code Cross Referenced for WmlDo.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/WmlDo.java $
025:        //$Author: Dan $
026:        //$Revision: 10 $
027:        //$Modtime: 6/12/03 1:31p $
028:        /////////////////////////
029:
030:        import java.util.Hashtable;
031:        import java.util.Vector;
032:
033:        import com.salmonllc.html.events.SubmitEvent;
034:        import com.salmonllc.html.events.SubmitListener;
035:        import com.salmonllc.jsp.*;
036:        import com.salmonllc.jsp.tags.PageTag;
037:        import com.salmonllc.sql.*;
038:        import com.salmonllc.util.MessageLog;
039:        import com.salmonllc.util.Util;
040:
041:        /**
042:         * This container will generate a Wml Do tag.
043:         */
044:        public class WmlDo extends JspContainer {
045:            private String _href;
046:            private DataStoreEvaluator _dsEval;
047:            private int _rowNo = -1;
048:            private String _class;
049:            private String _method;
050:            private String _acceptcharset;
051:            private boolean _sendreferer;
052:            private WmlCard _card;
053:            private Vector _listeners;
054:            private boolean _hrefparameters = true;
055:            private String _type;
056:            private String _label;
057:            private boolean _optional;
058:            private boolean _doprev;
059:            private boolean _postfields = true;
060:
061:            /**
062:             * WmlLink constructor comment.
063:             * @param name The name of the link
064:             * @param href The url for the link
065:             * @param p The page the do will go in.
066:             */
067:
068:            public WmlDo(String name, String href, com.salmonllc.html.HtmlPage p) {
069:                super (name, p);
070:                _href = href;
071:            }
072:
073:            /**
074:             * This method returns whether the postfields will be generated for the controls in the card.
075:             * @return boolean
076:             */
077:            public boolean isPostFields() {
078:                return _postfields;
079:            }
080:
081:            /**
082:             * This method sets whether the postfields will be generated for the controls in the card.
083:             */
084:            public void setPostFields(boolean _postfields) {
085:                this ._postfields = _postfields;
086:            }
087:
088:            /**
089:             * This method returns the type attribute of do tag.
090:             * @return String
091:             */
092:            public String getType() {
093:                return _type;
094:            }
095:
096:            /**
097:             * This method sets the type attribute of do tag.
098:             */
099:            public void setType(String _type) {
100:                this ._type = _type;
101:            }
102:
103:            /**
104:             * This method returns the label attribute of do tag.
105:             * @return String
106:             */
107:            public String getLabel() {
108:                return _label;
109:            }
110:
111:            /**
112:             * This method sets the label attribute of do tag.
113:             */
114:            public void setLabel(String _label) {
115:                this ._label = _label;
116:            }
117:
118:            /**
119:             * This method returns the optional attribute of do tag.
120:             * @return String
121:             */
122:            public boolean isOptional() {
123:                return _optional;
124:            }
125:
126:            /**
127:             * This method returns the optional attribute of do tag.
128:             */
129:            public void setOptional(boolean _optional) {
130:                this ._optional = _optional;
131:            }
132:
133:            /**
134:             * This method returns whether the do tag represents a prev command action.
135:             * @return boolean
136:             */
137:            public boolean isDoPrev() {
138:                return _doprev;
139:            }
140:
141:            /**
142:             * This method sets whether the do tag represents a prev command action.
143:             */
144:            public void setDoPrev(boolean _doprev) {
145:                this ._doprev = _doprev;
146:            }
147:
148:            /**
149:             *Does the binding for the component. This method is called by the framework and should not be called directly
150:             */
151:            public void doBinding() throws Exception {
152:                String dataSource = getDataSource();
153:                String dsName = null;
154:                String dsExp = null;
155:
156:                if (dataSource == null)
157:                    return;
158:
159:                int pos = dataSource.indexOf(":");
160:                if (pos == -1)
161:                    dsName = dataSource;
162:                else {
163:                    dsName = dataSource.substring(0, pos);
164:                    dsExp = dataSource.substring(pos + 1);
165:                }
166:
167:                DataStoreBuffer ds = ((JspController) getPage())
168:                        .getDataSource(dsName);
169:                if (ds == null)
170:                    return;
171:
172:                if (!ds.getAutoBind())
173:                    return;
174:
175:                setHrefExpression(ds, ((JspController) getPage())
176:                        .convertExpressionOperators(dsExp));
177:            }
178:
179:            /**
180:             *Generates the Html for the component. This method is called by the framework and should not be called directly
181:             */
182:            public void generateHTML(TagWriter t, String box, int rowNo)
183:                    throws java.io.IOException {
184:                StringBuffer sb = new StringBuffer();
185:
186:                if (!_visible)
187:                    return;
188:                StringBuffer href = null;
189:                try {
190:                    if (_dsEval != null) {
191:                        if (rowNo > -1) {
192:                            _href = _dsEval.evaluateRowFormat(rowNo);
193:                        } else {
194:                            _href = _dsEval.evaluateRowFormat();
195:                        }
196:                    }
197:                } catch (Exception e) {
198:                }
199:                // sr 12-08-2000 was getting a null pointer exception
200:                if (!Util.isNull(_href)) {
201:                    href = new StringBuffer(_href);
202:                    int hrefLength = href.length();
203:                    for (int i = 0; i < hrefLength; i++) {
204:                        if (href.charAt(i) == ' ') {
205:                            href.setCharAt(i, '+');
206:                        }
207:                    }
208:                }
209:                String row = "";
210:
211:                if (rowNo != -1)
212:                    row = "_" + row + new Integer(rowNo).toString();
213:
214:                StringBuffer sbQuery = new StringBuffer();
215:                if (_hrefparameters && !_doprev) {
216:                    if (getPage().isWMLMaintained()
217:                            && encodeURL(_href).indexOf(
218:                                    PageTag.getSessionIdentifier()
219:                                            + "="
220:                                            + PageTag.getWmlSessId(getPage()
221:                                                    .getSession())) < 0)
222:                        sbQuery.append(PageTag.getSessionIdentifier() + "="
223:                                + PageTag.getWmlSessId(getPage().getSession())
224:                                + "&amp;");
225:                    if (_card != null) {
226:                        WmlFormComponent[] wfca = _card.getInputComponents();
227:                        if (wfca != null) {
228:                            for (int i = 0; i < wfca.length; i++) {
229:                                String sParameter = wfca[i].getName() + "=$("
230:                                        + wfca[i].getName() + ")";
231:                                if (_href.indexOf(sParameter) < 0)
232:                                    sbQuery.append(sParameter + "&amp;");
233:                            }
234:                        }
235:                    }
236:                    if (_method != null && _method.toUpperCase().equals("POST")) {
237:                        if (_href.indexOf("method=post") < 0)
238:                            sbQuery.append("method=post&amp;");
239:                    }
240:                    if (_href.indexOf(getName() + row + "=1") < 0)
241:                        sbQuery.append(getName() + row + "=1&amp;");
242:                    if (sbQuery.toString().endsWith("&amp;"))
243:                        sbQuery.delete(sbQuery.length() - 5, sbQuery.length());
244:                }
245:
246:                sb.append("<do");
247:                sb.append(" id=\"" + getName() + row + "\"");
248:                sb.append(" type=\"" + _type + "\"");
249:                if (_class != null)
250:                    sb.append(" class=\"" + _class + "\"");
251:                if (_label != null)
252:                    sb.append(" label=\"" + _label + "\"");
253:                sb.append(" name=\"" + getName() + row + "\"");
254:                if (_optional)
255:                    sb.append(" optional=\"true\"");
256:                sb.append(">");
257:                if (!_doprev && _href != null && !_href.trim().equals("")) {
258:                    sb.append("<go");
259:                    if (_href.indexOf('?') < 0) {
260:                        if (!sbQuery.toString().trim().equals(""))
261:                            sb
262:                                    .append(" href=\""
263:                                            + encodeURL(href + "?"
264:                                                    + sbQuery.toString())
265:                                            + "\"");
266:                        else
267:                            sb.append(" href=\"" + encodeURL(href) + "\"");
268:                    } else
269:                        sb
270:                                .append(" href=\""
271:                                        + encodeURL(href + "&amp;"
272:                                                + sbQuery.toString()) + "\"");
273:                    if (_sendreferer)
274:                        sb.append(" sendreferer=\"true\"");
275:                    if (_method != null)
276:                        sb.append(" method=\"" + _method + "\"");
277:                    if (_acceptcharset != null)
278:                        sb.append(" accept-charset=\"" + _acceptcharset + "\"");
279:                    sb.append(">");
280:                    if (_postfields) {
281:                        if (_card != null) {
282:                            WmlFormComponent[] wfca = _card
283:                                    .getInputComponents();
284:                            if (wfca != null) {
285:                                for (int i = 0; i < wfca.length; i++)
286:                                    sb.append("\r\n" + wfca[i].getPostForm()
287:                                            + "\r\n");
288:                            }
289:                        }
290:                        if (_method != null
291:                                && _method.toUpperCase().equals("POST"))
292:                            sb
293:                                    .append("\r\n<postfield name=\"method\" value=\"POST\"/>\r\n");
294:                        if (getPage().isWMLMaintained()
295:                                && encodeURL(_href).indexOf(
296:                                        PageTag.getSessionIdentifier()
297:                                                + "="
298:                                                + PageTag
299:                                                        .getWmlSessId(getPage()
300:                                                                .getSession())) < 0)
301:                            sb.append("\r\n<postfield name=\""
302:                                    + PageTag.getSessionIdentifier()
303:                                    + "\" value=\""
304:                                    + PageTag.getWmlSessId(getPage()
305:                                            .getSession()) + "\"/>\r\n");
306:                        sb.append("\r\n<postfield name=\"" + getName() + row
307:                                + "\" value=\"\"/>\r\n");
308:                    }
309:                    sb.append("</go>");
310:                } else {
311:                    if (_doprev) {
312:                        sb.append("<prev>");
313:                    }
314:                }
315:                t.print(sb.toString(), TagWriter.TYPE_BEGIN_TAG);
316:                t.print(box, TagWriter.TYPE_CONTENT);
317:                t.print("</do>", TagWriter.TYPE_END_TAG);
318:            }
319:
320:            /**
321:             * Returns the href for the go tag within the do.
322:             */
323:            public String getHref() {
324:                return _href;
325:            }
326:
327:            /**
328:             * This method gets the DataStoreEvaluator being used for href expressions.
329:             * @return DataStoreEvaluator
330:             * @see DataStoreEvaluator
331:             */
332:            public DataStoreEvaluator getHrefExpression() {
333:                return _dsEval;
334:            }
335:
336:            /**
337:             * Use this method to get the class attribute in the do tag.
338:             */
339:            public String getClassName() {
340:                return _class;
341:            }
342:
343:            /**
344:             * Use this method to get the method for the go tag within the do.
345:             */
346:            public String getMethod() {
347:                return _method;
348:            }
349:
350:            /**
351:             * This method sets Whether or not to sendreferer.
352:             */
353:            public void setSendReferer(boolean sendreferer) {
354:                _sendreferer = sendreferer;
355:            }
356:
357:            /**
358:             * This method sets Whether or not to place the field values as parameters on the href.
359:             */
360:            public void setHrefParameters(boolean hrefparameters) {
361:                _hrefparameters = hrefparameters;
362:            }
363:
364:            /**
365:             * This method sets the accept-charset.
366:             */
367:            public void setAcceptCharset(String acceptcharset) {
368:                _acceptcharset = acceptcharset;
369:            }
370:
371:            /**
372:             * This method sets the method.
373:             */
374:            public void setMethod(String method) {
375:                _method = method;
376:            }
377:
378:            /**
379:             * Sets the href for the go tag in the do tag
380:             * @param href java.lang.String
381:             */
382:            public void setHref(String href) {
383:                _href = href;
384:            }
385:
386:            /**
387:             * This method sets a datastore expression that will be used to compute the href for the link.
388:             * @param ds com.salmonllc.sql.DataStoreBuffer
389:             * @param expression The expression to evaluate
390:             */
391:            public void setHrefExpression(DataStoreBuffer ds,
392:                    DataStoreExpression expression) throws Exception {
393:                try {
394:                    _dsEval = new DataStoreEvaluator(ds, expression);
395:                } catch (Exception e) {
396:                    MessageLog
397:                            .writeErrorMessage(
398:                                    "setHrefExpression(DataStoreBuffer ds, DataStoreExpression expression )",
399:                                    e, this );
400:                    throw e;
401:                }
402:            }
403:
404:            /**
405:             * This method sets a datastore expression that will be used to compute the href for the link.
406:             * @param ds com.salmonllc.sql.DataStoreBuffer
407:             * @param expression java.lang.String
408:             */
409:            public void setHrefExpression(DataStoreBuffer ds, String expression)
410:                    throws Exception {
411:                try {
412:                    _dsEval = new DataStoreEvaluator(ds, expression);
413:                } catch (Exception e) {
414:                    MessageLog
415:                            .writeErrorMessage(
416:                                    "setHrefExpression(DataStoreBuffer ds, String expression )",
417:                                    e, this );
418:                    throw e;
419:                }
420:            }
421:
422:            /**
423:             * This method sets the class for the do.
424:             */
425:            public void setClassName(String className) {
426:                _class = className;
427:            }
428:
429:            /**
430:             * This method sets the card that this do tag is within.
431:             */
432:            public void setCard(WmlCard card) {
433:                _card = card;
434:            }
435:
436:            /**
437:             *Processes the parms of the submitted form. This method is called by the framework and should not be called directly
438:             */
439:            public boolean processParms(Hashtable parms, int rowNo)
440:                    throws Exception {
441:                String name = getName();
442:                if (rowNo > -1)
443:                    name += "_" + rowNo;
444:
445:                if (parms.get(name) != null) {
446:                    _rowNo = rowNo;
447:                    return true;
448:                }
449:
450:                return false;
451:            }
452:
453:            /**
454:             * This method adds a listener the will be notified when this do action causes the page to be submitted.
455:             * @param l The listener to add.
456:             */
457:            public void addSubmitListener(SubmitListener l) {
458:                if (_listeners == null)
459:                    _listeners = new Vector();
460:
461:                for (int i = 0; i < _listeners.size(); i++) {
462:                    if (((SubmitListener) _listeners.elementAt(i)) == l)
463:                        return;
464:                }
465:
466:                _listeners.addElement(l);
467:            }
468:
469:            /**
470:             *Executes any events due to this component. This method is called by the framework and should not be called directly
471:             */
472:            public boolean executeEvent(int type) throws Exception {
473:                if (type != EVENT_SUBMIT)
474:                    return true;
475:
476:                if (_listeners == null)
477:                    return true;
478:
479:                SubmitEvent e = new SubmitEvent(getPage(), this , getName(),
480:                        getFullName(), _rowNo);
481:
482:                for (int i = 0; i < _listeners.size(); i++) {
483:                    SubmitListener l = (SubmitListener) _listeners.elementAt(i);
484:                    e.setNextListener(_listeners.size() > (i + 1) ? _listeners
485:                            .elementAt(i + 1) : null);
486:                    if (!l.submitPerformed(e))
487:                        return false;
488:                }
489:
490:                return true;
491:            }
492:
493:            /**
494:             * This method removes a listener from the list that will be notified if this button causes the page to be submitted.
495:             * @param l The listener to remove.
496:             */
497:            public void removeSubmitListener(SubmitListener l) {
498:                if (_listeners == null)
499:                    return;
500:
501:                for (int i = 0; i < _listeners.size(); i++) {
502:                    if (((SubmitListener) _listeners.elementAt(i)) == l) {
503:                        _listeners.removeElementAt(i);
504:                        return;
505:                    }
506:                }
507:            }
508:
509:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.