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