The problem described below relates to an inventory tracking Java program. There are multiple classes of inventory item and it is not possible to determine up front what properties of the intentory class are being tracked. Taking two classes for example:
InventoryClassOne {
String name;
Double price
}
InventoryClassTwo {
StockStatus status;
Long Quantity
}.
Storing the data is no problem, I can just define a
class InventoryProperty<T> {
T value;
}
and a
class InventoryClass {
Map<String, InventoryProperty<?>> inventoryPropertyMap;
}
The UI will be developed using the Wicket framework. I want to provide the administrator of the application with a means of adding new InventoryClasses and defining how the data gets laid out (tabular, list, etc…) on a per InventoryClass basis. Has anyone ever solved this type of problem before? What design patterns are available for achieving this. I don’t even know what words to type into Google in order get ideas for how to solve this.
As much as I love Wicket, I really don’t think it is the best option for this kind of meta-website.
But if I absolutely had to do it in Wicket, this is what I’d do:
Fragmentfor each basic UI widget.ListViewfor example, but even a simple repeater will do) which for each entry in your Field->Fragment mapping adds the fragment with a model pointing at the field.You might need to tweak it a bit, especially with tables but this is the basic idea.
However, and I have to repeat this, you’re practically losing most of the advantages of Wicket, even worse, you’ll have to put extra effort in to work your way around (or against) Wicket. It just doesn’t seem to be worth it.