Here other ideas about how to develop webby further are outlined.
It would be nice to have an API overview available, but ... sorry, not yet.
Idea: I would like to search a subset of all the beans in my application (which could be the set of all beans) through a generic search form; the search form maybe can use the FormDescriptors in order to introspect the beans.
Challenge: How to enable that not always all beans is looked at when searching?
Use something like sweet titles?
Idea: Have an attribute on an article which uses jtextile to display it's rendered text.
How to use blobs with hibernate?
Make a more complex example, with e.g. inheritance in the model?
doesNotFit. Somehow something does not fit:
<default>: View type: Company singleton: select from ... Company.description.type=JTextile(mode=view) Company.id.isVisible=false Browse articles: View
About state: Such stats should be owned by the user:
user --> state
State can define attribute values of the view. Examples:
What about just defining an object model (that can be persisted) which defines the structure needed? Classes then would probably be:
Entity (1:1 to FormDescriptor) --* Attribute
--* Relation
... pretty similar to the classes there are already in webby?BeanPageFactory Page createEditBeanPage(IModel model);
Should have a default implementation which instantiates SimpleBeanPage instances.
This factory can be used to create simple ("default") descriptors which use introspection to analyze the classes given as a set of viewable classes to the factory.
The idea of a BeanAction is that independant of how a possible action on a "business bean" is presented, an action can be described, so that Webby can present the action to the user. Finally, the user should be able to execute the action, of course...
There should be a List (NOT a Set) of BeanActionDescriptors available for every FormDescriptor. Maybe later also for RelationDescriptors there could be a list of those actions that are intended to be available for each item in a list of related beans/objects.
BeanActionDescriptor isActionVisible(IModel model) isActionEnabled(IModel model) void execute(IModel model) String getDisplayName(IModel model)
If you want to use Webby just to show/navigate beans using the forms and lists which are part of Webby itself, it is easy. If however you want to mix the UI stuff and application flow provided by Webby with other UI support, this can't be done so easily: You could implement your own BeanPageFactory, but this would only allow you to go to your own page whenever the user follows a to-n relation.
In order to make this better, let's look at the following which seems to be true:
This leads to the following design change: Instead of
void execute(IModel model)
it will become
Page execute(IModel model, Page currentPage)
whereas the currentPage is the current page for which the action is executed from (what a surprise ;-) and the return value is either the same as the currentPage parameter or null in order to indicate that the page shall not change, or it is any other page which will be set as the new page using Component.setResponsePage.
...
Most probably using inheritance in the model results in ugly (or hardly usable) results: Most probably I would not see attributes of sub classes in the lists, maybe I would not even see those attributes on the edit page!
This is something to be worked on, I'd say.
Idea: Allow actions to be taken from the beans instead of explicitly code them in the configurator?
Possible solution: Actions could be coded in the bean directly as methods and marked via annotations:
Use annotations to mark those methods of a bean that shall be visible as an action in the UI. How it is made visible is not to be decided by the bean but by webby. There is however some limited control about "what comes next" in the application flow by what is returned:
By the way, it should still be possible to add actions via the descriptors!
Advantages of this solution:
Disadvantages of this solution:
@interface Action {
String displayName();
}Possible enhancement: Annotate a resource id instead of a display name. This way internationalization of the display names might be possible.
Together with webby4db it is an issue when to commit the transaction: Committing the transaction inside the annotated bean method does not allow the creation of a bean model (HibernateObjectModel) any more afterwards, because the transaction is closed. Thus we need a specialisation of SimpleBeanAction in webby4db: This can be enabled by a BeanActionDescriptorFactory provided via WebbyConfigurator getBeanActionDescriptorFactory?
Idea: Allow the user to set a to-1 relation, provided that the property descriptor gives a list of choices.
The list of choices should be given indirectly however: the propertydescriptor should return a factory which takes as argument a bean object and returns a List of choices (of beans that could be assigned to the to-1 property via set<PropertyName>. During runtime (i.e. when the page is rendered) this List can be loaded via a LoadableDetachableModel ... well, the LoadableDetachableModel should invoke the factory method. (See also OrderbookConfigurator in webby-orderbook, revision 1.3.4.3.) Thus in short:
interface ChoicesFactory { // new interface
List getChoices(Object bean);
}
// add following to To1RelationPropertyDescriptor:
ChoicesFactory getChoicesFactory()
// extend To1RelationBeanFormPanel to make use of this information
...
// extend SimpleFormDescriptorFactory to add useful <<<ChoicesFactory>>>'s to the simple
// form descriptorsCurrently, there is no exception handling implemented: Whenever an exception must be caught, it is typically wrapped in a RuntimeException. No exceptional situation is handled seriously. (This is of course due to the early stage this piece of software is in...)
This seems particularly bad when calling actions which are coded in the model: An exception could represent an exceptional situation in the business logic. Then there should definitely not be a runtime exception thrown, but rather an error handling should be in place which allows smart reactions on the exceptional situation.
Is possible, see the example Webby Projects. However it is not very comfortable: You have to know the date format to be used. Improvements could be
How exactly could this be done? Maybe a good support could be via annotated components to be used for properties, see next section.
Not done yet.
Here some ideas I had but I don't "support" any more.
PersistentObject.businessId BusinessIdGenerator long lastId long getNewId(Session) static getInstance
Enabling business ids in the way they might be a good idea for hibernate is not in scope of what should be done with webby: Webby is independent of the persistence layer.
There is another project webby4db which might be interested in supporting business ids as sketched here.