Source Code Cross Referenced for HtmlTriStateCheckBox.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) 


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:        package com.salmonllc.html;
021:
022:        /////////////////////////
023:        //$Archive: /SOFIA/SourceCode/com/salmonllc/html/HtmlTriStateCheckBox.java $
024:        //$Author: Dan $ 
025:        //$Revision: 11 $ 
026:        //$Modtime: 6/11/03 4:27p $ 
027:        /////////////////////////
028:
029:        import java.util.Hashtable;
030:
031:        import com.salmonllc.html.events.ValueChangedEvent;
032:        import com.salmonllc.properties.Props;
033:
034:        /**
035:         * This class is used to place a check box component on a page.
036:         */
037:        public class HtmlTriStateCheckBox extends HtmlFormComponent {
038:            private String _fontTagStart;
039:            private String _fontTagEnd;
040:            private String _checkedValue;
041:            private String _unCheckedValue;
042:            private String _mixedCheckedValue;
043:            private String _imageDisabledChecked;
044:            private String _imageDisabledUnchecked;
045:            private String _imageDisabledMixed;
046:            private String _imageChecked;
047:            private String _imageUnchecked;
048:            private String _imageMixed;
049:
050:            /**
051:             * Constructs a new HTMLTextEdit component.
052:             * @param name The name of the component
053:             * @param p The page the component will be placed in.
054:             * @param Unchecked Value A string representation that will be returned from getValue() when the checkbox is unchecked.
055:             * @param Checked Value A string representation that will be returned from getValue() when the checkbox is checked.
056:             * @param Mixed Checked Value A string representation that will be returned from getValue() when the checkbox is mixed checked.
057:             */
058:            public HtmlTriStateCheckBox(String name,
059:                    com.salmonllc.html.HtmlPage p, String checkedValue,
060:                    String unCheckedValue, String mixedCheckedValue) {
061:                this (name, null, p, checkedValue, unCheckedValue,
062:                        mixedCheckedValue);
063:
064:            }
065:
066:            /**
067:             * Constructs a new HTMLTextEdit component.
068:             * @param name The name of the component
069:             * @param theme The theme to use for loading properties.
070:             * @param p The page the component will be placed in.
071:             * @param Unchecked Value A string representation that will be returned from getValue() when the checkbox is unchecked.
072:             * @param Checked Value A string representation that will be returned from getValue() when the checkbox is checked.
073:             * @param Mixed Checked Value A string representation that will be returned from getValue() when the checkbox is mixed checked.
074:             */
075:            public HtmlTriStateCheckBox(String name, String theme,
076:                    com.salmonllc.html.HtmlPage p, String checkedValue,
077:                    String unCheckedValue, String mixedCheckedValue) {
078:                super (name, theme, p);
079:
080:                _checkedValue = checkedValue;
081:                _value = _unCheckedValue = unCheckedValue;
082:                _mixedCheckedValue = mixedCheckedValue;
083:
084:            }
085:
086:            public void generateHTML(java.io.PrintWriter p, int rowNo)
087:                    throws Exception {
088:                if (!_visible)
089:                    return;
090:
091:                String value = getValue(rowNo, true);
092:
093:                int checked = 0;
094:                if (value == null && _checkedValue == null)
095:                    checked = 1;
096:                else if (value == null && _mixedCheckedValue == null)
097:                    checked = 2;
098:                else if (value != null) {
099:                    if (value.equals(_checkedValue))
100:                        checked = 1;
101:                    if (value.equals(_mixedCheckedValue))
102:                        checked = 2;
103:                }
104:                if (!_enabled && (_imageDisabledChecked != null)
105:                        && (_imageDisabledUnchecked != null)
106:                        && (_imageDisabledMixed != null)) {
107:                    String out = "<IMG SRC=\"";
108:                    if (checked == 1)
109:                        out += _imageDisabledChecked;
110:                    else if (checked == 2)
111:                        out += _imageDisabledMixed;
112:                    else
113:                        out += _imageDisabledUnchecked;
114:                    out += "\">";
115:                    if (_fontTagStart != null)
116:                        out = _fontTagStart + out + _fontTagEnd;
117:                    p.print(out);
118:                    return;
119:                }
120:                String name = getFullName();
121:                if (rowNo > -1)
122:                    name += "_" + rowNo;
123:
124:                String sJavascript = "if (" + name + ".value=='0')"
125:                        + "{document." + name + "TRISTATECHECKBOX.src=fnc"
126:                        + getFullName() + "_ImageChecked();" + name
127:                        + ".value='1';return false;}" + "else if (" + name
128:                        + ".value=='1')" + "{document." + name
129:                        + "TRISTATECHECKBOX.src=fnc" + getFullName()
130:                        + "_ImageMixed();" + name + ".value='2';return false;}"
131:                        + " else if (" + name + ".value=='2')" + "{document."
132:                        + name + "TRISTATECHECKBOX.src=fnc" + getFullName()
133:                        + "_ImageUnchecked();" + name
134:                        + ".value='0';return false;}";
135:                String image = _imageUnchecked;
136:                if (checked == 1)
137:                    image = _imageChecked;
138:                else if (checked == 2)
139:                    image = _imageMixed;
140:
141:                String sImagescript = "<SCRIPT LANGUAGE='JavaScript1.1'>\n"
142:                        + getImagesScript() + "\n</SCRIPT>\n";
143:                String tag = "<INPUT TYPE=HIDDEN NAME=\"" + name
144:                        + "\" VALUE=\"" + checked
145:                        + "\"><A HREF=\"\" ONCLICK=\"" + sJavascript
146:                        + "\"><IMG NAME=\"" + name + "TRISTATECHECKBOX\" SRC='"
147:                        + image + "' BORDER=0></A>";
148:
149:                if (_fontTagStart != null)
150:                    tag = _fontTagStart + tag + _fontTagEnd;
151:
152:                p.println(sImagescript + tag);
153:                //	writeFocusScript(p,rowNo);	
154:            }
155:
156:            /**
157:             * This method returns the the String representation that will be returned from getValue() when the checkbox is checked.
158:             */
159:            public String getCheckedValue() {
160:                return _checkedValue;
161:            }
162:
163:            /**
164:             * This method gets the end font tag for the component.
165:             */
166:            public String getFontEndTag() {
167:                return _fontTagEnd;
168:            }
169:
170:            /**
171:             * This method gets the start font tag for the component.
172:             */
173:            public String getFontStartTag() {
174:                return _fontTagStart;
175:            }
176:
177:            /**
178:             * This method returns the the String representation that will be returned from getValue() when the checkbox is checked.
179:             */
180:            public String getMixedCheckedValue() {
181:                return _mixedCheckedValue;
182:            }
183:
184:            /**
185:             * This method returns the the String representation that will be returned from getValue() when the checkbox is not checked.
186:             */
187:            public String getUncheckedValue() {
188:                return _unCheckedValue;
189:            }
190:
191:            public boolean processParms(Hashtable parms, int rowNo)
192:                    throws Exception {
193:                if (!getVisible() || !getEnabled())
194:                    return false;
195:
196:                Object oldValue = _value;
197:
198:                String name = getFullName();
199:                if (rowNo > -1) {
200:                    name += "_" + rowNo;
201:                    if (_dsBuff != null) {
202:                        try {
203:                            oldValue = _dsBuff.getAny(rowNo, _dsColNo);
204:                        } catch (Exception e) {
205:                            oldValue = null;
206:                        }
207:                    }
208:                } else {
209:                    if (_dsBuff != null) {
210:                        try {
211:                            oldValue = _dsBuff.getAny(_dsColNo);
212:                        } catch (Exception e) {
213:                            oldValue = null;
214:                        }
215:                    }
216:                }
217:
218:                String val[] = (String[]) parms.get(name);
219:
220:                _value = _unCheckedValue;
221:                if (val != null) {
222:                    int iVal = new Integer(val[0]).intValue();
223:                    if (iVal == 1)
224:                        _value = _checkedValue;
225:                    else if (iVal == 2)
226:                        _value = _mixedCheckedValue;
227:                }
228:
229:                if (!valuesEqual(oldValue, _value)) {
230:                    String s = null;
231:                    if (oldValue != null)
232:                        s = oldValue.toString();
233:                    ValueChangedEvent e = new ValueChangedEvent(getPage(),
234:                            this , getName(), getFullName(), s, _value, rowNo,
235:                            _dsColNo, _dsBuff);
236:                    addEvent(e);
237:                }
238:
239:                return false;
240:            }
241:
242:            /**
243:             * This method sets the the String representation that will be returned from getValue() when the checkbox is not checked.
244:             */
245:            public void setCheckedValue(String checkedValue) {
246:                _checkedValue = checkedValue;
247:            }
248:
249:            /**
250:             * This method sets the end font tag for the component.
251:             */
252:            public void setFontEndTag(String value) {
253:                _fontTagEnd = value;
254:            }
255:
256:            /**
257:             * This method sets the start font tag for the component.
258:             */
259:            public void setFontStartTag(String value) {
260:                _fontTagStart = value;
261:            }
262:
263:            /**
264:             * This method sets the the String representation that will be returned from getValue() when the checkbox is checked.
265:             */
266:            public void setMixedCheckedValue(String mixedCheckedValue) {
267:                _mixedCheckedValue = mixedCheckedValue;
268:            }
269:
270:            /**
271:             * This method sets the property theme for the component.
272:             * @param theme The theme to use.
273:             */
274:            public void setTheme(String theme) {
275:
276:                super .setTheme(theme);
277:
278:                Props props = getPage().getPageProperties();
279:
280:                _fontTagStart = props.getThemeProperty(theme,
281:                        Props.FONT_TEXT_EDIT + Props.TAG_START);
282:                _fontTagEnd = props.getThemeProperty(theme,
283:                        Props.FONT_TEXT_EDIT + Props.TAG_END);
284:                _imageDisabledChecked = props.getThemeProperty(theme,
285:                        Props.TRISTATECHECKBOX_DISABLED_IMAGE_CHECKED);
286:                _imageDisabledUnchecked = props.getThemeProperty(theme,
287:                        Props.TRISTATECHECKBOX_DISABLED_IMAGE_UNCHECKED);
288:                _imageDisabledMixed = props.getThemeProperty(theme,
289:                        Props.TRISTATECHECKBOX_DISABLED_IMAGE_MIXED);
290:                _imageChecked = props.getThemeProperty(theme,
291:                        Props.TRISTATECHECKBOX_IMAGE_CHECKED);
292:                _imageUnchecked = props.getThemeProperty(theme,
293:                        Props.TRISTATECHECKBOX_IMAGE_UNCHECKED);
294:                _imageMixed = props.getThemeProperty(theme,
295:                        Props.TRISTATECHECKBOX_IMAGE_MIXED);
296:
297:            }
298:
299:            /**
300:             * This method sets the the String representation that will be returned from getValue() when the checkbox is checked.
301:             */
302:            public void setUncheckedValue(String uncheckedValue) {
303:                _unCheckedValue = uncheckedValue;
304:            }
305:
306:            private String getImagesScript() {
307:                String sScript = "";
308:                if (_imageChecked != null && !_imageChecked.equals("")) {
309:                    sScript += "\nvar " + getFullName()
310:                            + "_ImageChecked=new Image();\n";
311:                    sScript += getFullName() + "_ImageChecked.src=\""
312:                            + _imageChecked + "\";\n";
313:                    sScript += "function fnc" + getFullName()
314:                            + "_ImageChecked() {\n";
315:                    sScript += "if (" + getFullName()
316:                            + "_ImageChecked==null) \n";
317:                    sScript += "return \"" + _imageChecked + "\";\n";
318:                    sScript += "else \n";
319:                    sScript += "return " + getFullName()
320:                            + "_ImageChecked.src;\n";
321:                    sScript += "};\n";
322:                }
323:                if (_imageUnchecked != null && !_imageUnchecked.equals("")) {
324:                    sScript += "\nvar " + getFullName()
325:                            + "_ImageUnchecked=new Image();\n";
326:                    sScript += getFullName() + "_ImageUnchecked.src=\""
327:                            + _imageUnchecked + "\";\n";
328:                    sScript += "function fnc" + getFullName()
329:                            + "_ImageUnchecked() {\n";
330:                    sScript += "if (" + getFullName()
331:                            + "_ImageUnchecked==null) \n";
332:                    sScript += "return \"" + _imageUnchecked + "\";\n";
333:                    sScript += "else \n";
334:                    sScript += "return " + getFullName()
335:                            + "_ImageUnchecked.src;\n";
336:                    sScript += "};\n";
337:                }
338:                if (_imageMixed != null && !_imageMixed.equals("")) {
339:                    sScript += "\nvar " + getFullName()
340:                            + "_ImageMixed=new Image();\n";
341:                    sScript += getFullName() + "_ImageMixed.src=\""
342:                            + _imageMixed + "\";\n";
343:                    sScript += "function fnc" + getFullName()
344:                            + "_ImageMixed() {\n";
345:                    sScript += "if (" + getFullName() + "_ImageMixed==null) \n";
346:                    sScript += "return \"" + _imageMixed + "\";\n";
347:                    sScript += "else \n";
348:                    sScript += "return " + getFullName() + "_ImageMixed.src;\n";
349:                    sScript += "};\n";
350:                }
351:                return sScript;
352:            }
353:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.