Source Code Cross Referenced for PageLink.java in  » J2EE » wicket » wicket » markup » html » link » 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 » wicket » wicket.markup.html.link 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: PageLink.java 457783 2005-10-02 10:06:33Z jcompagner $ $Revision:
003:         * 1.13 $ $Date: 2005-10-02 12:06:33 +0200 (Sun, 02 Oct 2005) $
004:         * 
005:         * ==============================================================================
006:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
007:         * use this file except in compliance with the License. You may obtain a copy of
008:         * the License at
009:         * 
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
014:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
015:         * License for the specific language governing permissions and limitations under
016:         * the License.
017:         */
018:        package wicket.markup.html.link;
019:
020:        import wicket.Page;
021:
022:        /**
023:         * Links to a given page via an object implementing the IPageLink delayed
024:         * linking interface. PageLinks can be constructed directly with an IPageLink
025:         * interface or with a Page Class object. In the latter case, an IPageLink
026:         * implementation is provided which constructs a Page of the given class when
027:         * the link is clicked. A default no-args constructor must be available in this
028:         * case or a WicketRuntimeException will be thrown when Wicket fails to
029:         * instantiate the class.
030:         * 
031:         * @see IPageLink
032:         * @author Jonathan Locke
033:         */
034:        public class PageLink extends Link {
035:            private static final long serialVersionUID = 1L;
036:
037:            /** The delayed linking Page source. */
038:            private final IPageLink pageLink;
039:
040:            /**
041:             * Constructs a link that instantiates the given Page class when the link is
042:             * clicked. The instantiated Page is used to render a response to the user.
043:             * 
044:             * @param id
045:             *            See Component
046:             * @param c
047:             *            Page class
048:             */
049:            public PageLink(final String id, final Class c) {
050:                super (id);
051:
052:                // Ensure that c is a subclass of Page
053:                if (!Page.class.isAssignableFrom(c)) {
054:                    throw new IllegalArgumentException("Class " + c
055:                            + " is not a subclass of Page");
056:                }
057:
058:                this .pageLink = new IPageLink() {
059:                    private static final long serialVersionUID = 1L;
060:
061:                    public Page getPage() {
062:                        // Create page using page factory
063:                        return PageLink.this .getPage().getPageFactory()
064:                                .newPage(c);
065:                    }
066:
067:                    public Class getPageIdentity() {
068:                        return c;
069:                    }
070:                };
071:            }
072:
073:            /**
074:             * This constructor is ideal if a Page object was passed in from a previous
075:             * Page. Construct a link to the Page.
076:             *
077:             * @param id  See component
078:             * @param page The page
079:             */
080:            public PageLink(final String id, final Page page) {
081:                super (id);
082:
083:                this .pageLink = new IPageLink() {
084:                    private static final long serialVersionUID = 1L;
085:
086:                    public Page getPage() {
087:                        // Create page using page factory
088:                        return page;
089:                    }
090:
091:                    public Class getPageIdentity() {
092:                        return page.getClass();
093:                    }
094:                };
095:            }
096:
097:            /**
098:             * This constructor is ideal for constructing pages lazily.
099:             *
100:             * Constructs a link which invokes the getPage() method of the IPageLink
101:             * interface when the link is clicked. Whatever Page objects is returned by
102:             * this method will be rendered back to the user.
103:             *
104:             * @param id
105:             *            See Component
106:             * @param pageLink
107:             *            An implementation of IPageLink which will create the page
108:             *            linked to if and when this hyperlink is clicked at a later
109:             *            time.
110:             */
111:            public PageLink(final String id, final IPageLink pageLink) {
112:                super (id);
113:                this .pageLink = pageLink;
114:            }
115:
116:            /**
117:             * Returns true if the given page is of the same class as the (delayed)
118:             * destination of this page link.
119:             * 
120:             * @see wicket.markup.html.link.Link#linksTo(wicket.Page)
121:             */
122:            public boolean linksTo(final Page page) {
123:                return page.getClass() == pageLink.getPageIdentity();
124:            }
125:
126:            /**
127:             * Handles a link click by asking for a concrete Page instance through the
128:             * IPageLink.getPage() delayed linking interface. This call will normally
129:             * cause the destination page to be created.
130:             * 
131:             * @see wicket.markup.html.link.Link#onClick()
132:             */
133:            public void onClick() {
134:                // Set page source's page as response page
135:                setResponsePage(pageLink.getPage());
136:            }
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.