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.ppr;
20  
21  import java.util.Collections;
22  import java.util.List;
23  
24  import org.apache.myfaces.component.html.ext.HtmlPanelGroup;
25  
26  /**
27   * AJAX component which supports updating its children via AJAX calls. These
28   * updates can occur regularly or based on triggering input components.
29   *
30   * @JSFComponent
31   *   name = "s:pprPanelGroup"
32   *   class = "org.apache.myfaces.custom.ppr.PPRPanelGroup"
33   *   tagClass = "org.apache.myfaces.custom.ppr.PPRPanelGroupTag"
34   *   
35   * @author Ernst Fastl
36   */
37  public abstract class AbstractPPRPanelGroup extends HtmlPanelGroup
38  {
39      public static final String COMPONENT_TYPE = "org.apache.myfaces.PPRPanelGroup";
40  
41      public static final String COMPONENT_FAMILY = "org.apache.myfaces.PPRPanelGroup";
42  
43      public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.PPRPanelGroup";
44  
45      /**
46       * Comma or Space seperated List of ids from ui_command-items which trigger a partial update of this PanelGroup
47       * 
48       * @JSFProperty
49       */
50      public abstract String getPartialTriggers();
51  
52      /**
53       * Does a periodical refresh of the partial page inside the ppr group. In milliseconds.
54       * No partialTriggers are needed.
55       * 
56       * @JSFProperty
57       */
58      public abstract Integer getPeriodicalUpdate();
59  
60      /**
61       * client javascript function which will do the actual dom update. function signature:
62       * function(formNodeElement, updateTargetElement, pprResponseElement)
63       * 
64       * @JSFProperty
65       */
66      public abstract String getComponentUpdateFunction();
67  
68      /**
69       * If a periodicalUpdate is set this trigger starts the periodical requests.
70       * No partialTriggers are needed.
71       * 
72       * @JSFProperty
73       */
74      public abstract String getPeriodicalTriggers();
75  
76      /**
77       * Regular Expression If the client Id of a submitting Component matches this Pattern the corresponding pprPanelGroup is updated via AJAX
78       * 
79       * @JSFProperty
80       */
81      public abstract String getPartialTriggerPattern();
82      
83      /**
84       * Normally when a link is clicked during periodical update, the update is stopped in order to prevent the server from getting
85       * unexpected requests. For any POST-request this is the wanted behaviour because the screen is completely refreshed and periodical
86       * updating starts again after the response.
87       * However, this behaviour may be unwanted e.g. in case of opening a new window with a link where the main screen should stay refreshed.
88       * This attribute takes a regular expression of link-client-ids for which the periodical update should not be stopped.
89       * 
90       * If this value is given, there will be a default timeout of 2000 milliseconds before any periodical
91       * update will start again. This is done as mentioned before in order to prevent the server from getting unexpected requests.   
92       * This timeout can be influenced via the waitBeforePeriodicalUpdate attribute.
93       * 
94       * @JSFProperty
95       */
96      public abstract String getExcludeFromStoppingPeriodicalUpdate();
97  
98      /**
99       * This attribute only works in combination with the excludeFromStoppingPeriodicalUpdate attribute. The value
100      * in milliseconds tells the periodical update mechanism to stop for the given amount of time after clicking a link, specified by
101      * the excludeFromStoppingPeriodicalUpdate attribute.
102      * 
103      * The default value is 2000 milliseconds.
104      * 
105      * @JSFProperty
106      *   defaultValue = "Integer.valueOf(2000)"
107      */
108     public abstract Integer getWaitBeforePeriodicalUpdate();
109 
110     /**
111      * If this attribute is set the content of the PPRPanelGroup will be replaced by the provided
112      * Loading-Message during partial update
113      * 
114      * @JSFProperty
115      */
116     public abstract String getInlineLoadingMessage();
117 
118     /**
119      * If false, alert messages which can be fired after a ppr response are not displayed in the browser.
120      * May switched to true in test environments. Default: false
121      * 
122      * @JSFProperty
123      *   defaultValue = "false"
124      */
125     public abstract Boolean getShowDebugMessages();
126 
127     /**
128      * If set to false, there will be no stateUpdate on server side due to the partialPage refresh.
129      * Default: true
130      * 
131      * @JSFProperty
132      *   defaultValue = "true"
133      */
134     public abstract Boolean getStateUpdate();
135 
136     /**
137      * comma separated List of client Ids that specify the messages components
138      * in the page to which messages are appended by this PPRPanelGroup
139      * 
140      * @JSFProperty
141      */
142     public abstract String getAppendMessages();
143 
144     /**
145      * comma separated List of client Ids that specify the messages components
146      * in the page which messages are replaced by this PPRPanelGroup
147      * 
148      * @JSFProperty
149      */
150     public abstract String getReplaceMessages();
151 
152     /**
153      * Javascript code executed after a ppr update has been completed
154      *
155      * @JSFProperty
156      */
157     public abstract String getAfterUpdateJSHook();
158     
159     public boolean getInitializationSent(){
160         return isInitializationSent();
161     }
162     
163     /**
164      * flag to store the information if the initialization code has been sent to the client
165      * already. This gets state-saved to have it available between requests, e.g. to make it work
166      * within ppr responses too.
167      * 
168      * @JSFProperty
169      *   literalOnly = "true"
170      *   tagExcluded = "true"
171      */
172     public abstract boolean isInitializationSent();
173 
174     public abstract void setInitializationSent(boolean initializationSent);
175 
176     /**
177      * @return {@link PartialTriggerParser.PartialTrigger}
178      */
179     public List parsePartialTriggers()
180     {
181         List list;
182         String partialTriggers = getPartialTriggers();
183         //handle partial triggers
184         if (partialTriggers != null && partialTriggers.trim().length() > 0) {
185             list = (new PartialTriggerParser()).parse(partialTriggers);
186         }
187         else {
188             list = Collections.EMPTY_LIST;
189         }
190         return list;
191     }
192 
193     /**
194      * @return {@link PartialTriggerParser.PartialTrigger}
195      */
196     public List parsePeriodicalTriggers()
197     {
198         List list;
199         String periodicalTriggers = getPeriodicalTriggers();
200         if (periodicalTriggers != null && periodicalTriggers.trim().length() <= 0) {
201             list = (new PartialTriggerParser()).parse(periodicalTriggers);
202         }
203         else {
204             list = Collections.EMPTY_LIST;
205         }
206         return list;
207     }
208 
209 }