Source Code Cross Referenced for AppendIterator.java in  » Web-Framework » struts-2.0.11 » org » apache » struts2 » components » 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 » struts 2.0.11 » org.apache.struts2.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: AppendIterator.java 497654 2007-01-19 00:21:57Z rgielen $
003:         *
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *  http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:        package org.apache.struts2.components;
022:
023:        import java.io.Writer;
024:        import java.util.ArrayList;
025:        import java.util.Iterator;
026:        import java.util.List;
027:
028:        import org.apache.commons.logging.Log;
029:        import org.apache.commons.logging.LogFactory;
030:        import org.apache.struts2.views.annotations.StrutsTag;
031:        import org.apache.struts2.views.annotations.StrutsTagAttribute;
032:        import org.apache.struts2.components.Param.UnnamedParametric;
033:        import org.apache.struts2.util.AppendIteratorFilter;
034:        import org.apache.struts2.util.MakeIterator;
035:
036:        import com.opensymphony.xwork2.util.ValueStack;
037:
038:        /**
039:         * <!-- START SNIPPET: javadoc -->
040:         * <p>Component for AppendIteratorTag, which jobs is to append iterators to form an
041:         * appended iterator whereby entries goes from one iterator to another after each
042:         * respective iterator is exhausted of entries.</p>
043:         *
044:         * <p>For example, if there are 3 iterator appended (each iterator has 3 entries),
045:         * the following will be how the appended iterator entries will be arranged:</p>
046:         *
047:         * <ol>
048:         *      <li>First Entry of the First Iterator</li>
049:         *      <li>Second Entry of the First Iterator</li>
050:         *      <li>Third Entry of the First Iterator</li>
051:         *      <li>First Entry of the Second Iterator</li>
052:         *      <li>Second Entry of the Second Iterator</li>
053:         *      <li>Third Entry of the Second Iterator</li>
054:         *      <li>First Entry of the Third Iterator</li>
055:         *      <li>Second Entry of the Third Iterator</li>
056:         *      <li>Third Entry of the Third ITerator</li>
057:         * </ol>
058:         * <!-- END SNIPPET: javadoc -->
059:         *
060:         * <!-- START SNIPPET: params -->
061:         * <ul>
062:         *      <li>id (String) - the id of which if supplied will have the resultant
063:         *                        appended iterator stored under in the stack's context</li>
064:         * </ul>
065:         * <!-- END SNIPPET: params -->
066:         *
067:         *
068:         * <!-- START SNIPPET: code -->
069:         * public class AppendIteratorTagAction extends ActionSupport {
070:         *
071:         *  private List myList1;
072:         *  private List myList2;
073:         *  private List myList3;
074:         *
075:         *
076:         *  public String execute() throws Exception {
077:         *
078:         *      myList1 = new ArrayList();
079:         *      myList1.add("1");
080:         *      myList1.add("2");
081:         *      myList1.add("3");
082:         *
083:         *      myList2 = new ArrayList();
084:         *      myList2.add("a");
085:         *      myList2.add("b");
086:         *      myList2.add("c");
087:         *
088:         *      myList3 = new ArrayList();
089:         *      myList3.add("A");
090:         *      myList3.add("B");
091:         *      myList3.add("C");
092:         *
093:         *      return "done";
094:         *  }
095:         *
096:         *  public List getMyList1() { return myList1; }
097:         *  public List getMyList2() { return myList2; }
098:         *  public List getMyList3() { return myList3; }
099:         *}
100:         * <!-- END SNIPPET: code -->
101:         *
102:         * <!-- START SNIPPET: example -->
103:         * &lt;s:append id="myAppendIterator"&gt;
104:         *      &lt;s:param value="%{myList1}" /&gt;
105:         *      &lt;s:param value="%{myList2}" /&gt;
106:         *      &lt;s:param value="%{myList3}" /&gt;
107:         * &lt;/s:append&gt;
108:         * &lt;s:iterator value="%{#myAppendIterator}"&gt;
109:         *      &lt;s:property /&gt;
110:         * &lt;/s:iterator&gt;
111:         * <!-- END SNIPPET: example -->
112:         *
113:         *
114:         * @see org.apache.struts2.util.AppendIteratorFilter
115:         * @see org.apache.struts2.views.jsp.iterator.AppendIteratorTag
116:         *
117:         */
118:        @StrutsTag(name="append",tldTagClass="org.apache.struts2.views.jsp.iterator.AppendIteratorTag",description="Append the values of a list of iterators to one iterator")
119:        public class AppendIterator extends Component implements 
120:                UnnamedParametric {
121:
122:            private static final Log _log = LogFactory
123:                    .getLog(AppendIterator.class);
124:
125:            private AppendIteratorFilter appendIteratorFilter = null;
126:            private List _parameters;
127:
128:            public AppendIterator(ValueStack stack) {
129:                super (stack);
130:            }
131:
132:            public boolean start(Writer writer) {
133:                _parameters = new ArrayList();
134:                appendIteratorFilter = new AppendIteratorFilter();
135:
136:                return super .start(writer);
137:            }
138:
139:            public boolean end(Writer writer, String body) {
140:
141:                for (Iterator paramEntries = _parameters.iterator(); paramEntries
142:                        .hasNext();) {
143:
144:                    Object iteratorEntryObj = paramEntries.next();
145:                    if (!MakeIterator.isIterable(iteratorEntryObj)) {
146:                        _log
147:                                .warn("param with value resolved as "
148:                                        + iteratorEntryObj
149:                                        + " cannot be make as iterator, it will be ignored and hence will not appear in the merged iterator");
150:                        continue;
151:                    }
152:                    appendIteratorFilter.setSource(MakeIterator
153:                            .convert(iteratorEntryObj));
154:                }
155:
156:                appendIteratorFilter.execute();
157:
158:                if (getId() != null && getId().length() > 0) {
159:                    getStack().getContext().put(getId(), appendIteratorFilter);
160:                }
161:
162:                appendIteratorFilter = null;
163:
164:                return super .end(writer, body);
165:            }
166:
167:            // UnnamedParametric implementation --------------------------------------
168:            public void addParameter(Object value) {
169:                _parameters.add(value);
170:            }
171:
172:            @StrutsTagAttribute(description="The id of which if supplied will have the resultant appended iterator stored under in the stack's context")
173:            public void setId(String id) {
174:                super.setId(id);
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.