View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.custom.imageloop;
20  
21  import javax.faces.component.UIComponentBase;
22  import javax.faces.context.FacesContext;
23  
24  import org.apache.myfaces.component.html.util.HtmlComponentUtils;
25  
26  /**
27   * HTML image loop component.
28   * 
29   * Image loop/slide show component. 
30   * 
31   * Provides Javascript methods to control image loop behaviour. 
32   * Methods: getImageLoop(id) - get image loop object with id, 
33   * play() - play loop, 
34   * stop() - stop loop, 
35   * accelerate() - accelerate loop until minDelay reached, 
36   * decelerate() - decelerate loop until maxDelay reached, 
37   * setImageIndex(index) - show image with index, 
38   * reset() - reset settings to origin values, 
39   * getImageCount() - get number of images loaded
40   * 
41   * @JSFComponent
42   *   name = "s:imageLoop"
43   *   class = "org.apache.myfaces.custom.imageloop.HtmlImageLoop"
44   *   tagClass = "org.apache.myfaces.custom.imageloop.HtmlImageLoopTag"
45   *   
46   * @author Felix Röthenbacher (latest modification by $Author: lu4242 $)
47   * @version $Revision: 663481 $ $Date: 2008-06-05 02:00:34 -0500 (Thu, 05 Jun 2008) $
48   */
49  public abstract class AbstractHtmlImageLoop extends UIComponentBase {
50  
51      public static final String COMPONENT_FAMILY = "javax.faces.Output";
52      public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlImageLoop";
53      public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.HtmlImageLoop";
54      
55      // Value binding constants
56      public static final String VB_DELAY = "delay";
57      public static final String VB_MIN_DELAY = "minDelay";
58      public static final String VB_MAX_DELAY = "maxDelay";
59      public static final String VB_TRANSITION_TIME = "transitionTime";
60      public static final String VB_WIDTH = "width";
61      public static final String VB_HEIGHT = "height";
62              
63      public String getClientId(FacesContext context) {
64          String clientId = HtmlComponentUtils.getClientId(this, getRenderer(context), context);
65          if (clientId == null)
66          {
67              clientId = super.getClientId(context);
68          }
69          return clientId;
70      }
71      
72      public String getFamily() {
73          return COMPONENT_FAMILY;
74      }
75      
76      /**
77       * The delay between transitions
78       * 
79       * @JSFProperty
80       */
81      public abstract Integer getDelay();
82      
83      /**
84       * The minimum delay allowed when decreasing delay time
85       * 
86       * @JSFProperty
87       */
88      public abstract Integer getMinDelay();
89  
90      /**
91       * The maximum delay allowed when increasing delay time
92       * 
93       * @JSFProperty
94       */
95      public abstract Integer getMaxDelay();
96  
97      /**
98       * Transition time in milliseconds. Set to -1 for immediate image switch.
99       * 
100      * @JSFProperty
101      */
102     public abstract Integer getTransitionTime();
103     
104     /**
105      * Width
106      * 
107      * @JSFProperty
108      */
109     public abstract Integer getWidth();
110 
111     /**
112      * Height
113      * 
114      * @JSFProperty
115      */
116     public abstract Integer getHeight();
117     
118     /**
119      * If true, this component will force the use of the specified id when rendering.
120      * 
121      * @JSFProperty
122      *   literalOnly = "true"
123      *   defaultValue = "false"
124      *   
125      * @return
126      */
127     public abstract Boolean getForceId();
128         
129     /**
130      *  If false, this component will not append a '[n]' suffix 
131      *  (where 'n' is the row index) to components that are 
132      *  contained within a "list." This value will be true by 
133      *  default and the value will be ignored if the value of 
134      *  forceId is false (or not specified.)
135      * 
136      * @JSFProperty
137      *   literalOnly = "true"
138      *   defaultValue = "true"
139      *   
140      * @return
141      */
142     public abstract Boolean getForceIdIndex();
143         
144 }