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


001:package com.salmonllc.jsp.controller;
002:
003://///////////////////////
004://$Archive: /sofia/sourcecode/com/salmonllc/jsp/controller/ListFormController.java $
005://$Author: Tezgiden $
006://$Revision: 40 $
007://$Modtime: 9/29/03 1:54p $
008://///////////////////////
009:import java.util.*;
010:import java.io.File;
011:
012:import com.salmonllc.forms.ListForm;
013:import com.salmonllc.forms.ListFormListener;
014:import com.salmonllc.html.*;
015:import com.salmonllc.html.events.PageEvent;
016:import com.salmonllc.html.events.SubmitEvent;
017:import com.salmonllc.html.events.SubmitListener;
018:import com.salmonllc.jsp.JspListForm;
019:import com.salmonllc.sql.DataStore;
020:import com.salmonllc.util.MessageLog;
021:import com.salmonllc.properties.Props;
022:
023:/**
024: * ListFormController is used as a Special Controller to generate standard ListForms.
025: * This Controller creates the ListForm and binds all the column cells to the datastore by reading a XML file.
026: * This can be extended to do any other job or to modify any of the component specified in ListForm.
027: * Creation date: (7/20/01 3:20:08 PM)
028: * @author Administrator
029: */
030:public class ListFormController extends BaseListController implements  ListFormListener, SubmitListener
031:{
032:    public boolean searchButton = false;
033:    public boolean addButton = false;
034:    public boolean advanceSearch = false;
035:    int flags = 0;
036:
037:    /**
038:     * Creation date: (7/25/01 11:48:04 AM)
039:     */
040:    private int createFlagsForListForm(int flags)
041:    {
042:        if(_mainCont.getButtons() == null || _mainCont.getButtons().trim().equals(""))
043:        {
044:            return flags;
045:        }
046:
047:        java.util.StringTokenizer st = new java.util.StringTokenizer(_mainCont.getButtons(), "|");
048:
049:        while( st.hasMoreElements()) {
050:
051:            String token = st.nextToken();
052:
053:            if(token.equalsIgnoreCase("ADD"))
054:            {
055:                addButton = true;
056:                continue;
057:            }
058:            if(token.equalsIgnoreCase("SEARCH"))
059:            {
060:                searchButton = true;
061:                continue;
062:            }
063:
064:            if(token.equalsIgnoreCase("ADVANCE_SEARCH") || token.equalsIgnoreCase("ADVANCE") || token.equalsIgnoreCase("ASEARCH"))
065:            {
066:                advanceSearch = true;
067:                continue;
068:            }
069:
070:        }
071:
072:        if(!addButton)
073:            flags |= ListForm.INIT_NO_ADD_BUTTON;
074:
075:        if(!searchButton)
076:            flags |= ListForm.INIT_NO_SEARCH_BUTTON;
077:
078:        if(advanceSearch)
079:            flags |= ListForm.INIT_ADVANCED_SEARCH_ON_SIDE;
080:
081:        return flags;
082:
083:    }
084:
085:    /**
086:     * Recreate the view from the xml definition in the list form and/or URL line params
087:     */
088:    public void defineView() throws java.sql.SQLException, com.salmonllc.sql.DataStoreException {
089:
090:        String datadefinition = _mainCont.getDataDictionary();
091:        String caption = getParameter("caption");
092:        String navBarId = getParameter("NavBarId");
093:
094:        if (getParameter("datadef") != null)
095:            datadefinition = getParameter("datadef");
096:
097:        querystring = "datadef=" + datadefinition + "&redirect=" + getPageName() + "?datadef=" + datadefinition;
098:
099:        if (caption != null)
100:            querystring += "&caption=" + caption;
101:
102:        if (navBarId != null)
103:            querystring += "&NavBarId=" + navBarId;
104:
105:        // Create the Detail Page URL
106:        String detailPage = _mainCont.getDetailPageName() + "?" + querystring;
107:
108:        // XML data path where XML is located
109:        String xmlPath = getPageProperties().getProperty(Props.XML_DATA_PATH);
110:        if (xmlPath != null && !xmlPath.endsWith(File.separator))
111:            xmlPath += File.separator;
112:
113:        writeMessage("XML Path is " + xmlPath);
114:
115:        if (xmlPath == null)
116:            writeMessage("XMLDataPath is missing from properties file");
117:
118:        // Create the Total rather complete path of XML file adding the directory to datadef(XML file name)
119:        String _totaldatadefinition = xmlPath + datadefinition;
120:
121:        _ds = (DataStore)this .getDataSource("dsMain");
122:        if( _ds == null )
123:            _ds = new DataStore(getApplicationName());
124:
125:
126:        // Create the List form with Detail PAge URL - This URL is used when ADD button is clicked
127:        //_listForm = new ListForm(this, detailPage, _ds, createFlagsForListForm(flags, _mainCont));  This code, was using the current object
128:	    // as HtmlPage. In the currewnt object(this) loadProperties() was not executed. therefore, the "_useDisabledAttribute" boolean
129:	    //variable was always "true". that caused all dropdowns to be displayed as "disabled" vies instead of as plain "text".
130:	    _listForm = new ListForm(_mainCont.getPage(), detailPage, _ds, createFlagsForListForm(flags));
131:
132:        if (_listForm != null) {
133:            removePageListener(_listForm);
134:        }
135:
136:        FormBinder binder = new FormBinder(_totaldatadefinition);
137:
138:        // This querystring is used when Link is clicked
139:        _listForm = binder.bindListForm(_listForm, this , querystring);
140:
141:        replaceComponent(_mainCont.getName(), _listForm);
142:
143:	    String sSearchString = getParameter(HtmlLookUpComponent.PARAM_LISTFORM_SEARCH_FILTER_STRING);
144:	    String sSearchCoulmn = getParameter("searchColumn");
145:
146:
147:        _linkComponents = new Vector();
148:        Enumeration enum = _listForm.getComponents();
149:        storeListFormLinkComponents(enum);
150:
151:	    if(sSearchCoulmn!=null && sSearchCoulmn.length()>0 && sSearchString !=null && sSearchString.length()>0){
152:		    enum = _listForm.getComponents();
153:		    HtmlComponent comp = getComponent(sSearchCoulmn);
154:		    if(comp instanceof  HtmlFormComponent)
155:			      ((HtmlFormComponent)comp).setValue(sSearchString);
156:	    }
157:        //get the data
158:        _listForm.doRetrieve();
159:        _ds.gotoFirst();
160:
161:    }
162:    private void storeListFormLinkComponents(Enumeration enum)
163:    {
164:        while(enum.hasMoreElements())
165:        {
166:            HtmlComponent comp = (HtmlComponent)(enum.nextElement());
167:            if (comp instanceof  HtmlLink)
168:                _linkComponents.add(comp);
169:            if(comp instanceof  HtmlContainer)
170:                storeListFormLinkComponents(((HtmlContainer)comp).getComponents());
171:        }
172:    }
173:
174:    /**
175:     * This method was created in VisualAge.
176:     */
177:    public void initialize() throws Exception
178:    {
179:        try
180:        {
181:            super .initialize();
182:
183:            addPageListener(this );
184:
185:            // Assigning to main cont
186:            Enumeration e = getComponentTable().elements();
187:            while (e.hasMoreElements())
188:            {
189:                HtmlComponent comp = (HtmlComponent) e.nextElement();
190:                if (comp instanceof  JspListForm)
191:                {
192:                    _mainCont = (JspListForm) comp;
193:                    break;
194:                }
195:            }
196:
197:        }
198:        catch (Exception e)
199:        {
200:            MessageLog.writeErrorMessage("initialize", e, this );
201:        }
202:    }
203:    /**
204:     * 	This method MUST be OVERRIDDEN in descendant classes to prohibit or restrict
205:     * 	access to a page or some of its components.
206:     * 	@return boolean
207:     */
208:    public boolean pageAccess() {
209:        return true;
210:    }
211:    /**
212:     *	This method is overridden in the descendant class/page.  It is used each time a user re-visits a page after the initial page generation by the initPage and createPage methods.
213:     *	@param p PageEvent
214:     *	@throws Exception
215:     */
216:
217:    public void request(PageEvent p) throws Exception
218:    {
219:        if(!isReferredByCurrentPage())
220:            defineView();
221:
222:        // Set the primary Link after defining the view
223:        super .request(p);
224:    }
225:    /**
226:     *	This method is overridden in the descendant class/page.  It is used each time a user re-visits a page after the initial page generation by the initPage and createPage methods.
227:     *	@param p PageEvent
228:     *	@throws Exception
229:     */
230:
231:    public boolean submitPerformed(SubmitEvent p) throws Exception
232:    {
233:        return false;
234:    }
235:}
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.