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.autoupdatedatatable;
20
21 import java.io.IOException;
22
23 import javax.faces.context.FacesContext;
24 import javax.faces.render.Renderer;
25
26 import org.apache.myfaces.component.html.ext.HtmlDataTable;
27 import org.apache.myfaces.custom.ajax.api.AjaxComponent;
28 import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
29
30 /**
31 * Extended data_table that adds some additional features to the standard
32 * data_table action: see attribute descriptions for preserveDataModel,
33 * sortColumn, sortAscending and preserveSort.
34 *
35 * NOTE: This component is deprecated. Use periodicalUpdate mechanism of partial page rendering instead
36 *
37 * @JSFComponent
38 * name = "s:autoUpdateDataTable"
39 * class = "org.apache.myfaces.custom.autoupdatedatatable.AutoUpdateDataTable"
40 * tagClass = "org.apache.myfaces.custom.autoupdatedatatable.AutoUpdateDataTableTag"
41 *
42 * @author Jörg Artaker
43 * @author Thomas Huber
44 * @version $Revision: 673833 $ $Date: 2008-07-03 16:58:05 -0500 (Thu, 03 Jul 2008) $
45 * <p/>
46 * $Log: $
47 * @deprecated: Use periodicalUpdate mechanism of partial page rendering instead
48 */
49 public abstract class AbstractAutoUpdateDataTable extends HtmlDataTable implements AjaxComponent{
50
51 public static final String COMPONENT_TYPE = "org.apache.myfaces.AutoUpdateDataTable";
52 public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.AutoUpdateDataTable";
53
54 /**
55 * @param context FacesContext
56 * @param state Object
57 */
58 public void processRestoreState(FacesContext context, Object state)
59 {
60 super.processRestoreState(context, state);
61 }
62
63 /**
64 * @param context FacesContext
65 * @return Object
66 */
67 public Object processSaveState(FacesContext context)
68 {
69 return super.processSaveState(context);
70 }
71
72 /**
73 * Defines in seconds the interval of reloads. if no value is specified 2 seconds will be default.
74 *
75 * @JSFProperty
76 * @return the frequency String
77 */
78 public abstract String getFrequency();
79
80 /**
81 * Define javascript function to call after successful refresh.
82 *
83 * @JSFProperty
84 * @return
85 */
86 public abstract String getOnSuccess();
87
88 /**
89 * @param context FacesContext
90 * @throws java.io.IOException
91 */
92 public void encodeAjax(FacesContext context) throws IOException {
93 if (context == null) throw new NullPointerException("context");
94 if (!isRendered()) return;
95 Renderer renderer = getRenderer(context);
96
97 if (isValidChildren())
98 {
99 setPreservedDataModel(null);
100 }
101
102 if (renderer != null && renderer instanceof AjaxRenderer)
103 {
104
105 ((AjaxRenderer) renderer).encodeAjax(context, this);
106
107 }
108 }
109
110 public void decodeAjax(FacesContext context)
111 {
112
113 }
114 }