Scenario: my application makes use of uibinder. I have a splitlayout panel with:
-
a menu on the left side of the screen with a few hyperlinks (history support);
-
a central SimplePanel bound to the historychanged event like this:
String historyToken = event.getValue();
content.setWidget(new Label(historyToken)); -
not very useful right? Now I want to populate my center panel with a dynamically created widget.
-
I know that reflection is not possible on the client-side.
-
So how can I decide what class to create / add to my content panel, and avoid an awful if / else if / else if / … block of code, based on the history token?
-
I was thinking about using constants in a more elegant “switch” way, but it’s substantially the same solution.
Ok, the solution is using DeferredBinding and write a code generator for a “factory” class.