001    // Copyright 2005 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.tapestry.annotations;
016    
017    import org.apache.tapestry.*;
018    import org.apache.tapestry.form.Checkbox;
019    import org.apache.tapestry.form.TextField;
020    import org.apache.tapestry.html.BasePage;
021    
022    import java.lang.annotation.Target;
023    import java.util.HashMap;
024    import java.util.Map;
025    
026    /**
027     * Used by {@link org.apache.tapestry.annotations.AnnotationEnhancementWorkerTest}. Also a chance
028     * to try each of the annotations out.
029     * 
030     * @author Howard M. Lewis Ship
031     * @since 4.0
032     */
033    public abstract class AnnotatedPage extends BasePage
034    {
035        @Asset("/style/global.css")
036        public abstract IAsset getGlobalStylesheet();
037    
038        @InjectObject("barney")
039        public abstract Object getInjectedObject();
040    
041        @Bean
042        public abstract HashMap getHashMapBean();
043    
044        @Bean(HashMap.class)
045        public abstract Map getMapBean();
046    
047        @Bean(initializer = "intValue=10")
048        public abstract Target getBeanWithInitializer();
049    
050        @Bean(value = HashMap.class, lifecycle = Lifecycle.RENDER)
051        public abstract Map getRenderLifecycleBean();
052    
053        @Persist
054        public abstract int getPersistentProperty();
055    
056        @Persist("client")
057        public abstract String getClientPersistentProperty();
058    
059        @Persist
060        @InitialValue("user.naturalName")
061        public abstract int getPersistentPropertyWithInitialValue();
062    
063        @InjectAsset("stylesheet")
064        public abstract IAsset getStylesheetAsset();
065        
066        @InjectAsset("homageDeFred")
067        public abstract IAsset getUnknownAsset();
068        
069        @InjectComponent("fred")
070        public abstract TextField getFredField();
071    
072        @InjectState("barneyASO")
073        public abstract Map getBarney();
074    
075        @InjectStateFlag("barneyASO")
076        public abstract boolean getBarneyExists();
077        
078        @InjectState
079        public abstract Map getMyVisit();
080    
081        @InjectStateFlag
082        public abstract boolean getMyVisitExists();    
083    
084        @Parameter
085        public abstract String getSimpleParameter();
086    
087        @InjectPage("SomePageName")
088        public abstract IPage getMyPage();
089        
090        @Component
091        public abstract TextField getUsernameField();
092    
093        @Component(type = "TextField")
094        public abstract TextField getTextField();
095    
096        @Component(type = "Checkbox", id = "email")
097        public abstract Checkbox getEmailField();
098    
099        @Component(type = "TextField", inheritInformalParameters = true)
100        public abstract IComponent getInherit();
101    
102        @Component(type = "Conditional", bindings =
103        { "condition=message", "element=div" })
104        public abstract IComponent getComponentWithBindings();
105    
106        @Component(type = "Conditional", bindings =
107        { "condition=message", "element=div" }, inheritedBindings = {"title=pageTitle", "email"})
108        public abstract IComponent getComponentWithInheritedBindings();
109    
110        @Component(type = "TextField", bindings =
111        { "value = email", "displayName = message:email-label" })
112        public abstract IComponent getWhitespace();
113        
114        @Component(id = "anEmailCopy", copyOf = "email", type = "Checkbox")
115        public abstract IComponent getInvalidEmailCopy();
116        
117        @Component(id = "aComponentCopy", copyOf = "componentWithBindings")
118        public abstract IComponent getComponentWithBindingsCopy();
119    
120        @Message
121        public abstract String noArgsMessage();
122    
123        @Message("message-key")
124        public abstract String messageWithSpecificKey();
125    
126        @Message
127        public abstract String messageWithParameters(String foo, Map bar);
128    
129        @Message
130        public abstract String messageWithPrimitives(int foo, double bar);
131    
132        @Message
133        public abstract void voidMessage();
134    
135        @Message
136        public abstract String getLikeGetter();
137    
138        @InjectMeta("fred")
139        public abstract String getMetaFred();
140        
141        @InjectMeta
142        public abstract String getPageTitle();    
143    
144        @InjectScript("foo.script")
145        public abstract IScript getScript();
146        
147        @InitialValue("fred")
148        public abstract int getPropertyWithInitialValue();
149        
150        @EventListener(events = { "onClick" }, targets = { "email" }, 
151                elements = { "foo" })
152        public void eventListener() { }
153        
154        @EventListener(events = { "onClick" })
155        public void brokenTargetListener() { }
156        
157        @Component(type = "Form", id = "testForm")
158        public abstract IForm getForm();
159        
160        @EventListener(events = { "onClick" }, targets = { "email" }, submitForm = "testForm", focus=true)
161        public void formListener() { }
162        
163        @EventListener(events = { "onClick" }, targets = { "phone" }, submitForm = "testForm")
164        public void anotherFormListener() { }
165        
166        @EventListener(events = { "onClick" }, targets = { "phone" }, submitForm = "form")
167        public void yetAnotherFormListener() { }
168        
169        @EventListener(events = { "onClick" }, targets = { "email" }, submitForm = "notExisting")
170        public void brokenFormListener() { }
171        
172        @EventListener(targets = "foo", events = "onchange", async = false)
173        public void submitForm() {}
174    
175        @InitialValue("literal:5")
176        public abstract int getDefaultPageSize();
177        
178        @Persist
179        public abstract SimpleBean getBean();
180        
181        @Persist
182        public abstract SubSimpleBean getSubBean();
183    
184        @Asset("images/test-asset.txt")
185        public abstract IAsset getTextAsset();
186    }