001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: * $Header:$
018: */
019: package org.apache.beehive.netui.databinding.datagrid.api;
020:
021: import java.util.List;
022: import javax.servlet.ServletRequest;
023:
024: import org.apache.beehive.netui.databinding.datagrid.api.sort.Sort;
025: import org.apache.beehive.netui.databinding.datagrid.api.sort.SortModel;
026: import org.apache.beehive.netui.databinding.datagrid.api.filter.FilterModel;
027: import org.apache.beehive.netui.databinding.datagrid.api.filter.Filter;
028: import org.apache.beehive.netui.databinding.datagrid.api.pager.PagerModel;
029: import org.apache.beehive.netui.databinding.datagrid.api.rendering.PagerRenderer;
030: import org.apache.beehive.netui.databinding.datagrid.api.rendering.StyleModel;
031:
032: /**
033: * <p>
034: * Abstract class used by the data grid to create model objects used for state
035: * management and rendering. This abstraction exists in order to allow the data grid's
036: * implementation to be configurable. Various data grid implementation classes are exposed
037: * here including sorting, filtering, and paging. In addition, classes such as the
038: * {@link PagerRenderer} and {@link StyleModel} are created by subclasses in order to provide
039: * a data grid specific implementation of pager UI or style support.
040: * </p>
041: * <p>
042: * By default, DataGridConfig implementations are not thread safe, but custom implementations are
043: * free to store instance state as long as the DataGridConfig object lifetimes are managed
044: * in user code.
045: * </p>
046: * <p>
047: * A specific DataGridConfig object can be created and passed to a data grid via the
048: * data grid's
049: * {@link org.apache.beehive.netui.tags.databinding.datagrid.DataGrid#setDataGridConfig(DataGridConfig)}
050: * method.
051: * </p>
052: */
053: public abstract class DataGridConfig implements java.io.Serializable {
054:
055: /**
056: * <p>
057: * Create a {@link DataGridState} instance that will be used to store the state for a data grid. This
058: * method will be called only when a DataGridState object needs to be manufactured by a data grid tag.
059: * </p>
060: *
061: * @return the {@link DataGridState} object for a data grid.
062: */
063: public abstract DataGridState createDataGridState();
064:
065: /**
066: * <p>
067: * Create a concrete {@link Sort} implementation for a data grid. When the sort state of a data grid
068: * is created, this {@link Sort} instance will contain a single sort.
069: * </p>
070: * @return a {@link Sort} instance
071: */
072: public abstract Sort createSort();
073:
074: /**
075: * <p>
076: * Create a {@link SortModel} instance used to store the {@link Sort} state for a data grid.
077: * </p>
078: * @param sorts the current {@link List} of sorts for a data grid
079: * @return the {@link SortModel}
080: */
081: public abstract SortModel createSortModel(List/*<Sort>*/sorts);
082:
083: /**
084: * <p>
085: * Create a concrete {@link org.apache.beehive.netui.databinding.datagrid.api.filter.Filter} implementation for a data grid. When the filter state of a data grid
086: * is created, this {@link org.apache.beehive.netui.databinding.datagrid.api.filter.Filter} instance will contain a single filter.
087: * </p>
088: * @return a {@link org.apache.beehive.netui.databinding.datagrid.api.filter.Filter} instance
089: */
090: public abstract Filter createFilter();
091:
092: /**
093: * <p>
094: * Create a {@link FilterModel} instance used to store the {@link Filter} state for a data grid.
095: * </p>
096: * @param filters the current {@link List} of filters for a data grid
097: * @return a {@link FilterModel}
098: */
099: public abstract FilterModel createFilterModel(
100: List/*<Filter>*/filters);
101:
102: /**
103: * <p>
104: * Create a {@link PagerModel} instance used to store the current paging state for a data grid.
105: * </p>
106: * @return a {@link PagerModel}
107: */
108: public abstract PagerModel createPagerModel();
109:
110: /**
111: * <p>
112: * Create a {@link DataGridStateCodec} instance used to obtain services for handling data grid state.
113: * </p>
114: * @param request the current {@link ServletRequest}
115: * @param gridName the name of a data grid whose {@link DataGridStateCodec} to obtain
116: * @return a {@link DataGridStateCodec}
117: */
118: public abstract DataGridStateCodec createStateCodec(
119: ServletRequest request, String gridName);
120:
121: /**
122: * <p>
123: * Create the default {@link DataGridResourceProvider}. A resource provider is an implementation of
124: * the {@link DataGridResourceProvider} which is used during data grid rendering to obtain strings
125: * for messages, paths, etc. The default resource provider simply exposes the default data grid
126: * messages stored in the properties file located at:
127: * <pre>
128: * org.apache.beehive.netui.databinding.datagrid.runtime.util.data-grid-default.properties
129: * </pre>
130: * </p>
131: * @return a {@link DataGridResourceProvider}
132: */
133: public abstract DataGridResourceProvider getDefaultResourceProvider();
134:
135: /**
136: * <p>
137: * Create a DataGridConfig-specific implementation of a {@link DataGridResourceProvider}. The DataGridConfig
138: * instance should use the provided resource bundle path to create a {@link DataGridResourceProvider} which
139: * will expose those messages into the data grid for rendering.
140: * </p>
141: * @param resourceBundle the resource bundle to use for grid messages
142: * @return a {@link DataGridResourceProvider}
143: */
144: public abstract DataGridResourceProvider getResourceProvider(
145: String resourceBundle);
146:
147: /**
148: * <p>
149: * Create a {@link StyleModel} used by a data grid to render styles onto various HTML markup elements
150: * generated by a data grid.
151: * </p>
152: * @param name the name of a style type to support. This name can vary by {@link DataGridConfig} implementation
153: * subclasses may use this value to configure the type of {@link StyleModel} returned to the caller.
154: * @param classPrefix an optional prefix to use when generating style class names
155: * @return the {@link StyleModel}
156: */
157: public abstract StyleModel getStyleModel(String name,
158: String classPrefix);
159:
160: /**
161: * <p>
162: * Create a concrete {@link PagerRenderer} implementation that will be used to render the pager
163: * in the absence of an alternate pager renderer.
164: * </p>
165: * @return the default {@link PagerRenderer} used to render a paging user interface
166: */
167: public abstract PagerRenderer getDefaultPagerRenderer();
168: }
|