Webby implements the concepts of
What is a business class / business object? A business class is a Java class that describes attributes, relations and behavior (as every class does) and that represents something meaningful to the users of an application, typically (but not always) related to something that exists in the real world outside the computer. Examples:
Every business class needs a descriptor, telling us the Java class of business instances, the attributes, the relations and the actions:
public interface EntityDescriptor extends Serializable {
Class getEntityClass();
List<AttributeDescriptor> getAttributes();
List<RelationDescriptor> getRelations();
List<BeanActionDescriptor> getActions();
WebbyConfigurator getConfigurator();
}Additionally, the descriptor needs to be Serializable (because session objects in wicket must be storable in the session; also each descriptor should know it's configurator.
The UI components (and maybe other parts of the application) often have an EntityDescriptor reference given, but need to find/access other descriptors and/or instantiate wicket models or other UI components / pages. This is what the configurator should help with: Allow to find these things.
What might also be needed: A data provider to supply a component with a set of business objects, if another buesiness object has got a relation to this set:
public interface WebbyConfigurator extends Serializable {
BeanPageFactory getEntityPageFactory();
BeanModelFactory getBeanModelFactory();
SortableDataProvider getToNRelationDataProvider(Class clazz, IModel beanModel, RelationDescriptor rd);
Set getAllInstances(Class clazz);
Set<Class> getViewableClasses();
EntityDescriptor getEntityDescriptor(Class entityClass);
BeanActionMethodInvoker getBeanActionMethodInvoker(Method method);
}Having a configurator and descriptors can be used by UI components to display and navigate business objects. Some simple forms, panels and pages are provided in Webby, which can be instantiated individually, e.g. like this:
IModel businessModel = new YourModel(businessObject);
EntityDescriptor descriptor =
configurator.getEntityDescriptor(businessObject.getClass());
Page page = new SimpleEditBeanPage(businessModel, descriptor);The simple UI components in turn use the configurator, if needed, to get access to sets of business objects for navigating a relation and for instantiating wicket models for business objects.
In order to avoid coding descriptors manually, some utility classes for introspection and SimpleEntityDescriptor are available:
Introspection must make some assumptions. An important one is that getters and setters of to-n relations use typed collections (based upon Java's Generics). It might be helpful to explain the assumptions better...
Many web applications need persistence. Webby itself doesn't care about persistence, but it is well suited to have business classes persisted.
Webby4db is a lightweight artefact targeting exactly this, using databinder, which in turn uses Hibernate.
See the home of webby4db, but also look at the examples which also use Webby4db.