Source Code Cross Referenced for AbstractLink.java in  » J2EE » wicket » org » apache » 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 » org.apache.wicket.markup.html.link 
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:        package org.apache.wicket.markup.html.link;
018:
019:        import org.apache.wicket.Application;
020:        import org.apache.wicket.markup.ComponentTag;
021:        import org.apache.wicket.markup.MarkupStream;
022:        import org.apache.wicket.markup.html.WebMarkupContainer;
023:        import org.apache.wicket.model.IModel;
024:
025:        /**
026:         * Base class that that contains functionality for rendering disabled links.
027:         * 
028:         * @author Matej Knopp
029:         */
030:        public abstract class AbstractLink extends WebMarkupContainer {
031:
032:            /**
033:             * Construct.
034:             * 
035:             * @param id
036:             * @param model
037:             */
038:            public AbstractLink(String id, IModel model) {
039:                super (id, model);
040:            }
041:
042:            /**
043:             * Construct.
044:             * 
045:             * @param id
046:             */
047:            public AbstractLink(String id) {
048:                super (id);
049:            }
050:
051:            /**
052:             * Simple insertion string to allow disabled links to look like <i>Disabled
053:             * link </i>.
054:             */
055:            private String beforeDisabledLink;
056:
057:            /**
058:             * Simple insertion string to allow disabled links to look like <i>Disabled
059:             * link </i>.
060:             */
061:            private String afterDisabledLink;
062:
063:            /**
064:             * Sets the insertion string to allow disabled links to look like
065:             * <i>Disabled link </i>.
066:             * 
067:             * @param afterDisabledLink
068:             *            The insertion string
069:             */
070:            public void setAfterDisabledLink(final String afterDisabledLink) {
071:                if (afterDisabledLink == null) {
072:                    throw new IllegalArgumentException(
073:                            "Value cannot be null.  For no text, specify an empty String instead.");
074:                }
075:                this .afterDisabledLink = afterDisabledLink;
076:            }
077:
078:            /**
079:             * Gets the insertion string to allow disabled links to look like
080:             * <i>Disabled link </i>.
081:             * 
082:             * @return The insertion string
083:             */
084:            public String getAfterDisabledLink() {
085:                return afterDisabledLink;
086:            }
087:
088:            /**
089:             * Sets the insertion string to allow disabled links to look like
090:             * <i>Disabled link </i>.
091:             * 
092:             * @param beforeDisabledLink
093:             *            The insertion string
094:             */
095:            public void setBeforeDisabledLink(final String beforeDisabledLink) {
096:                if (beforeDisabledLink == null) {
097:                    throw new IllegalArgumentException(
098:                            "Value cannot be null.  For no text, specify an empty String instead.");
099:                }
100:                this .beforeDisabledLink = beforeDisabledLink;
101:            }
102:
103:            protected void onBeforeRender() {
104:                super .onBeforeRender();
105:
106:                // Set default for before/after link text
107:                if (beforeDisabledLink == null) {
108:                    final Application app = getApplication();
109:                    beforeDisabledLink = app.getMarkupSettings()
110:                            .getDefaultBeforeDisabledLink();
111:                    afterDisabledLink = app.getMarkupSettings()
112:                            .getDefaultAfterDisabledLink();
113:                }
114:            }
115:
116:            /**
117:             * Gets the insertion string to allow disabled links to look like
118:             * <i>Disabled link </i>.
119:             * 
120:             * @return The insertion string
121:             */
122:            public String getBeforeDisabledLink() {
123:                return beforeDisabledLink;
124:            }
125:
126:            /**
127:             * Helper methods that both checks whether the link is enabled and whether
128:             * the action ENABLE is allowed.
129:             * 
130:             * @return whether the link should be rendered as enabled
131:             */
132:            protected final boolean isLinkEnabled() {
133:                return isEnabled() && isEnableAllowed();
134:            }
135:
136:            /**
137:             * Renders this link's body.
138:             * 
139:             * @param markupStream
140:             *            the markup stream
141:             * @param openTag
142:             *            the open part of this tag
143:             * @see org.apache.wicket.Component#onComponentTagBody(MarkupStream,
144:             *      ComponentTag)
145:             */
146:            protected void onComponentTagBody(final MarkupStream markupStream,
147:                    final ComponentTag openTag) {
148:                // Draw anything before the body?
149:                if (!isLinkEnabled() && getBeforeDisabledLink() != null) {
150:                    getResponse().write(getBeforeDisabledLink());
151:                }
152:
153:                // Render the body of the link
154:                renderComponentTagBody(markupStream, openTag);
155:
156:                // Draw anything after the body?
157:                if (!isLinkEnabled() && getAfterDisabledLink() != null) {
158:                    getResponse().write(getAfterDisabledLink());
159:                }
160:            }
161:
162:            /**
163:             * Alters the tag so that the link renders as disabled.
164:             * 
165:             * This method is meant to be called from
166:             * {@link #onComponentTag(ComponentTag)} method of the derived class.
167:             * 
168:             * @param tag
169:             */
170:            protected void disableLink(final ComponentTag tag) {
171:                // if the tag is an anchor proper
172:                if (tag.getName().equalsIgnoreCase("a")
173:                        || tag.getName().equalsIgnoreCase("link")
174:                        || tag.getName().equalsIgnoreCase("area")) {
175:                    // Change anchor link to span tag
176:                    tag.setName("span");
177:
178:                    // Remove any href from the old link
179:                    tag.remove("href");
180:
181:                    tag.remove("onclick");
182:                }
183:                // if the tag is a button or input
184:                else if ("button".equalsIgnoreCase(tag.getName())
185:                        || "input".equalsIgnoreCase(tag.getName())) {
186:                    tag.put("disabled", "disabled");
187:                }
188:            }
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.