Source Code Cross Referenced for UISearchField.java in  » ERP-CRM-Financial » SourceTap-CRM » com » sourcetap » sfa » ui » 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 » ERP CRM Financial » SourceTap CRM » com.sourcetap.sfa.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * 
003:         * Copyright (c) 2004 SourceTap - www.sourcetap.com
004:         *
005:         *  The contents of this file are subject to the SourceTap Public License 
006:         * ("License"); You may not use this file except in compliance with the 
007:         * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
008:         * Software distributed under the License is distributed on an  "AS IS"  basis,
009:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
010:         * the specific language governing rights and limitations under the License.
011:         *
012:         * The above copyright notice and this permission notice shall be included
013:         * in all copies or substantial portions of the Software.
014:         *
015:         */
016:
017:        package com.sourcetap.sfa.ui;
018:
019:        //import com.sourcetap.sfa.ui.UIDisplayObject;
020:        //import com.sourcetap.sfa.ui.UIFieldInfo;
021:        import com.sourcetap.sfa.util.UserInfo;
022:
023:        import org.ofbiz.entity.*;
024:        import org.ofbiz.entity.model.*;
025:        import org.ofbiz.base.util.Debug;
026:
027:        import java.util.*;
028:
029:        /**
030:         * This class is used by the UI builder to display a search field on the screen.
031:         *
032:         * @author  <a href='mailto:steve_fowler@sourcetap.com'>Steve Fowler</a>
033:         * @author  <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
034:         */
035:        public class UISearchField {
036:            public static final String module = UISearchField.class.getName();
037:
038:            /**
039:             * Dynamically retrieves values to display as a drop down list when the search field is in list mode.
040:             *
041:             * @author  <a href='mailto:steve_fowler@sourcetap.com'>Steve Fowler</a>
042:             * @author  <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
043:             *
044:             * @param delegator Reference to the OFBIZ delegator being used to connect to the data base
045:             * @param entityName The name of the entity whose instances are to be displayed in the list.
046:             * @param searchField Name of attribute in the listed entity to be compared to the searchValue
047:             * @param searchValue Value entered by the user into the search field.  To be used in a LIKE clause to filter the items in the drop down.
048:             * @param userInfo Reference to user info object containing information about the currently logged-in user
049:             *
050:             * @return String containing the HTML text that will draw the current field on the web page
051:             *
052:             * @see com.sourcetap.sfa.ui.UIWebScreenSection
053:             */
054:            public List getSearchFieldValuesDynamic(GenericDelegator delegator,
055:                    String entityName, String searchField, String searchValue,
056:                    UserInfo userInfo) {
057:                return new LinkedList();
058:            }
059:
060:            /**
061:             * Produces an HTML string to display the search field in search mode.
062:             *
063:             * @author  Chris Maurer
064:             * @author  <a href='mailto:steve_fowler@sourcetap.com'>Steve Fowler</a>
065:             * @author  <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
066:             *
067:             * @param htmlName The name to be used for the current field in the HTML
068:             * @param action Action string defining the current screen mode.  See UIScreenSection for possible values.
069:             * @param fieldInfo Reference to field info object containing attributes of the current field
070:             * @param uiDisplayObject Reference to a display object defined in the data base and attached to the field to be displayed by the UI builder
071:             * @param fieldValue Value stored or to be stored in the data base
072:             * @param tabIndex Tab index (tab order) of the current field on the HTML form
073:             *
074:             * @return String containing the HTML text that will draw the current field on the web page
075:             *
076:             * @see com.sourcetap.sfa.ui.UIWebScreenSection
077:             */
078:            public static String displaySearchValueBox(String htmlName,
079:                    String action, UIFieldInfo fieldInfo,
080:                    UIDisplayObject uiDisplayObject, String fieldValue,
081:                    int tabIndex) {
082:                // Display an input box where the user can type search criteria.
083:                StringBuffer displayHtml = new StringBuffer();
084:                displayHtml.append("<INPUT TYPE=\"TEXT\" ID=\"" + htmlName
085:                        + "\" NAME=\"" + htmlName + "\" TABINDEX=\""
086:                        + String.valueOf(tabIndex) + "\" ");
087:                displayHtml.append(UIWebUtility
088:                        .translateAttribSize(uiDisplayObject.getAttribSize()));
089:                displayHtml.append(UIWebUtility.translateAttribMaxLength(
090:                        uiDisplayObject.getAttribMaxLength(), String
091:                                .valueOf(fieldInfo.getMaxLength())));
092:                displayHtml.append(UIWebUtility
093:                        .translateAttribDisabled(uiDisplayObject
094:                                .getAttribDisabled()));
095:                displayHtml.append(UIWebUtility
096:                        .translateAttribReadOnly(uiDisplayObject
097:                                .getAttribReadOnly()));
098:                displayHtml
099:                        .append(UIWebUtility
100:                                .translateAttribAlign(uiDisplayObject
101:                                        .getAttribAlign()));
102:                displayHtml.append(UIWebUtility
103:                        .translateAttribClass(uiDisplayObject.getAttribClass(
104:                                action, fieldInfo.getIsMandatory())));
105:                displayHtml.append(UIWebUtility
106:                        .translateAttribFieldName(uiDisplayObject
107:                                .getAttribEntitySearchDef()));
108:                displayHtml.append(UIWebUtility
109:                        .translateAttribEntityName(uiDisplayObject
110:                                .getAttribEntity()));
111:                displayHtml.append(UIWebUtility
112:                        .translateAttribIdName(uiDisplayObject
113:                                .getAttribEntityValueDef()));
114:                displayHtml.append(UIWebUtility
115:                        .translateAttribFindClass(uiDisplayObject
116:                                .getAttribEntityFindMethod()));
117:                displayHtml.append(" VALUE='" + fieldValue + "'>");
118:
119:                return displayHtml.toString();
120:            }
121:
122:            /**
123:             * Produces an HTML string to display the search field on a web page being built by the UIWebScreenSection class.
124:             * If the screen is being displayed in read-only mode, this method looks up the specified name value using the
125:             * current value as the primary key, and displays the looked up name instead of a search field.
126:             *
127:             * @author  Chris Maurer
128:             * @author  <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
129:             *
130:             * @param uiDisplayObject Reference to a display object defined in the data base and attached to the field to be displayed by the UI builder
131:             * @param protect Defines wether to show the current field in protected (read-only)_ mode
132:             * @param htmlName The name to be used for the current field in the HTML
133:             * @param fieldValue Value stored or to be stored in the data base
134:             * @param entityDetailsVector Vector of generic values containing the values to be displayed on the screen for all fields
135:             * @param fieldInfo Reference to field info object containing attributes of the current field
136:             * @param action Action string defining the current screen mode.  See UIScreenSection for possible values.
137:             * @param tabIndex Tab index (tab order) of the current field on the HTML form
138:             * @param protect Boolean value defining whether to show the current field in protected (read-only)_ mode
139:             * @param userInfo Reference to user info object containing information about the currently logged-in user
140:             * @param delegator Reference to the OFBIZ delegator being used to connect to the data base
141:             *
142:             * @return String containing the HTML text that will draw the current field on the web page
143:             *
144:             * @see com.sourcetap.sfa.ui.UIWebScreenSection
145:             */
146:            public String displayFieldHtml(UIDisplayObject uiDisplayObject,
147:                    boolean protect, String htmlName, String fieldValue,
148:                    Vector entityDetailsVector, UIFieldInfo fieldInfo,
149:                    String action, int tabIndex, UserInfo userInfo,
150:                    GenericDelegator delegator) {
151:                StringBuffer displayHtml = new StringBuffer();
152:
153:                if (!protect) {
154:                    // Not protected.  Need to display in edit mode.
155:                    // Use a <P> element as a placeholder(?)
156:                    displayHtml.append("<P ID=\"" + htmlName
157:                            + "Holder\" NAME=\"" + htmlName + "Holder\" >\n");
158:
159:                    if ((fieldValue != null)
160:                            && (String.valueOf(fieldValue).trim().length() > 0)) {
161:                        // Field has a value already.  Build an HTML SELECT that includes 2 entries: The one already
162:                        // in the field, and the "search again" value.
163:                        HashMap findMap = UIWebUtility.decodeEntityFindDef(
164:                                uiDisplayObject.getAttribEntityPkFindDef(),
165:                                entityDetailsVector, fieldInfo.getUiAttribute()
166:                                        .getAttributeName());
167:                        ModelEntity entityEntity = delegator
168:                                .getModelEntity(uiDisplayObject
169:                                        .getAttribEntity());
170:                        GenericPK entityPk = new GenericPK(entityEntity,
171:                                findMap);
172:
173:                        //GenericValue entityGenericValue = delegator.findByPrimaryKeyCache(entityPk);
174:                        GenericValue optGV = null;
175:
176:                        try {
177:                            optGV = delegator.findByPrimaryKeyCache(entityPk);
178:                        } catch (GenericEntityException e) {
179:                            displayHtml.append(UIWebUtility
180:                                    .displayFieldReadOnly(uiDisplayObject,
181:                                            htmlName, fieldValue, fieldValue,
182:                                            entityDetailsVector));
183:                            Debug
184:                                    .logError(
185:                                            "[UISearchField.displayFieldHtml] Error searching for the single value to put in the drop down for the serach field: "
186:                                                    + e.getLocalizedMessage(),
187:                                            module);
188:
189:                            return displayHtml.toString();
190:                        }
191:
192:                        if (uiDisplayObject.getAttribEntity().equals("")) {
193:                            displayHtml.append(UIWebUtility
194:                                    .displayFieldReadOnly(uiDisplayObject,
195:                                            htmlName, fieldValue, fieldValue,
196:                                            entityDetailsVector));
197:                            Debug
198:                                    .logError(
199:                                            "[UISearchField.displayFieldHtml] Entity name is required for SEARCH_TEXT display type.",
200:                                            module);
201:
202:                            return displayHtml.toString();
203:                        }
204:
205:                        if (optGV != null) {
206:                            displayHtml.append("<SELECT ID=\"" + htmlName
207:                                    + "\" NAME=\"" + htmlName
208:                                    + "\" TABINDEX=\""
209:                                    + String.valueOf(tabIndex) + "\" ");
210:                            displayHtml.append(UIWebUtility
211:                                    .translateAttribSize(uiDisplayObject
212:                                            .getAttribSize()));
213:                            displayHtml.append(UIWebUtility
214:                                    .translateAttribDisabled(uiDisplayObject
215:                                            .getAttribDisabled()));
216:                            displayHtml.append(UIWebUtility
217:                                    .translateAttribClass(uiDisplayObject
218:                                            .getAttribClass(action, fieldInfo
219:                                                    .getIsMandatory())));
220:                            displayHtml.append(UIWebUtility
221:                                    .translateAttribFieldName(uiDisplayObject
222:                                            .getAttribEntitySearchDef()));
223:                            displayHtml.append(UIWebUtility
224:                                    .translateAttribEntityName(uiDisplayObject
225:                                            .getAttribEntity()));
226:                            displayHtml.append(UIWebUtility
227:                                    .translateAttribIdName(uiDisplayObject
228:                                            .getAttribEntityValueDef()));
229:                            displayHtml.append(UIWebUtility
230:                                    .translateAttribFindClass(uiDisplayObject
231:                                            .getAttribEntityFindMethod()));
232:                            displayHtml.append(">\n");
233:
234:                            String optionValue = String.valueOf(optGV
235:                                    .get(uiDisplayObject
236:                                            .getAttribEntityValueDef()));
237:                            Vector optGVVector = new Vector();
238:                            optGVVector.add(optGV);
239:
240:                            String optionDisplay = UIUtility
241:                                    .decodeEntityDisplayDef(
242:                                            uiDisplayObject
243:                                                    .getAttribEntityDisplayDef(),
244:                                            optGVVector,
245:                                            UIWebUtility
246:                                                    .getAttribFromParamName(htmlName));
247:                            displayHtml.append("<OPTION VALUE=\"" + optionValue
248:                                    + "\"");
249:
250:                            if (optionValue.equals(fieldValue)) {
251:                                displayHtml.append(" SELECTED");
252:                            }
253:
254:                            displayHtml.append(">" + optionDisplay
255:                                    + "</OPTION>\n");
256:                            displayHtml
257:                                    .append("<OPTION VALUE=\"search again\">Search again...</OPTION>\n");
258:                            displayHtml.append("</SELECT>");
259:                        } else {
260:                            // Entity was not found in the data base.  Display the search box so the user can pick a new one.
261:                            displayHtml.append(displaySearchValueBox(htmlName,
262:                                    action, fieldInfo, uiDisplayObject,
263:                                    fieldValue, tabIndex));
264:                        }
265:                    } else {
266:                        // Field value is still blank.  Display an input box where the user can type search criteria.
267:                        displayHtml.append(displaySearchValueBox(htmlName,
268:                                action, fieldInfo, uiDisplayObject, fieldValue,
269:                                tabIndex));
270:                    }
271:
272:                    if (fieldInfo.getIsMandatory()
273:                            && !action
274:                                    .equals(UIScreenSection.ACTION_SHOW_QUERY)
275:                            && !action
276:                                    .equals(UIScreenSection.ACTION_SHOW_QUERY_REPORT)
277:                            && !action
278:                                    .equals(UIScreenSection.ACTION_SHOW_REPORT)) {
279:                        displayHtml.append("*\n");
280:                    }
281:
282:                    displayHtml.append("</p>");
283:                    displayHtml
284:                            .append("<SCRIPT FOR=\""
285:                                    + htmlName
286:                                    + "\" EVENT=\"onblur()\" LANGUAGE=\"JavaScript\" >sendData(this, this.form, '"
287:                                    + action + "');</script>\n");
288:                    displayHtml
289:                            .append("<SCRIPT FOR=\""
290:                                    + htmlName
291:                                    + "\" EVENT=\"onchange()\" LANGUAGE=\"JavaScript\" >searchAgain(this, this.form);</script>\n");
292:
293:                    return displayHtml.toString();
294:                } else {
295:                    // User can't edit right now, so there's no point in showing the list. Just look up the
296:                    // the display value and show it.
297:                    GenericValue linkGenericValue = UIUtility.getReadOnlyValue(
298:                            fieldValue, fieldInfo.getUiAttribute()
299:                                    .getAttributeName(), uiDisplayObject,
300:                            entityDetailsVector, delegator);
301:
302:                    displayHtml
303:                            .append(UIDropDown
304:                                    .getSelectHtmlReadOnly(
305:                                            fieldValue,
306:                                            htmlName,
307:                                            fieldInfo.getUiAttribute()
308:                                                    .getAttributeName(),
309:                                            uiDisplayObject,
310:                                            UIDropDown
311:                                                    .decodeValue(
312:                                                            uiDisplayObject
313:                                                                    .getAttribEntityValueDef(),
314:                                                            uiDisplayObject
315:                                                                    .getAttribEntityDisplayDef(),
316:                                                            UIWebUtility
317:                                                                    .getAttribFromParamName(htmlName),
318:                                                            linkGenericValue),
319:                                            UIWebUtility
320:                                                    .translateAttribAnchorHrefDef(
321:                                                            uiDisplayObject
322:                                                                    .getAttribAnchorHrefDef(),
323:                                                            entityDetailsVector,
324:                                                            UIWebUtility
325:                                                                    .getAttribFromParamName(htmlName)),
326:                                            UIWebUtility
327:                                                    .translateAttribAnchorTarget(uiDisplayObject
328:                                                            .getAttribAnchorTarget()),
329:                                            delegator));
330:
331:                    return displayHtml.toString();
332:                }
333:            }
334:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.