Source Code Cross Referenced for HtmlEMailComponent.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:        package com.salmonllc.html;
002:
003:        /////////////////////////
004:        //$Archive: /SOFIA/SourceCode/com/salmonllc/html/HtmlEMailComponent.java $
005:        //$Author: Dan $ 
006:        //$Revision: 11 $ 
007:        //$Modtime: 10/20/03 3:38p $ 
008:        /////////////////////////
009:        import java.util.Hashtable;
010:
011:        import com.salmonllc.html.events.ValueChangedEvent;
012:
013:        /**
014:         * Implements an entry field for an email address
015:         */
016:        public class HtmlEMailComponent extends HtmlFormComponent {
017:            protected HtmlTextEdit _email;
018:            private String _EMail;
019:            private int _size = 20, _maxlength = 50, _minlength = 7;
020:
021:            /**
022:             * EMailComponent constructor.
023:             *
024:             * @param name		Name of component.
025:             * @param p			Page containing component.
026:             * @param phoneSeparator	character to display between the 3rd & 4th digit of the phone.
027:             */
028:            public HtmlEMailComponent(String name, HtmlPage p) {
029:                this (name, p, 7);
030:
031:            }
032:
033:            /**
034:             * EMailComponent constructor.
035:             * @param name java.lang.String
036:             * @param p com.salmonllc.html.HtmlPage
037:             * @param minLength int
038:             */
039:            public HtmlEMailComponent(String name, HtmlPage p, int minLength) {
040:                super (name, p);
041:                _email = new HtmlTextEdit(name, p);
042:                _email.setGenerateNewline(false);
043:                _email.setSize(_size);
044:                _email.setMaxLength(_maxlength);
045:                setMinLength(minLength);
046:            }
047:
048:            public void generateHTML(java.io.PrintWriter p, int row)
049:                    throws Exception {
050:                // It is essential to call getValue() here because there may be a ValueChanged
051:                // event in the queue for this object, which needs to be removed, which getValue()
052:                // does.  The secondary calls to getValue() from the container will not
053:                // do this because there are no events associated with them.
054:                String val = getValue(row, true);
055:                if (val == null) {
056:                    _email.setValue(null, row);
057:                } else {
058:                    String sVal;
059:                    if (_dsBuff != null) {
060:                        if (row >= 0)
061:                            sVal = _dsBuff.getString(row, _dsColNo);
062:                        else
063:                            sVal = _dsBuff.getString(_dsColNo);
064:                    } else
065:                        sVal = val;
066:                    _email.setValue(sVal, row);
067:                }
068:                _email.generateHTML(p, row);
069:                if (_visible && _enabled)
070:                    p.println("");
071:            }
072:
073:            /**
074:             * Returns the sub-component to be used for setting focus.
075:             * @return com.salmonllc.html.HtmlComponent
076:             */
077:            public HtmlComponent getFocus() {
078:                return _email;
079:            }
080:
081:            /**
082:             * Returns whether the e-mail entered is valid or not.
083:             * @return boolean Indicates whether e-mail is valid or not.
084:             */
085:            public boolean isValid() {
086:
087:                _email.setValue(_EMail);
088:                int atIndex = _EMail.indexOf('@');
089:                if (atIndex < 0)
090:                    return false;
091:                if (_EMail.substring(atIndex + 1).indexOf('@') >= 0)
092:                    return false;
093:                String sBeforeAt = _EMail.substring(0, atIndex);
094:                String sAfterAt = _EMail.substring(atIndex + 1);
095:                if (sBeforeAt.length() < 1)
096:                    return false;
097:                if (sAfterAt.length() < _minlength - 2)
098:                    return false;
099:                int iDotIndex = sAfterAt.indexOf('.');
100:                if (iDotIndex < 0)
101:                    return false;
102:                if (sAfterAt.substring(iDotIndex + 1).length() < 1)
103:                    return false;
104:                return true;
105:            }
106:
107:            public boolean processParms(Hashtable parms, int rowNo)
108:                    throws Exception {
109:
110:                if (!getVisible() || !getEnabled())
111:                    return false;
112:
113:                // Determine the old value from both edit fields.
114:
115:                String oldValue;
116:                if (_dsBuff == null) {
117:                    oldValue = _email.getValue();
118:                } else {
119:                    String s;
120:                    if (rowNo > -1)
121:                        s = _dsBuff.getString(rowNo, _dsColNo);
122:                    else
123:                        s = _dsBuff.getString(_dsColNo);
124:                    if (s == null)
125:                        oldValue = null;
126:                    else
127:                        oldValue = s;
128:                }
129:
130:                // Determine the new value from both edit fields.
131:
132:                String newValue;
133:                String name1 = _email.getFullName();
134:                if (rowNo > -1)
135:                    name1 += "_" + rowNo;
136:                String val[] = (String[]) parms.get(name1);
137:                if (val != null) {
138:                    _EMail = newValue = val[0].trim();
139:                    if (newValue.equals(""))
140:                        newValue = null;
141:                } else
142:                    newValue = null;
143:
144:                // Compare old and new values and possibly create a ValueChangedEvent.
145:                if (!valuesEqual(oldValue, newValue)) {
146:                    ValueChangedEvent e = new ValueChangedEvent(getPage(),
147:                            this , getName(), getFullName(), oldValue, newValue,
148:                            rowNo, _dsColNo, _dsBuff);
149:                    addEvent(e);
150:                }
151:                return false;
152:            }
153:
154:            public void reset() {
155:                super .reset();
156:                _email.reset();
157:            }
158:
159:            /**
160:             * Specifies the Style Class to be used for the EMail Component.
161:             * Creation date: (7/19/01 8:41:20 AM)
162:             * @param sClass java.lang.String A name of a class in Html to be used by this component
163:             */
164:            public void setClassName(String sClass) {
165:                super .setClassName(sClass);
166:                _email.setClassName(sClass);
167:            }
168:
169:            /**
170:             * Sets the font end tag for disabled mode.
171:             * @param tag java.lang.String
172:             */
173:            public void setDisabledFontEndTag(String tag) {
174:                _email.setDisabledFontEndTag(tag);
175:            }
176:
177:            /**
178:             * Sets the font tag for disabled mode.
179:             * @param tag java.lang.String
180:             */
181:            public void setDisabledFontStartTag(String tag) {
182:                _email.setDisabledFontStartTag(tag);
183:            }
184:
185:            /**
186:             * Enables or disables the ability of this component to respond to user input.
187:             * @param editable boolean
188:             */
189:            public void setEnabled(boolean enabled) {
190:                super .setEnabled(enabled);
191:                _email.setEnabled(enabled);
192:            }
193:
194:            /**
195:             * Sets the Max Length for the E-Mail.
196:             * @param maxLength int
197:             */
198:            public void setMaxLength(int maxLength) {
199:                _email.setMaxLength(maxLength);
200:            }
201:
202:            /**
203:             * This method sets the minimum length an email address can be default is 7
204:             * @param minLength int
205:             */
206:            public void setMinLength(int minLength) {
207:                _minlength = minLength;
208:            }
209:
210:            /**
211:             * Specifies the parent component for this E-Mail Component.
212:             * Creation date: (7/19/01 8:41:20 AM)
213:             * @param sClass java.lang.String A name of a class in Html to be used by this component
214:             */
215:            public void setParent(HtmlComponent parent) {
216:                super .setParent(parent);
217:                // This is necessary for the name to be generated correctly, else the leading
218:                // sequence of parent names will be lost.
219:                _email.setParent(parent);
220:
221:            }
222:
223:            /**
224:             * Set the size of the E-Mail Component.
225:             * @param size int
226:             */
227:            public void setSize(int size) {
228:                _email.setSize(size);
229:            }
230:
231:            /**
232:             * @returns the access key html attribute
233:             */
234:            public String getAccessKey() {
235:                return _email.getAccessKey();
236:            }
237:
238:            /**
239:             * @returns the read only html attribute
240:             */
241:            public boolean getReadOnly() {
242:                return _email.getReadOnly();
243:            }
244:
245:            /**
246:             * @returns the tab index html attribute
247:             */
248:            public int getTabIndex() {
249:                return _email.getTabIndex();
250:            }
251:
252:            /**
253:             * @param sets the access key html attribute
254:             */
255:            public void setAccessKey(String val) {
256:                _email.setAccessKey(val);
257:            }
258:
259:            /**
260:             * @param sets the read only html attribute
261:             */
262:            public void setReadOnly(boolean val) {
263:                _email.setReadOnly(val);
264:            }
265:
266:            /**
267:             * @param sets the tab index html attribute. You can also pass TAB_INDEX_DEFAULT to use the default tab index for the component or TAB_INDEX_NONE to keep this component from being tabbed to
268:             */
269:            public void setTabIndex(int val) {
270:                _email.setTabIndex(val);
271:            }
272:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.