01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.uilib.list;
16:
17: import org.araneaframework.backend.util.BeanUtil;
18: import org.araneaframework.core.Assert;
19:
20: /**
21: * ListWidget that is aware of field types according to the Bean type.
22: *
23: * @author <a href="mailto:rein@araneaframework.org">Rein Raudjärv</a>
24: *
25: * @see ListWidget
26: */
27: public class BeanListWidget extends ListWidget {
28:
29: private static final long serialVersionUID = 1L;
30:
31: protected final Class beanType;
32:
33: /**
34: * Constructs a {@link BeanListWidget} for specified Bean type.
35: *
36: * @param beanType list element type.
37: */
38: public BeanListWidget(Class beanType) {
39: super ();
40: Assert.notNullParam(this , beanType, "beanType");
41: this .beanType = beanType;
42: }
43:
44: protected TypeHelper createTypeHelper() {
45: return new TypeHelper() {
46: public Class getFieldType(String fieldId) {
47: Class result = super.getFieldType(fieldId);
48: if (result == null) {
49: result = BeanUtil.getFieldType(beanType, fieldId);
50: }
51: return result;
52: }
53: };
54: }
55: }
|