Source Code Cross Referenced for ConfigurePager.java in  » Library » Apache-beehive-1.0.2-src » org » apache » beehive » netui » tags » databinding » datagrid » 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 » Library » Apache beehive 1.0.2 src » org.apache.beehive.netui.tags.databinding.datagrid 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         *
017:         * $Header:$
018:         */
019:        package org.apache.beehive.netui.tags.databinding.datagrid;
020:
021:        import javax.servlet.jsp.JspException;
022:        import javax.servlet.http.HttpServletRequest;
023:
024:        import org.apache.beehive.netui.databinding.datagrid.api.exceptions.DataGridExtensionException;
025:        import org.apache.beehive.netui.databinding.datagrid.api.rendering.DataGridTagModel;
026:        import org.apache.beehive.netui.databinding.datagrid.api.rendering.PagerRenderer;
027:        import org.apache.beehive.netui.databinding.datagrid.runtime.rendering.pager.FirstPreviousNextLastPagerRenderer;
028:        import org.apache.beehive.netui.databinding.datagrid.runtime.rendering.pager.PreviousNextPagerRenderer;
029:        import org.apache.beehive.netui.databinding.datagrid.runtime.util.JspUtil;
030:        import org.apache.beehive.netui.databinding.datagrid.runtime.util.ExtensionUtil;
031:        import org.apache.beehive.netui.databinding.datagrid.api.pager.PagerModel;
032:        import org.apache.beehive.netui.tags.AbstractSimpleTag;
033:        import org.apache.beehive.netui.util.logging.Logger;
034:        import org.apache.beehive.netui.util.Bundle;
035:
036:        /**
037:         * <p>
038:         * The configurePager tag is used to parameterize the data used to render a data grid's pager.  This
039:         * tag should be used inside of a &lt;netui-data:dataGrid&gt; tag.  The tag supports adding a custom
040:         * {@link PagerRenderer} via the {@link #setPagerRendererClass(String)}, overriding the default page
041:         * size for a data grid via the {@link #setDefaultPageSize(Integer)} attribute, and setting
042:         * the current data grid's page size via the {@link #setPageSize(int)} attribute.  This tag produces
043:         * no output and does not evaluate its body.
044:         * </p>
045:         * @jsptagref.tagdescription
046:         * <p>
047:         * The configurePager tag is used to parameterize the data used to render a data grid's pager.  This
048:         * tag should be used inside of a &lt;netui-data:dataGrid&gt; tag.  The tag supports adding a custom
049:         * {@link PagerRenderer} via the {@link #setPagerRendererClass(String)}, overriding the default page
050:         * size for a data grid via the {@link #setDefaultPageSize(Integer)} attribute, and setting
051:         * the current data grid's page size via the {@link #setPageSize(int)} attribute.  This tag produces
052:         * no output and does not evaluate its body.
053:         * </p>
054:         * @netui:tag name="configurePager" body-content="empty"
055:         * description="Pager tag for the configuring and rendering the pager rendered in the NetUI data grid"
056:         */
057:        public class ConfigurePager extends AbstractSimpleTag {
058:
059:            private static final Logger LOGGER = Logger
060:                    .getInstance(ConfigurePager.class);
061:            private static final String PAGER_FORMAT_FIRST_LAST_PREV_NEXT = "firstPrevNextLast";
062:            private static final String PAGER_FORMAT_PREV_NEXT = "prevNext";
063:
064:            private Boolean _disableDefaultPager = null;
065:            private Integer _pageSize = null;
066:            private Integer _defaultPageSize = null;
067:            private String _pagerFormat = null;
068:            private String _pageHref = null;
069:            private String _pageAction = null;
070:            private String _pagerRendererClass = null;
071:
072:            /**
073:             * The name of this tag; this value is used for error reporting.
074:             * @return the String name of this tag
075:             */
076:            public String getTagName() {
077:                return "ConfigurePager";
078:            }
079:
080:            /**
081:             * Set the page size for the current data grid.  This value is the maximum number of data rows
082:             * that will be rendered by a data grid.  When this value is set, it overides the
083:             * {@link #setDefaultPageSize(Integer)} attribute.  If this value is not set, the
084:             * {@link #setDefaultPageSize(Integer)} is used to determine the maximum size of a data grid's
085:             * page.  Use this value when a data grid allows a user to vary the number of rows in a grid.
086:             * @jsptagref.attributedescription
087:             * Set the page size for the current data grid.  This value is the maximum number of data rows
088:             * that will be rendered by a data grid.  When this value is set, it overides the
089:             * {@link #setDefaultPageSize(Integer)} attribute.  If this value is not set, the
090:             * {@link #setDefaultPageSize(Integer)} is used to determine the maximum size of a data grid's
091:             * page.  Use this value when a data grid allows a user to vary the number of rows in a grid.
092:             * @jsptagref.attributesyntaxvalue <i>int_pageSize</i>
093:             * @netui:attribute required="false" rtexprvalue="true"
094:             *                  description="Set the maximum number of rows to render for a data grid."
095:             */
096:            public void setPageSize(int pageSize) {
097:                _pageSize = new Integer(pageSize);
098:            }
099:
100:            /**
101:             * Set the appearance of the pager rendered by the data grid.  This attribute allows the page author to
102:             * choose from a set of pre-defined pager renderers which can be used to render paging UI
103:             * in a data grid.  The values include:
104:             * <b>prevNext</b> which renders a pager as:<br/>
105:             * <pre>
106:             *   Page # of # Previous Next
107:             * </pre>
108:             * where Previous and Next are anchors that can navigate to the previous and next pages.  When
109:             * there is no previous or next page, Previous or Next are displayed as literal text.
110:             * <br/>
111:             * <br/>
112:             * <b>firstPrevNextLast</b> which renders a pager as:<br/>
113:             * <pre>
114:             *   Page # of # First Previous Next Last
115:             * </pre>
116:             * where First, Previous, Next, and Last are anchors that can navigate to the first, previous, next, and last
117:             * pages respectively.  When the anchors would reference invalid pages, First, Previous, Nest, and Last
118:             * are displayed as literal text.
119:             * @jsptagref.attributedescription
120:             * Set the style of the pager rendered by the data grid.  This attribute allows the page author to
121:             * choose from a set of pre-defined pager renderers which can be used to render paging UI
122:             * in a data grid.  The values include:
123:             * <b>prevNext</b> which renders a pager as:<br/>
124:             * <pre>
125:             *   Page # of # Previous Next
126:             * </pre>
127:             * where Previous and Next are anchors that can navigate to the previous and next pages.  When
128:             * there is no previous or next page, Previous or Next are displayed as literal text.
129:             * <br/>
130:             * <br/>
131:             * <b>firstPrevNextLast</b> which renders a pager as:<br/>
132:             * <pre>
133:             *   Page # of # First Previous Next Last
134:             * </pre>
135:             * where First, Previous, Next, and Last are anchors that can navigate to the first, previous, next, and last
136:             * pages respectively.  When the anchors would reference invalid pages, First, Previous, Nest, and Last
137:             * are displayed as literal text.
138:             * @jsptagref.attributesyntaxvalue <i>String_pagerStyle</i>
139:             * @netui:attribute required="false" rtexprvalue="true"
140:             *                  description="Set the appearance of the pager rendered by the data grid.
141:             */
142:            public void setPagerFormat(String pagerFormat) {
143:                _pagerFormat = pagerFormat;
144:            }
145:
146:            /**
147:             * Set the HREF used to perform paging.  When a pager renders anchors for navigating the data set
148:             * inside of the data grid, this HREF when set is used as the request URI to perform the paging.
149:             * Only one of this and the {@link #setPageAction(String)} may be set.
150:             * @jsptagref.attributedescription
151:             * Set the HREF used to perform paging.  When a pager renders anchors for navigating the data set
152:             * inside of the data grid, this HREF when set is used as the request URI to perform the paging.
153:             * Only one of this and the {@link #setPageAction(String)} may be set.
154:             * @jsptagref.attributesyntaxvalue <i>String_pageUri</i>
155:             * @netui:attribute required="false" rtexprvalue="true" description="The HREF used when building HTML
156:             * anchors that perform paging."
157:             */
158:            public void setPageHref(String pageHref) {
159:                _pageHref = pageHref;
160:            }
161:
162:            /**
163:             * Set the action used to perform paging.  When a pager renders anchors for navigating the
164:             * data set in a data grid, this action is used as the request URI to perform the paging.
165:             * Only one of this and the {@link #setPageHref(String)} may be set.
166:             * @jsptagref.attributedescription
167:             * Set the action used to perform paging.  When a pager renders anchors for navigating the
168:             * data set in a data grid, this action is used as the request URI to perform the paging.
169:             * Only one of this and the {@link #setPageHref(String)} may be set.
170:             * @jsptagref.attributesyntaxvalue <i>String_pageAction</i>
171:             * @netui:attribute required="false" rtexprvalue="true"
172:             *                  description="The action used when building HTML anchors that perrform paging.
173:             */
174:            public void setPageAction(String pageAction) {
175:                _pageAction = pageAction;
176:            }
177:
178:            /**
179:             * Sets the value of an attribute that enables or disables rendering the data grid's default pager.
180:             * When this value is set to <code>false</code>, the data grid will not render its pager and rendering
181:             * is left to the page author.  When rendering is disabled, a pager can be rendered using the
182:             * {@link RenderPager} tag or manually in a page.
183:             * @jsptagref.attributedescription
184:             * Sets the value of an attribute that enables or disables rendering the data grid's default pager.
185:             * When this value is set to <code>false</code>, the data grid will not render its pager and rendering
186:             * is left to the page author.  When rendering is disabled, a pager can be rendered using the
187:             * {@link RenderPager} tag or manually in a page.
188:             * @jsptagref.attributesyntaxvalue <i>boolean</i>
189:             * @netui:attribute required="false" rtexprvalue="true"
190:             *                  description="Boolean that enables / disables a data grid rendering the pager in its default location"
191:             */
192:            public void setDisableDefaultPager(boolean disableDefaultPager) {
193:                _disableDefaultPager = Boolean.valueOf(disableDefaultPager);
194:            }
195:
196:            /**
197:             * Set a Java class name to create a {@link PagerRenderer} used to render a data grid's pager.  The
198:             * class referenced by this name must extend the {@link PagerRenderer} base class.
199:             * @jsptagref.attributedescription
200:             * Set a Java class name to create a {@link PagerRenderer} used to render a data grid's pager.  The
201:             * class referenced by this name must extend the {@link PagerRenderer} base class.
202:             * @jsptagref.attributesyntaxvalue <i>string</i>
203:             * @netui:attribute required="false" rtexprvalue="true"
204:             *                  description="The data grid pager's custom pager render classname"
205:             */
206:            public void setPagerRendererClass(String pagerRendererClass) {
207:                _pagerRendererClass = pagerRendererClass;
208:            }
209:
210:            /**
211:             * Set the default page size for the data grid.  The grid has a default page size that is used
212:             * when no other page size is specified; this value is {@link PagerModel#DEFAULT_PAGE_SIZE}.
213:             * This value overrides that default so that the normal rendering of such a data grid is
214:             * change in the absence of an override provided by the {@link #setPageSize(int)} attribute.
215:             *
216:             * @jsptagref.attributedescription
217:             * Set the default page size for the data grid.  The grid has a default page size that is used
218:             * when no other page size is specified; this value is {@link PagerModel#DEFAULT_PAGE_SIZE}.
219:             * This value overrides that default so that the normal rendering of such a data grid is
220:             * change in the absence of an override provided by the {@link #setPageSize(int)} attribute.
221:             * @jsptagref.attributesyntaxvalue <i>string</i>
222:             * @netui:attribute required="false" rtexprvalue="true" description="The data grid pager's default page size"
223:             */
224:            public void setDefaultPageSize(Integer defaultPageSize) {
225:                _defaultPageSize = defaultPageSize;
226:            }
227:
228:            /**
229:             * Execute the ConfigurePager tag.  When the ConfigurePager tag runs, it applies its tag attributes
230:             * onto a {@link DataGridTagModel} state object which is used when the data grid renders its pager.
231:             * @throws JspException when errors occur when processing this tag's attribute values
232:             */
233:            public void doTag() throws JspException {
234:
235:                DataGridTagModel dgm = DataGridUtil
236:                        .getDataGridTagModel(getJspContext());
237:                if (dgm == null)
238:                    throw new JspException(
239:                            Bundle
240:                                    .getErrorString("DataGridTags_MissingDataGridModel"));
241:
242:                PagerModel pm = dgm.getState().getPagerModel();
243:                assert pm != null;
244:
245:                if (_disableDefaultPager != null)
246:                    dgm.setDisableDefaultPagerRendering(_disableDefaultPager
247:                            .booleanValue());
248:
249:                if (_pageSize != null)
250:                    pm.setPageSize(_pageSize.intValue());
251:
252:                if (_defaultPageSize != null)
253:                    pm.setDefaultPageSize(_defaultPageSize.intValue());
254:
255:                PagerRenderer pagerRenderer = null;
256:                if (_pagerRendererClass != null) {
257:                    try {
258:                        pagerRenderer = (PagerRenderer) ExtensionUtil
259:                                .instantiateClass(_pagerRendererClass,
260:                                        PagerRenderer.class);
261:                        assert pagerRenderer != null : "Expected a non-null pager renderer of type \""
262:                                + _pagerRendererClass + "\"";
263:                    } catch (DataGridExtensionException e) {
264:                        String msg = Bundle.getErrorString(
265:                                "ConfigurePager_CantCreateCustomPagerRenderer",
266:                                new Object[] { e });
267:                        JspException jsp = new JspException(msg, e);
268:
269:                        // todo: future cleanup
270:                        // The 2.5 Servlet api will set the initCause in the Throwable superclass during construction,
271:                        // this will cause an IllegalStateException on the following call.
272:                        if (jsp.getCause() == null) {
273:                            jsp.initCause(e);
274:                        }
275:                        throw jsp;
276:                    }
277:                } else if (_pagerFormat != null) {
278:                    if (_pagerFormat.equals(PAGER_FORMAT_FIRST_LAST_PREV_NEXT))
279:                        pagerRenderer = new FirstPreviousNextLastPagerRenderer();
280:                    else if (_pagerFormat.equals(PAGER_FORMAT_PREV_NEXT))
281:                        pagerRenderer = new PreviousNextPagerRenderer();
282:                    else
283:                        throw new JspException(Bundle.getErrorString(
284:                                "ConfigurePager_UnsupportedPagerFormat",
285:                                new Object[] { _pagerFormat }));
286:                }
287:
288:                if (pagerRenderer != null)
289:                    dgm.setPagerRenderer(pagerRenderer);
290:
291:                if (_pageHref != null && _pageAction != null)
292:                    throw new JspException(
293:                            Bundle
294:                                    .getErrorString("ConfigurePager_CantSetHrefAndAction"));
295:
296:                if (_pageHref == null && _pageAction == null) {
297:                    LOGGER
298:                            .info("The configurePager tag has no page action or HREF specified; using the current request URI instead.");
299:                    _pageHref = JspUtil.getRequest(getJspContext())
300:                            .getRequestURI();
301:                }
302:
303:                if (_pageHref != null)
304:                    pm.setPageHref(_pageHref);
305:
306:                if (_pageAction != null)
307:                    pm.setPageAction(_pageAction);
308:            }
309:        }
www___.__j_a__v_a__2___s__.___co__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.