Source Code Cross Referenced for ContainmentFormChildFixer.java in  » Web-Framework » RSF » uk » org » ponder » rsf » componentprocessor » 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 » Web Framework » RSF » uk.org.ponder.rsf.componentprocessor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Nov 2, 2005
003:         */
004:        package uk.org.ponder.rsf.componentprocessor;
005:
006:        import java.util.Iterator;
007:
008:        import uk.org.ponder.beanutil.IterableBeanLocator;
009:        import uk.org.ponder.rsf.components.ComponentList;
010:        import uk.org.ponder.rsf.components.UIBound;
011:        import uk.org.ponder.rsf.components.UICommand;
012:        import uk.org.ponder.rsf.components.UIComponent;
013:        import uk.org.ponder.rsf.components.UIContainer;
014:        import uk.org.ponder.rsf.components.UIForm;
015:        import uk.org.ponder.rsf.components.UIParameter;
016:        import uk.org.ponder.rsf.request.EarlyRequestParser;
017:        import uk.org.ponder.rsf.request.SubmittedValueEntry;
018:        import uk.org.ponder.rsf.util.RSFUtil;
019:        import uk.org.ponder.rsf.viewstate.ViewParameters;
020:        import uk.org.ponder.rsf.viewstate.ViewParamsCodec;
021:        import uk.org.ponder.saxalizer.SAXalizerMappingContext;
022:        import uk.org.ponder.stringutil.StringList;
023:        import uk.org.ponder.util.Logger;
024:
025:        /**
026:         * A fixer to be run BEFORE the main form fixer, which implements the HTML/HTTP
027:         * form model whereby ALL nested child controls of the form are submitted. This
028:         * fixer will perform no action if it discovers that the "submittingcontrols"
029:         * fields of {@link uk.org.ponder.rsf.components.UIForm} has already been filled
030:         * in.
031:         * <p>
032:         * This fixer is HTML/HTTP SPECIFIC, and should not execute for other idioms. It
033:         * typically executes as the very first in the pipeline if it executes at all.
034:         * <p>
035:         * Note that it also is responsible for setting the "Submitting Control" packed
036:         * attribute for UICommand objects.
037:         * 
038:         * @author Antranig Basman (antranig@caret.cam.ac.uk)
039:         * 
040:         */
041:        public class ContainmentFormChildFixer implements  ComponentProcessor {
042:
043:            private SAXalizerMappingContext mappingcontext;
044:            private ViewParamsCodec vpcodec;
045:            private FormModel formModel;
046:
047:            public void setFormModel(FormModel formModel) {
048:                this .formModel = formModel;
049:            }
050:
051:            public void setMappingContext(SAXalizerMappingContext mappingcontext) {
052:                this .mappingcontext = mappingcontext;
053:            }
054:
055:            public void setViewParamsCodec(ViewParamsCodec vpcodec) {
056:                this .vpcodec = vpcodec;
057:            }
058:
059:            public void processComponent(UIComponent toprocesso) {
060:                if (toprocesso instanceof  UIForm) {
061:                    UIForm toprocess = (UIForm) toprocesso;
062:                    if (toprocess.submittingcontrols == null) {
063:                        toprocess.submittingcontrols = new StringList();
064:                        registerContainer(toprocess, toprocess);
065:                    }
066:                }
067:            }
068:
069:            private void registerComponent(UIForm toprocess, UIComponent child) {
070:                // TODO: produce some useful diagnostic on an attempt to create a nested
071:                // form. This is "presumably" forbidden in every dialect but HTML, and
072:                // "certainly" forbidden in HTML, even though it actually seems to work
073:                // in practice (apart from double-registration of SUBMITTING_CONTROL &c).
074:                // The problem is there is currently no (portable) place for this
075:                // housekeeping information since we abolished FormModel.
076:                if (child instanceof  UIBound) {
077:                    boolean getform = toprocess.type
078:                            .equals(EarlyRequestParser.RENDER_REQUEST);
079:                    // in the case of an "unmanaged" form, this will generate submitting names
080:                    // that the processor is "not expecting" in repetitious cases.
081:                    UIBound bound = (UIBound) child;
082:                    String fullID = child.getFullID();
083:                    if (bound.willinput) {
084:                        String formID = toprocess.getFullID();
085:
086:                        if (getform) {
087:                            if (bound.valuebinding != null) {
088:                                ViewParameters viewparams = toprocess.viewparams;
089:                                String attrname = vpcodec.getMappingInfo(
090:                                        toprocess.viewparams).pathToAttribute(
091:                                        bound.valuebinding.value);
092:                                if (attrname == null) {
093:                                    Logger.log
094:                                            .warn("Warning: Unable to look up path "
095:                                                    + bound.valuebinding.value
096:                                                    + " in ViewParameters "
097:                                                    + viewparams.getClass()
098:                                                    + " with parseSpec "
099:                                                    + viewparams.getParseSpec()
100:                                                    + ": falling back to ID-based strategy");
101:                                }
102:                                bound.submittingname = attrname;
103:                            }
104:                            if (bound.submittingname == null) {
105:                                bound.submittingname = reduceGETSubmittingName(inferBaseSubmittingName(
106:                                        fullID, formID));
107:                            }
108:                        } else {
109:                            bound.submittingname = fullID;
110:                        }
111:                        toprocess.submittingcontrols.add(fullID);
112:                        formModel.registerChild(toprocess, bound);
113:                    } else {
114:                        // case of a non-inputting control that needs to be nonetheless located
115:                        // on the client side. This is actually the non-HTML default.
116:                        // bound.submittingname = fullID;
117:                        // new interpretation - willinput = NO NAME
118:                    }
119:                }
120:                // TODO: clarify UIForm/UICommand relationship for WAP-style forms.
121:                // Who is to be master!
122:                // we expect that UIForm -> do, UICommand -> go
123:                // http://www.codehelp.co.uk/html/wap1.html
124:                else if (child instanceof  UICommand) {
125:                    toprocess.submittingcontrols.add(child.getFullID());
126:                    formModel.registerChild(toprocess, child);
127:                    // add the notation explaining which control is submitting, when it does
128:                    UICommand command = (UICommand) child;
129:                    command.parameters.add(new UIParameter(
130:                            SubmittedValueEntry.SUBMITTING_CONTROL, child
131:                                    .getFullID()));
132:                    if (command.methodbinding != null) {
133:                        command.parameters.add(new UIParameter(
134:                                SubmittedValueEntry.FAST_TRACK_ACTION,
135:                                command.methodbinding.value));
136:                    }
137:                }
138:                if (child instanceof  UIContainer) {
139:                    registerContainer(toprocess, (UIContainer) child);
140:                }
141:                IterableBeanLocator children = new ComponentChildIterator(
142:                        child, mappingcontext);
143:                for (Iterator childit = children.iterator(); childit.hasNext();) {
144:                    UIComponent nested = (UIComponent) children
145:                            .locateBean((String) childit.next());
146:                    registerComponent(toprocess, nested);
147:                }
148:            }
149:
150:            private static String inferBaseSubmittingName(String fullID,
151:                    String formID) {
152:                return fullID.substring(RSFUtil.commonPath(fullID, formID));
153:            }
154:
155:            private static String reduceGETSubmittingName(String submittingname) {
156:                String[] comps = submittingname.split(":", -1);
157:                submittingname = "";
158:                for (int i = 0; i < comps.length; ++i) {
159:                    // append prefix.localID. for each component that has one
160:                    if ((i % 3) == 2) {
161:                        if (comps[i].length() != 0)
162:                            submittingname += comps[i - 2] + "." + comps[i]
163:                                    + ".";
164:                    }
165:                }
166:                submittingname += comps[comps.length - 1];
167:                // slight "hack" to make cluster components in GET forms work
168:                // correctly - presumably there is only ONE of them that will actually
169:                // try to submit an HTML value.
170:                int hypos = submittingname.indexOf('-');
171:                if (hypos != -1) {
172:                    submittingname = submittingname.substring(0, hypos);
173:                }
174:                return submittingname;
175:            }
176:
177:            private void registerContainer(UIForm toprocess,
178:                    UIContainer toregister) {
179:                ComponentList children = toregister.flattenChildren();
180:                for (int i = 0; i < children.size(); ++i) {
181:                    UIComponent child = children.componentAt(i);
182:                    registerComponent(toprocess, child);
183:                }
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.