001 // Copyright 2010, 2011 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.tapestry5.annotations; 016 017 import org.apache.tapestry5.ioc.annotations.UseWith; 018 import org.apache.tapestry5.services.javascript.JavaScriptStack; 019 import org.apache.tapestry5.services.javascript.JavaScriptSupport; 020 021 import java.lang.annotation.*; 022 023 import static org.apache.tapestry5.ioc.annotations.AnnotationUseContext.*; 024 025 /** 026 * Annotations to control the importing of JavaScript stacks and libraries as well as stylesheets. This annotation may 027 * be placed on a class, in which case importing will occur as part of the {@link SetupRender} render phase. 028 * Alternately, the annotation maybe placed on any method (though typically it will be placed on a render phase 029 * method) and the import operations will be associated of that method. 030 * <p/> 031 * Assets are localized during the {@link org.apache.tapestry5.runtime.PageLifecycleAdapter#containingPageDidLoad()} lifecycle 032 * method. 033 * 034 * @see JavaScriptSupport 035 * @since 5.2.0 036 */ 037 @Target( 038 {ElementType.TYPE, ElementType.METHOD}) 039 @Retention(RetentionPolicy.RUNTIME) 040 @Documented 041 @UseWith( 042 {COMPONENT, MIXIN, PAGE}) 043 public @interface Import 044 { 045 /** 046 * JavaScript Stacks to import. Stacks are imported before individual libraries. Note that 047 * stacks themselves may have {@linkplain JavaScriptStack#getStacks() dependencies on other 048 * stacks}. 049 * 050 * @see JavaScriptStack 051 * @see JavaScriptSupport#importStack(String) 052 */ 053 String[] stack() default {}; 054 055 /** 056 * JavaScript libraries to import. Each value is an asset path; symbols in each path are expanded. The library may 057 * be localized. 058 * 059 * @see JavaScriptSupport#importJavaScriptLibrary(org.apache.tapestry5.Asset) 060 */ 061 String[] library() default {}; 062 063 /** 064 * Stylesheets to import. Each value is an asset path; symbols in each path are expanded. The stylesheet may be 065 * localized. The stylesheet is imported with no options. 066 * 067 * @see JavaScriptSupport#importStylesheet(org.apache.tapestry5.Asset) 068 */ 069 String[] stylesheet() default {}; 070 }