This morning I asked this question and received a really great answer for it. I'm now trying to prototype the design and am running into a similar (but not same) issue. Essentially I'm trying to have a 100% configuration-driven GWT UI, where changes to a DB can produce radically different UIs but without any code changes.
My architecture is simple:
XulParser
that reads the XUL file out of the database and turns it into a ContainerProxy
instance
ContainerProxy
is my "proxy" equivalent to a com.google.gwt.user.client.ui.Panel
or something similar; it is just a bean/POJO that contains a list of other widget proxies (see code snippet below)Button
like the one belowButtonProxy
would be added to a ContainerProxy
(along with any other UI widgets in the same container/view/panel)ContainerProxy
somehow (???), and pull it down from the server.ContainerProxy
's children (the ButtonProxy
, etc.) into actual UI widgets.This way, at first I can put a certain XUL file into the database and the UI might only contain the "Order Now" button on it. But down the road, I might want to use a totally different UI, so I design a different XUL file, update the document in the database, and - voila - the UI changes for all users without any code changes. Please note: I understand this is not a normal way of doing things: I have a special use case where I need such config-driven UIs.
To help clarify the XUL-parsing process:
<button id="order" label="orderNow" clickHandler="org.myapp.OrderButtonHandler" />
after the XulParser reads the above snippet, we get:
ButtonProxy orderButton = new ButtonProxy("order", "OrderNow");
orderButton.addClickHandler(new OrderButtonHandler());
Anyways, my questions:
ContainerProxy
? Can anyone provide pseudo-code to help me visualize it?ContainerProxy
on the client-side, what UI mechanisms are available for me to translate the proxied classes into actual UI widgets? Is UIBinder available? Again, can someone provide some pseudo-code?Thanks in advance for any help here!
Here is a bit of a code idea that would do what you wanted. I haven't tested this, but you can get the idea of how it all could work together from it.
String htmlFragment = "<div><button id='action1' type='button>Action 1<button/><div/>";
HTMLPanel container = new HTMLPanel(htmlFragment);
RootLayoutPanel.get().add(container);
Element button1El = container.getElementById("action1");
if(button1El != null){
Button button1 = Button.wrap(button1El);
button1.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
// What you want button 1 to do
}
});
}