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


0001:        //** Copyright Statement ***************************************************
0002:        //The Salmon Open Framework for Internet Applications (SOFIA)
0003:        // Copyright (C) 1999 - 2002, Salmon LLC
0004:        //
0005:        // This program is free software; you can redistribute it and/or
0006:        // modify it under the terms of the GNU General Public License version 2
0007:        // as published by the Free Software Foundation;
0008:        // 
0009:        // This program is distributed in the hope that it will be useful,
0010:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
0011:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012:        // GNU General Public License for more details.
0013:        // 
0014:        // You should have received a copy of the GNU General Public License
0015:        // along with this program; if not, write to the Free Software
0016:        // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
0017:        // 
0018:        // For more information please visit http://www.salmonllc.com
0019:        //** End Copyright Statement ***************************************************
0020:        package com.salmonllc.html;
0021:
0022:        /////////////////////////
0023:        //$Archive: /SOFIA/SourceCode/com/salmonllc/html/HtmlApplet.java $
0024:        //$Author: Dan $
0025:        //$Revision: 19 $
0026:        //$Modtime: 6/11/03 4:39p $
0027:        /////////////////////////
0028:
0029:        import java.io.*;
0030:        import java.util.*;
0031:
0032:        import com.salmonllc.util.*;
0033:        import com.salmonllc.sql.DataStoreBuffer;
0034:        import com.salmonllc.sql.DataStoreEvaluator;
0035:        import com.salmonllc.sql.DBConnection;
0036:        import com.salmonllc.jsp.JspController;
0037:
0038:        /**
0039:         * This component will construct an applet tag.
0040:         */
0041:        public class HtmlApplet extends HtmlComponent {
0042:            public static final int SIZE_PERCENT = 0;
0043:            public static final int SIZE_PIXELS = 1;
0044:
0045:            public static final String ALIGN_LEFT = "LEFT";
0046:            public static final String ALIGN_RIGHT = "RIGHT";
0047:            public static final String ALIGN_TOP = "TOP";
0048:            public static final String ALIGN_ABSMIDDLE = "ABSMIDDLE";
0049:            public static final String ALIGN_ABSBOTTOM = "ABSBOTTOM";
0050:            public static final String ALIGN_TEXTTOP = "TEXTTOP";
0051:            public static final String ALIGN_MIDDLE = "MIDDLE";
0052:            public static final String ALIGN_BASELINE = "BASELINE";
0053:            public static final String ALIGN_BOTTOM = "BOTTOM";
0054:
0055:            String _code, _codeBase, _archive, _alt, _align, _object, _title;
0056:            String _width = "-1", _height = "-1", _hSpace = "-1",
0057:                    _vSpace = "-1";
0058:            String _mayScript = "false";
0059:            Hashtable _parms;
0060:            int _sizeOption = SIZE_PIXELS;
0061:            String _value, _state;
0062:            String _interactWithForm = "false";
0063:            String _usePlugin = "false";
0064:            String _pluginClassId = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93",
0065:                    _pluginCodeBase = "http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0";
0066:            String _type = "application/x-java-applet;version=1.3";
0067:            String _pluginsPage = "http://java.sun.com/products/plugin/1.3/plugin-install.html";
0068:            String _nojavasupport = "Browser has No Java Support for Applet.";
0069:            String _appletAttributesDatasource;
0070:            DataStoreBuffer _dsBuff;
0071:            String _visible;
0072:
0073:            /**
0074:             * Creates a new HtmlApplet
0075:             * @param name The name of the applet
0076:             * @param className The class name of the applet
0077:             * @param p The page the applet will go in.
0078:             */
0079:            public HtmlApplet(String name, String className,
0080:                    com.salmonllc.html.HtmlPage p) {
0081:                super (name, p);
0082:                _code = className;
0083:                p.addApplet(this );
0084:            }
0085:
0086:            /**
0087:             * Creates a new HtmlApplet
0088:             * @param name The name of the applet
0089:             * @param className The class name of the applet
0090:             * @param codeBase The directory where the applets resources will be found
0091:             * @param width The width of the applet
0092:             * @param height The height of the applet
0093:             * @param p The page the applet will go in.
0094:             */
0095:            public HtmlApplet(String name, String className, String codeBase,
0096:                    int width, int height, com.salmonllc.html.HtmlPage p) {
0097:                this (name, className, codeBase, p);
0098:                _width = "" + width;
0099:                _height = "" + height;
0100:            }
0101:
0102:            /**
0103:             * Creates a new HtmlApplet
0104:             * @param name The name of the applet
0105:             * @param className The class name of the applet
0106:             * @param codeBase The directory where the applets resources will be found
0107:             * @param width The width of the applet
0108:             * @param height The height of the applet
0109:             * @param p The page the applet will go in.
0110:             */
0111:            public HtmlApplet(String name, String className, String codeBase,
0112:                    int width, int height, String jarFile,
0113:                    com.salmonllc.html.HtmlPage p) {
0114:                this (name, className, codeBase, p);
0115:                _width = "" + width;
0116:                _height = "" + height;
0117:                _archive = jarFile;
0118:
0119:            }
0120:
0121:            /**
0122:             * Creates a new HtmlApplet
0123:             * @param name The name of the applet
0124:             * @param className The class name of the applet
0125:             * @param codeBase The directory where the applets resources will be found
0126:             * @param p The page the applet will go in.
0127:             */
0128:            public HtmlApplet(String name, String className, String codeBase,
0129:                    com.salmonllc.html.HtmlPage p) {
0130:                this (name, className, p);
0131:                _codeBase = codeBase;
0132:
0133:            }
0134:
0135:            /**
0136:             * This method removes a parameter used by the applet.
0137:             */
0138:
0139:            public void clearParm(String name) {
0140:                if (_parms == null)
0141:                    return;
0142:
0143:                if (name == null)
0144:                    return;
0145:
0146:                _parms.remove(name);
0147:            }
0148:
0149:            public void generateHTML(PrintWriter p, int rowNo) throws Exception {
0150:                if (!getVisible())
0151:                    return;
0152:                int iBrowserVersion = getPage().getBrowserVersion();
0153:                int iBrowserType = getPage().getBrowserType();
0154:                boolean bUsePlugIn = Boolean.valueOf(
0155:                        evaluateExpression(_usePlugin, rowNo)).booleanValue();
0156:
0157:                if (!bUsePlugIn
0158:                        || (bUsePlugIn && (iBrowserType != HtmlPage.BROWSER_MICROSOFT && !(iBrowserType == HtmlPage.BROWSER_NETSCAPE && iBrowserVersion < 6)))) {
0159:                    StringBuffer out = new StringBuffer("<APPLET ");
0160:                    out.append("CODE=\"" + evaluateExpression(_code, rowNo)
0161:                            + "\" ");
0162:
0163:                    // CODEBASE
0164:                    String sCodebase = evaluateExpression(_codeBase, rowNo);
0165:                    if (!Util.isNull(sCodebase) && !Util.isEmpty(sCodebase)) {
0166:                        out.append("CODEBASE=\"" + sCodebase + "\" ");
0167:                    }
0168:
0169:                    // ARCHIVE
0170:                    String sArchive = evaluateExpression(_archive, rowNo);
0171:                    if (!Util.isNull(sArchive) && !Util.isEmpty(sArchive)) {
0172:                        out.append("ARCHIVE=\"" + sArchive + "\" ");
0173:                    }
0174:
0175:                    // ALT
0176:                    String sAlt = evaluateExpression(_alt, rowNo);
0177:                    if (!Util.isNull(sAlt) && !Util.isEmpty(sAlt)) {
0178:                        out.append("ALT=\"" + sAlt + "\" ");
0179:                    }
0180:
0181:                    // ALIGN
0182:                    String sAlign = evaluateExpression(_align, rowNo);
0183:                    if (!Util.isNull(sAlign) && !Util.isEmpty(sAlign)) {
0184:                        out.append("ALIGN=\"" + sAlign + "\" ");
0185:                    }
0186:
0187:                    // HEIGHT
0188:                    String sHeight = evaluateExpression(_height, rowNo);
0189:                    if (!sHeight.equals("-1")) {
0190:                        out.append("HEIGHT=\""
0191:                                + sHeight
0192:                                + (_sizeOption == SIZE_PERCENT
0193:                                        && !sHeight.endsWith("%") ? "%" : "")
0194:                                + "\" ");
0195:                    }
0196:
0197:                    // TITLE
0198:                    String sTitle = evaluateExpression(_title, rowNo);
0199:                    if (!Util.isNull(sTitle) && !Util.isEmpty(sTitle)) {
0200:                        out.append("TITLE=\"" + sTitle + "\" ");
0201:                    }
0202:
0203:                    // WIDTH
0204:                    String sWidth = evaluateExpression(_width, rowNo);
0205:                    if (!sWidth.equals("-1")) {
0206:                        out.append("WIDTH=\""
0207:                                + sWidth
0208:                                + (_sizeOption == SIZE_PERCENT
0209:                                        && !sWidth.endsWith("%") ? "%" : "")
0210:                                + "\" ");
0211:                    }
0212:
0213:                    // HSPACE
0214:                    String sHSpace = evaluateExpression(_hSpace, rowNo);
0215:                    if (!sHSpace.equals("-1")) {
0216:                        out.append("HSPACE=\"" + sHSpace + "\" ");
0217:                    }
0218:
0219:                    // VSPACE
0220:                    String sVSpace = evaluateExpression(_vSpace, rowNo);
0221:                    if (!_vSpace.equals("-1")) {
0222:                        out.append("VSPACE=\"" + sVSpace + "\" ");
0223:                    }
0224:
0225:                    String sMayScript = evaluateExpression(_mayScript, rowNo);
0226:                    boolean bMayScript = Boolean.valueOf(sMayScript)
0227:                            .booleanValue();
0228:                    // MAYSCRIPT
0229:                    if (bMayScript) {
0230:                        out.append("MAYSCRIPT ");
0231:                    }
0232:
0233:                    // NAME
0234:                    out.append("NAME=\"" + getFullName(rowNo) + "\">");
0235:                    p.println(out.toString());
0236:                    p.println("<PARAM NAME=\"servletSessionID\" VALUE=\""
0237:                            + getPage().getSession().getId() + "\">");
0238:                    boolean bInteractWithForm = Boolean.valueOf(
0239:                            evaluateExpression(_interactWithForm, rowNo))
0240:                            .booleanValue();
0241:                    if (bInteractWithForm) {
0242:                        String sState = evaluateExpression(_state, rowNo);
0243:                        if (sState != null && sState.trim().length() > 0) {
0244:                            p.println("<PARAM NAME=\"state\" VALUE=\"" + sState
0245:                                    + "\">");
0246:                        }
0247:                        String sValue = evaluateExpression(_value, rowNo);
0248:                        if (sValue != null && sValue.trim().length() > 0) {
0249:                            p.println("<PARAM NAME=\"value\" VALUE=\"" + sValue
0250:                                    + "\">");
0251:                        }
0252:                    }
0253:                    if (_parms != null) {
0254:                        Enumeration keys = _parms.keys();
0255:                        // no need to have in loop
0256:                        String key = null;
0257:                        while (keys.hasMoreElements()) {
0258:                            key = (String) keys.nextElement();
0259:                            p.println("<PARAM NAME=\"" + key + "\" VALUE=\""
0260:                                    + (String) _parms.get(key) + "\">");
0261:                        }
0262:                    }
0263:                    p.println(_nojavasupport);
0264:                    p.println("</APPLET>");
0265:                } else {
0266:                    if (iBrowserType == HtmlPage.BROWSER_MICROSOFT) {
0267:                        StringBuffer out = new StringBuffer("<OBJECT ");
0268:                        out.append("classid=\"");
0269:                        out.append(evaluateExpression(_pluginClassId, rowNo));
0270:                        out.append("\" ");
0271:                        out.append("codebase=\"");
0272:                        out.append(evaluateExpression(_pluginCodeBase, rowNo));
0273:                        out.append("\" ");
0274:
0275:                        // ALIGN
0276:                        String sAlign = evaluateExpression(_align, rowNo);
0277:                        if (!Util.isNull(sAlign) && !Util.isEmpty(sAlign)) {
0278:                            out.append("ALIGN=\"" + sAlign + "\" ");
0279:                        }
0280:
0281:                        // HEIGHT
0282:                        String sHeight = evaluateExpression(_height, rowNo);
0283:                        if (!sHeight.equals("-1")) {
0284:                            out.append("HEIGHT=\""
0285:                                    + sHeight
0286:                                    + (_sizeOption == SIZE_PERCENT
0287:                                            && !sHeight.endsWith("%") ? "%"
0288:                                            : "") + "\" ");
0289:                        }
0290:
0291:                        // TITLE
0292:                        String sTitle = evaluateExpression(_title, rowNo);
0293:                        if (!Util.isNull(sTitle) && !Util.isEmpty(sTitle)) {
0294:                            out.append("TITLE=\"" + sTitle + "\" ");
0295:                        }
0296:
0297:                        // WIDTH
0298:                        String sWidth = evaluateExpression(_width, rowNo);
0299:                        if (!sWidth.equals("-1")) {
0300:                            out
0301:                                    .append("WIDTH=\""
0302:                                            + sWidth
0303:                                            + (_sizeOption == SIZE_PERCENT
0304:                                                    && !sWidth.endsWith("%") ? "%"
0305:                                                    : "") + "\" ");
0306:                        }
0307:
0308:                        // HSPACE
0309:                        String sHSpace = evaluateExpression(_hSpace, rowNo);
0310:                        if (!sHSpace.equals("-1")) {
0311:                            out.append("HSPACE=\"" + sHSpace + "\" ");
0312:                        }
0313:
0314:                        // VSPACE
0315:                        String sVSpace = evaluateExpression(_vSpace, rowNo);
0316:                        if (!_vSpace.equals("-1")) {
0317:                            out.append("VSPACE=\"" + sVSpace + "\" ");
0318:                        }
0319:
0320:                        // NAME
0321:                        out.append("NAME=\"" + getFullName(rowNo) + "\">");
0322:                        out.append("\r\n");
0323:                        out.append("<PARAM NAME=\"code\" VALUE=\"");
0324:                        out.append(evaluateExpression(_code, rowNo));
0325:                        out.append("\">\r\n");
0326:                        out.append("<PARAM NAME=\"type\" VALUE=\"");
0327:                        out.append(evaluateExpression(_type, rowNo));
0328:                        out.append("\">\r\n");
0329:                        // CODEBASE
0330:                        String sCodebase = evaluateExpression(_codeBase, rowNo);
0331:                        if (!Util.isNull(sCodebase) && !Util.isEmpty(sCodebase)) {
0332:                            out.append("<PARAM NAME=\"codebase\" VALUE=\"");
0333:                            out.append(sCodebase);
0334:                            out.append("\">\r\n");
0335:                        }
0336:                        // ARCHIVE
0337:                        String sArchive = evaluateExpression(_archive, rowNo);
0338:                        if (!Util.isNull(sArchive) && !Util.isEmpty(sArchive)) {
0339:                            out.append("<PARAM NAME=\"archive\" VALUE=\"");
0340:                            out.append(sArchive);
0341:                            out.append("\">\r\n");
0342:                        }
0343:                        String sMayScript = evaluateExpression(_mayScript,
0344:                                rowNo);
0345:                        boolean bMayScript = Boolean.valueOf(sMayScript)
0346:                                .booleanValue();
0347:                        // MAYSCRIPT
0348:                        if (bMayScript) {
0349:                            out
0350:                                    .append("<PARAM NAME=\"mayscript\" VALUE=\"true\">\r\n");
0351:                            out
0352:                                    .append("<PARAM NAME=\"scriptable\" VALUE=\"true\">\r\n");
0353:                        }
0354:
0355:                        // NAME
0356:                        out.append("<PARAM NAME=\"NAME\" VALUE=\""
0357:                                + getFullName(rowNo) + "\">\r\n");
0358:
0359:                        p.println(out.toString());
0360:                        p.println("<PARAM NAME=\"servletSessionID\" VALUE=\""
0361:                                + getPage().getSession().getId() + "\">");
0362:                        boolean bInteractWithForm = Boolean.valueOf(
0363:                                evaluateExpression(_interactWithForm, rowNo))
0364:                                .booleanValue();
0365:                        if (bInteractWithForm) {
0366:                            String sState = evaluateExpression(_state, rowNo);
0367:                            if (sState != null && sState.trim().length() > 0) {
0368:                                p.println("<PARAM NAME=\"state\" VALUE=\""
0369:                                        + sState + "\">");
0370:                            }
0371:                            String sValue = evaluateExpression(_value, rowNo);
0372:                            if (sValue != null && sValue.trim().length() > 0) {
0373:                                p.println("<PARAM NAME=\"value\" VALUE=\""
0374:                                        + sValue + "\">");
0375:                            }
0376:                        }
0377:                        if (_parms != null) {
0378:                            Enumeration keys = _parms.keys();
0379:                            // no need to have in loop
0380:                            String key = null;
0381:                            while (keys.hasMoreElements()) {
0382:                                key = (String) keys.nextElement();
0383:                                p.println("<PARAM NAME=\"" + key
0384:                                        + "\" VALUE=\""
0385:                                        + (String) _parms.get(key) + "\">");
0386:                            }
0387:                        }
0388:                        p.println(_nojavasupport);
0389:                        p.println("</OBJECT>");
0390:                    } else if (getPage().getBrowserType() == HtmlPage.BROWSER_NETSCAPE) {
0391:                        StringBuffer out = new StringBuffer("<EMBED ");
0392:
0393:                        // ALIGN
0394:                        String sAlign = evaluateExpression(_align, rowNo);
0395:                        if (!Util.isNull(sAlign) && !Util.isEmpty(sAlign)) {
0396:                            out.append("ALIGN=\"" + sAlign + "\" ");
0397:                        }
0398:
0399:                        // HEIGHT
0400:                        String sHeight = evaluateExpression(_height, rowNo);
0401:                        if (!sHeight.equals("-1")) {
0402:                            out.append("HEIGHT=\""
0403:                                    + sHeight
0404:                                    + (_sizeOption == SIZE_PERCENT
0405:                                            && !sHeight.endsWith("%") ? "%"
0406:                                            : "") + "\" ");
0407:                        }
0408:
0409:                        // TITLE
0410:                        String sTitle = evaluateExpression(_title, rowNo);
0411:                        if (!Util.isNull(sTitle) && !Util.isEmpty(sTitle)) {
0412:                            out.append("TITLE=\"" + sTitle + "\" ");
0413:                        }
0414:
0415:                        // WIDTH
0416:                        String sWidth = evaluateExpression(_width, rowNo);
0417:                        if (!sWidth.equals("-1")) {
0418:                            out
0419:                                    .append("WIDTH=\""
0420:                                            + sWidth
0421:                                            + (_sizeOption == SIZE_PERCENT
0422:                                                    && !sWidth.endsWith("%") ? "%"
0423:                                                    : "") + "\" ");
0424:                        }
0425:
0426:                        // HSPACE
0427:                        String sHSpace = evaluateExpression(_hSpace, rowNo);
0428:                        if (!sHSpace.equals("-1")) {
0429:                            out.append("HSPACE=\"" + sHSpace + "\" ");
0430:                        }
0431:
0432:                        // VSPACE
0433:                        String sVSpace = evaluateExpression(_vSpace, rowNo);
0434:                        if (!_vSpace.equals("-1")) {
0435:                            out.append("VSPACE=\"" + sVSpace + "\" ");
0436:                        }
0437:
0438:                        // ALT
0439:                        String sAlt = evaluateExpression(_alt, rowNo);
0440:                        if (!Util.isNull(sAlt) && !Util.isEmpty(sAlt)) {
0441:                            out.append("ALT=\"" + sAlt + "\" ");
0442:                        }
0443:
0444:                        // NAME
0445:                        out.append("NAME=\"" + getFullName(rowNo) + "\"");
0446:                        out.append("pluginspage=\"");
0447:                        out.append(evaluateExpression(_pluginsPage, rowNo));
0448:                        out.append("\" ");
0449:                        out.append("code=\"");
0450:                        out.append(evaluateExpression(_code, rowNo));
0451:                        out.append("\" ");
0452:                        out.append("type=\"");
0453:                        out.append(evaluateExpression(_type, rowNo));
0454:                        out.append("\" ");
0455:                        // CODEBASE
0456:                        String sCodebase = evaluateExpression(_codeBase, rowNo);
0457:                        if (!Util.isNull(sCodebase) && !Util.isEmpty(sCodebase)) {
0458:                            out.append("codebase=\"");
0459:                            out.append(sCodebase);
0460:                            out.append("\" ");
0461:                        }
0462:                        // ARCHIVE
0463:                        String sArchive = evaluateExpression(_archive, rowNo);
0464:                        if (!Util.isNull(sArchive) && !Util.isEmpty(sArchive)) {
0465:                            out.append("archive=\"");
0466:                            out.append(sArchive);
0467:                            out.append("\" ");
0468:                        }
0469:
0470:                        String sMayScript = evaluateExpression(_mayScript,
0471:                                rowNo);
0472:                        boolean bMayScript = Boolean.valueOf(sMayScript)
0473:                                .booleanValue();
0474:                        // MAYSCRIPT
0475:                        if (bMayScript) {
0476:                            out.append("mayscript=\"true\" ");
0477:                        }
0478:
0479:                        p.println(out.toString());
0480:                        p.println("servletSessionID=\""
0481:                                + getPage().getSession().getId() + "\" ");
0482:                        boolean bInteractWithForm = Boolean.valueOf(
0483:                                evaluateExpression(_interactWithForm, rowNo))
0484:                                .booleanValue();
0485:                        if (bInteractWithForm) {
0486:                            String sState = evaluateExpression(_state, rowNo);
0487:                            if (sState != null && sState.trim().length() > 0) {
0488:                                p.println("state=\"" + sState + "\" ");
0489:                            }
0490:                            String sValue = evaluateExpression(_value, rowNo);
0491:                            if (sValue != null && sValue.trim().length() > 0) {
0492:                                p.println("value=\"" + sValue + "\" ");
0493:                            }
0494:                        }
0495:                        if (_parms != null) {
0496:                            Enumeration keys = _parms.keys();
0497:                            // no need to have in loop
0498:                            String key = null;
0499:                            while (keys.hasMoreElements()) {
0500:                                key = (String) keys.nextElement();
0501:                                p.println(key + "=\""
0502:                                        + (String) _parms.get(key) + "\" ");
0503:                            }
0504:                        }
0505:                        p.println("><NOEMBED>");
0506:                        p.println(_nojavasupport);
0507:                        p.println("</NOEMBED>");
0508:                        p.println("</EMBED>");
0509:                    }
0510:                }
0511:                boolean bInteractWithForm = Boolean.valueOf(
0512:                        evaluateExpression(_interactWithForm, rowNo))
0513:                        .booleanValue();
0514:                if (bInteractWithForm) {
0515:                    p.println("<INPUT TYPE=\"HIDDEN\" name=\"" + getFullName()
0516:                            + "HIDDENVALUE\">");
0517:                    p.println("<INPUT TYPE=\"HIDDEN\" name=\"" + getFullName()
0518:                            + "HIDDENSTATE\">");
0519:                }
0520:            }
0521:
0522:            /**
0523:             * Gets how the applet will be aligned on the page. Valid Values are ALIGN_LEFT,ALIGN_RIGHT, ALIGN_TOP, ALIGN_ABSMIDDLE, ALIGN_ABSBOTTOM, ALIGN_TEXTTOP, ALIGN_MIDDLE, ALIGN_BASELINE, ALIGN_BOTTOM
0524:             */
0525:            public String getAlign() {
0526:                return _align;
0527:            }
0528:
0529:            /**
0530:             * Gets the text to display for browsers that don't support java.
0531:             */
0532:            public String getAltText() {
0533:                return _alt;
0534:            }
0535:
0536:            /**
0537:             * Gets the Datasource which has the Applet Attributes
0538:             */
0539:            public String getAppletAttributesDatasource() {
0540:                return _appletAttributesDatasource;
0541:            }
0542:
0543:            /**
0544:             * Sets the name for the jar file that contains the applet and related classes.
0545:             */
0546:            public String getArchive() {
0547:                return _archive;
0548:            }
0549:
0550:            /**
0551:             * This method gets the name for the applet class.
0552:             */
0553:            public String getClassName() {
0554:                return _code;
0555:            }
0556:
0557:            /**
0558:             * Gets the directory containing the applet class file and any resources the applet needs. The value is a URL for an absolute or a relative pathname. An absolute URL is used as is without modification and is not affected by the document's BASE tag. A relative CODEBASE attribute is relative to the document's base URL defined by the BASE tag. If the document does not define a BASE tag, it is relative to the directory containing the HTML file.
0559:             */
0560:            public String getCodeBase() {
0561:                return _codeBase;
0562:            }
0563:
0564:            /**
0565:             * Gets the height of the applet
0566:             */
0567:            public int getHeight() {
0568:                return Integer.parseInt(_height);
0569:            }
0570:
0571:            /**
0572:             * Gets the horizontal space of the applet
0573:             */
0574:            public int getHSpace() {
0575:                return Integer.parseInt(_hSpace);
0576:            }
0577:
0578:            /**
0579:             * If the value is true if the applet will interact with the HTML form that it's in.
0580:             */
0581:            public boolean getInteractWithForm() {
0582:                return Boolean.valueOf(_interactWithForm).booleanValue();
0583:            }
0584:
0585:            /**
0586:             * This method gets whether the applet can be accessed via javaScript in the browser.
0587:             */
0588:            public boolean getMayScript() {
0589:                return Boolean.valueOf(_mayScript).booleanValue();
0590:            }
0591:
0592:            /**
0593:             * Gets the No Java Support String that is displayed in  browsers which cannot support applets.
0594:             */
0595:            public String getNoJavaSupport() {
0596:                return _nojavasupport;
0597:            }
0598:
0599:            /**
0600:             * Gets the object attribute of the applet. It specifies the serialized Java Applet.
0601:             */
0602:            public String getObject() {
0603:                return _object;
0604:            }
0605:
0606:            /**
0607:             * This method gets a parameter used by the applet.
0608:             */
0609:
0610:            public String getParm(String name) {
0611:                if (_parms == null)
0612:                    return null;
0613:
0614:                if (name == null)
0615:                    return null;
0616:
0617:                return (String) _parms.get(name);
0618:            }
0619:
0620:            /**
0621:             * Gets the Java Plug-in Class ID. Used by I.E. <Object Tag>
0622:             */
0623:            public String getPluginClassId() {
0624:                return _pluginClassId;
0625:            }
0626:
0627:            /**
0628:             * Gets the Java Plug-in Code Base. Used by I.E. <Object Tag>
0629:             */
0630:            public String getPluginCodeBase() {
0631:                return _pluginCodeBase;
0632:            }
0633:
0634:            /**
0635:             * Gets the Java Plug-in Download Page. Used by Netscape <Embed Tag>
0636:             */
0637:            public String getPluginsPage() {
0638:                return _pluginsPage;
0639:            }
0640:
0641:            /**
0642:             * Gets the SizeOption of the applet. Valid values are SIZE_PIXELS and SIZE_PERCENT
0643:             */
0644:            public int getSizeOption() {
0645:                return _sizeOption;
0646:            }
0647:
0648:            /**
0649:             * Gets the state attribute of the applet.
0650:             */
0651:            public String getState() {
0652:                return _state;
0653:            }
0654:
0655:            /**
0656:             * Gets the title attribute of the applet.
0657:             */
0658:            public String getTitle() {
0659:                return _title;
0660:            }
0661:
0662:            /**
0663:             * Gets the Java Plug-in Applet Type.
0664:             */
0665:            public String getType() {
0666:                return _type;
0667:            }
0668:
0669:            /**
0670:             * This method gets whether the applet uses the sun plug-in or not.
0671:             */
0672:            public boolean getUsePlugin() {
0673:                return Boolean.valueOf(_usePlugin).booleanValue();
0674:            }
0675:
0676:            /**
0677:             * If the applet can submit a value along with the page this will return it.
0678:             */
0679:            public String getValue() {
0680:                return _value;
0681:            }
0682:
0683:            /**
0684:             * This method gets whether the applet is visible or not.
0685:             */
0686:            public boolean getVisible() {
0687:                return Boolean.valueOf(_visible).booleanValue();
0688:            }
0689:
0690:            /**
0691:             * Gets the vertical space of the applet
0692:             */
0693:            public int getVSpace() {
0694:                return Integer.parseInt(_vSpace);
0695:            }
0696:
0697:            /**
0698:             * gets the width of the applet
0699:             */
0700:            public int getWidth() {
0701:                return Integer.parseInt(_width);
0702:            }
0703:
0704:            public boolean processParms(Hashtable parms, int rowNo)
0705:                    throws Exception {
0706:                String val[] = (String[]) parms.get(getFullName()
0707:                        + "HIDDENVALUE");
0708:                if (val != null)
0709:                    _value = val[0];
0710:                else
0711:                    _value = null;
0712:
0713:                if (_value != null && _value.trim().length() == 0)
0714:                    _value = null;
0715:
0716:                String state[] = (String[]) parms.get(getFullName()
0717:                        + "HIDDENSTATE");
0718:                if (state != null)
0719:                    _state = state[0];
0720:                else
0721:                    _state = null;
0722:
0723:                if (_state != null && _state.trim().length() == 0)
0724:                    _state = null;
0725:
0726:                return false;
0727:            }
0728:
0729:            /**
0730:             * Sets how the applet will be aligned on the page. Valid Values are ALIGN_LEFT,ALIGN_RIGHT, ALIGN_TOP, ALIGN_ABSMIDDLE, ALIGN_ABSBOTTOM, ALIGN_TEXTTOP, ALIGN_MIDDLE, ALIGN_BASELINE, ALIGN_BOTTOM
0731:             */
0732:            public void setAlign(String align) {
0733:                _align = align;
0734:            }
0735:
0736:            /**
0737:             * Sets the text to display for browsers that don't support java.
0738:             */
0739:            public void setAltText(String text) {
0740:                _alt = text;
0741:            }
0742:
0743:            /**
0744:             * Sets the DataStore which has the Applet Attributes
0745:             */
0746:            public void setAppletAttributesDatasource(String sDatasource) {
0747:                if (sDatasource == null || sDatasource.trim().equals(""))
0748:                    return;
0749:                _appletAttributesDatasource = sDatasource;
0750:                if (getPage() instanceof  JspController) {
0751:                    _dsBuff = ((JspController) getPage())
0752:                            .getDataSource(_appletAttributesDatasource);
0753:                }
0754:
0755:            }
0756:
0757:            /**
0758:             * Sets the name for the jar file that contains the applet and related classes.
0759:             */
0760:            public void setArchive(String archive) {
0761:                _archive = archive;
0762:            }
0763:
0764:            /**
0765:             * This method sets the name for the applet class.
0766:             */
0767:            public void setClassName(String className) {
0768:                _code = className;
0769:            }
0770:
0771:            /**
0772:             * Sets the applet code class.
0773:             */
0774:            public void setCode(String code) {
0775:                _code = code;
0776:            }
0777:
0778:            /**
0779:             * Sets the directory containing the applet class file and any resources the applet needs. The value is a URL for an absolute or a relative pathname. An absolute URL is used as is without modification and is not affected by the document's BASE tag. A relative CODEBASE attribute is relative to the document's base URL defined by the BASE tag. If the document does not define a BASE tag, it is relative to the directory containing the HTML file.
0780:             */
0781:            public void setCodeBase(String codeBase) {
0782:                _codeBase = codeBase;
0783:            }
0784:
0785:            /**
0786:             * Sets the height of the applet
0787:             */
0788:            public void setHeight(int height) {
0789:                _height = "" + height;
0790:            }
0791:
0792:            /**
0793:             * Sets the height of the applet
0794:             */
0795:            public void setHeight(String height) {
0796:                _height = height;
0797:            }
0798:
0799:            /**
0800:             * Sets the horizontal space of the applet
0801:             */
0802:            public void setHSpace(int hSpace) {
0803:                _hSpace = "" + hSpace;
0804:            }
0805:
0806:            /**
0807:             * Sets the horizontal space of the applet
0808:             */
0809:            public void setHSpace(String hSpace) {
0810:                _hSpace = hSpace;
0811:            }
0812:
0813:            /**
0814:             * Set the value to true if you want the applet to interact with the HTML form that it's in. Interaction consists of the applet returning a string value to the page when it is submitted (which can be queried via the getValue() method in this object and the page returning a state string to the applet which tells it how to initialize<BR>The applet itself must have 2 public methods for this to work:<BR>public String getValue() - This will return the value that the applet should return to the page. <BR> public String getState() - This method will return a state string to the page. The page will return this string back to the applet the next time it goes back to the browser as an applet parameter: "state". The applet can then restore it's state using the state string specified. This is so the applet can be made to retain it's state across page submits. In addition, two other parameters will be passed to each applet: "value" contains the value of the applet on the server and "servletSessionID" contains the session id of the session on the server.
0815:             */
0816:            public void setInteractWithForm(boolean interact) {
0817:                _interactWithForm = new Boolean(interact).toString();
0818:            }
0819:
0820:            /**
0821:             * Set the value to true if you want the applet to interact with the HTML form that it's in. Interaction consists of the applet returning a string value to the page when it is submitted (which can be queried via the getValue() method in this object and the page returning a state string to the applet which tells it how to initialize<BR>The applet itself must have 2 public methods for this to work:<BR>public String getValue() - This will return the value that the applet should return to the page. <BR> public String getState() - This method will return a state string to the page. The page will return this string back to the applet the next time it goes back to the browser as an applet parameter: "state". The applet can then restore it's state using the state string specified. This is so the applet can be made to retain it's state across page submits. In addition, two other parameters will be passed to each applet: "value" contains the value of the applet on the server and "servletSessionID" contains the session id of the session on the server.
0822:             */
0823:            public void setInteractWithForm(String interact) {
0824:                _interactWithForm = interact;
0825:            }
0826:
0827:            /**
0828:             * This method sets whether the applet can be accessed via javaScript in the browser.
0829:             */
0830:            public void setMayScript(boolean mayScript) {
0831:                _mayScript = new Boolean(mayScript).toString();
0832:            }
0833:
0834:            /**
0835:             * This method sets whether the applet can be accessed via javaScript in the browser.
0836:             */
0837:            public void setMayScript(String mayScript) {
0838:                _mayScript = mayScript;
0839:            }
0840:
0841:            /**
0842:             * Sets the No Java Support String that is displayed in  browsers which cannot support applets.
0843:             */
0844:            public void setNoJavaSupport(String sNoJavaSupport) {
0845:                _nojavasupport = sNoJavaSupport;
0846:            }
0847:
0848:            /**
0849:             * Sets the object attribute of the applet. It specifies the serialized Java Applet.
0850:             */
0851:            public void setObject(String sObject) {
0852:                _object = sObject;
0853:            }
0854:
0855:            /**
0856:             * This method sets a parameter used by the applet. Name and value cannot be null.
0857:             */
0858:            public void setParm(String name, String value) {
0859:                if (_parms == null)
0860:                    _parms = new Hashtable();
0861:
0862:                if (name == null || value == null)
0863:                    return;
0864:
0865:                _parms.put(name, value);
0866:            }
0867:
0868:            /**
0869:             * Sets the Java Plug-in Class ID. Used by I.E. <Object Tag>
0870:             */
0871:            public void setPluginClassId(String sPluginClassId) {
0872:                _pluginClassId = sPluginClassId;
0873:            }
0874:
0875:            /**
0876:             * Sets the Java Plug-in Code Base. Used by I.E. <Object Tag>
0877:             */
0878:            public void setPluginCodeBase(String sPluginCodeBase) {
0879:                _pluginCodeBase = sPluginCodeBase;
0880:            }
0881:
0882:            /**
0883:             * Sets the Java Plug-in Download Page. Used by Netscape <Embed Tag>
0884:             */
0885:            public void setPluginsPage(String sPluginPage) {
0886:                _pluginsPage = sPluginPage;
0887:            }
0888:
0889:            /**
0890:             * Sets the SizeOption of the applet. Valid values are SIZE_PIXELS and SIZE_PERCENT
0891:             */
0892:            public void setSizeOption(int sizeOption) {
0893:                _sizeOption = sizeOption;
0894:            }
0895:
0896:            /**
0897:             * Sets the state attribute of the applet.
0898:             */
0899:            public void setState(String sState) {
0900:                _state = sState;
0901:            }
0902:
0903:            /**
0904:             * Sets the title attribute of the applet.
0905:             */
0906:            public void setTitle(String sTitle) {
0907:                _title = sTitle;
0908:            }
0909:
0910:            /**
0911:             * Sets the Java Plug-in Applet Type.
0912:             */
0913:            public void setType(String sType) {
0914:                _type = sType;
0915:            }
0916:
0917:            /**
0918:             * This method sets whether the applet uses the sun plug-in or not.
0919:             */
0920:            public void setUsePlugin(boolean bUsePlugIn) {
0921:                _usePlugin = new Boolean(bUsePlugIn).toString();
0922:            }
0923:
0924:            /**
0925:             * This method sets whether the applet uses the sun plug-in or not.
0926:             */
0927:            public void setUsePlugin(String sUsePlugIn) {
0928:                _usePlugin = sUsePlugIn;
0929:            }
0930:
0931:            /**
0932:             * This method sets whether the applet is visible or not.
0933:             */
0934:            public void setVisible(boolean bVisible) {
0935:                _visible = new Boolean(bVisible).toString();
0936:            }
0937:
0938:            /**
0939:             * This method sets whether the applet is visible or not.
0940:             */
0941:            public void setVisible(String sVisible) {
0942:                _visible = sVisible;
0943:            }
0944:
0945:            /**
0946:             * If the applet can display a value this will pass it .
0947:             */
0948:            public void setValue(String value) {
0949:                _value = value;
0950:            }
0951:
0952:            /**
0953:             * Sets the vertical space of the applet
0954:             */
0955:            public void setVSpace(int vSpace) {
0956:                _vSpace = "" + vSpace;
0957:            }
0958:
0959:            /**
0960:             * Sets the vertical space of the applet
0961:             */
0962:            public void setVSpace(String vSpace) {
0963:                _vSpace = vSpace;
0964:            }
0965:
0966:            /**
0967:             * Sets the width of the applet
0968:             */
0969:            public void setWidth(int width) {
0970:                _width = "" + width;
0971:            }
0972:
0973:            /**
0974:             * Sets the width of the applet
0975:             */
0976:            public void setWidth(String width) {
0977:                _width = width;
0978:            }
0979:
0980:            private String evaluateExpression(String sExpression, int iRowNo) {
0981:                if (sExpression == null)
0982:                    return null;
0983:                if (_dsBuff != null) {
0984:                    if (sExpression.startsWith(_appletAttributesDatasource
0985:                            + ":")) {
0986:                        try {
0987:                            DataStoreEvaluator dsEval = new DataStoreEvaluator(
0988:                                    _dsBuff,
0989:                                    sExpression
0990:                                            .substring(_appletAttributesDatasource
0991:                                                    .length() + 1));
0992:                            Object o = null;
0993:                            if (iRowNo == -1)
0994:                                o = dsEval.evaluateRow();
0995:                            else
0996:                                o = dsEval.evaluateRow(iRowNo);
0997:                            return o != null ? o.toString().trim() : null;
0998:                        } catch (Exception e) {
0999:                            MessageLog.writeErrorMessage(
1000:                                    "Unable to evaluate Expression "
1001:                                            + sExpression, e, this );
1002:                        }
1003:                    }
1004:                }
1005:                return sExpression;
1006:            }
1007:
1008:            /**
1009:             * Adds Applet Parameters based on a table with an <BR> integer primary key column (typically an id) and a name and value column.<BR> A simplifying assumption is that each of the following <BR> is the same: <BR> - name of column in the main table which refers to the simple table <BR> - name of integer column in simple table <BR>
1010:             *
1011:             * @param table - name of table to look up names and values from
1012:             * @param nameColumn - column to get name values from
1013:             * @param valueColumn - column to get value values from
1014:             * @param criteria - optional selection criteria
1015:             */
1016:            public void addParameters(String table, String nameColumn,
1017:                    String valueColumn, String criteria) {
1018:                DBConnection connection = null;
1019:
1020:                try {
1021:                    connection = DBConnection.getConnection(getPage()
1022:                            .getApplicationName());
1023:
1024:                    java.sql.Statement s = connection.createStatement();
1025:                    String query = null;
1026:
1027:                    if (criteria != null) {
1028:                        query = "SELECT " + nameColumn + "," + valueColumn
1029:                                + " FROM " + table + " WHERE " + criteria
1030:                                + " ORDER BY ";
1031:
1032:                        query += nameColumn;
1033:                    } else {
1034:                        query = "SELECT " + nameColumn + "," + valueColumn
1035:                                + " FROM " + table + " ORDER BY ";
1036:
1037:                        query += nameColumn;
1038:                    }
1039:
1040:                    java.sql.ResultSet r = s.executeQuery(query);
1041:
1042:                    if (r.next()) {
1043:                        do {
1044:                            setParm(r.getObject(1).toString(), r.getObject(2)
1045:                                    .toString());
1046:                        } while (r.next());
1047:                    }
1048:
1049:                    r.close();
1050:                    s.close();
1051:                } catch (java.sql.SQLException se) {
1052:                    MessageLog.writeErrorMessage("addParameters", se, null);
1053:                } catch (Exception e) {
1054:                    MessageLog.writeErrorMessage("addParameters", e, this );
1055:                } finally {
1056:                    if (connection != null) {
1057:                        connection.freeConnection();
1058:                    }
1059:                }
1060:            }
1061:
1062:            public String getFullName() {
1063:                return getFullName(-1);
1064:            }
1065:
1066:            public String getFullName(int iRowNo) {
1067:                if (_dsBuff != null
1068:                        && getName().startsWith(
1069:                                _appletAttributesDatasource + ":"))
1070:                    return evaluateExpression(getName(), iRowNo);
1071:                if (iRowNo == -1)
1072:                    return super .getFullName();
1073:                return super .getFullName() + "_" + iRowNo;
1074:            }
1075:
1076:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.