01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.beaneditor;
16:
17: import java.util.List;
18:
19: import org.apache.tapestry.PropertyConduit;
20: import org.apache.tapestry.services.BeanModelSource;
21:
22: /**
23: * Provides the information necessary to build a user interface to view, create or edit an instance
24: * of a particular type.
25: * <p>
26: * BeanModels are not threadsafe, they are also not serializable.
27: *
28: * @see BeanModelSource
29: */
30: public interface BeanModel {
31: /** Returns the type of bean for which this model was initially created. */
32: Class getBeanType();
33:
34: /**
35: * Returns a list of the editable properties of the bean, in <em>presentation</em> order.
36: */
37: List<String> getPropertyNames();
38:
39: /**
40: * Returns the named model.
41: *
42: * @param propertyName
43: * name of property to retrieve model for (case is ignored)
44: * @return the model for the property
45: * @throws RuntimeException
46: * if the bean editor model does not have a property model for the provided name
47: */
48: PropertyModel get(String propertyName);
49:
50: /**
51: * Adds a new property to the model, returning its mutable model for further refinement.
52: *
53: * @param propertyName
54: * name of property to add
55: * @return the model for the property
56: * @throws RuntimeException
57: * if the property already exists
58: */
59: PropertyModel add(String propertyName);
60:
61: /**
62: * Adds a new property to the model, returning its mutable model for further refinement.
63: *
64: * @param propertyName
65: * name of property to add
66: * @param conduit
67: * the conduit used to read or update the property; this may be null for a synthetic
68: * or placeholder property
69: * @return the model for the property
70: * @throws RuntimeException
71: * if the property already exists
72: */
73: PropertyModel add(String propertyName, PropertyConduit conduit);
74:
75: /**
76: * Removes the named properties from the model, if present. It is not considered an error to
77: * remove a property that does not exist.
78: *
79: * @param propertyName
80: * the names of properties to be removed (case insensitive)
81: * @return the model for futher modifications
82: */
83: BeanModel remove(String... propertyName);
84: }
|