0

I have some page that should have dynamic count of check boxes, and inputs depends on data received from database

now I do like this:

  1. make rpc call on component load (getting data for inputs)
  2. onSuccess add inputs dynamically on the form

result: form displayed without content(because it makes call async), only after resizing, it displays content properly (probably I can fire resize event or redraw with my self, don't know how.. )

question: I am new in GWT, What is the best way to do this task? (Now i am using gwt-ext http://gwt-ext.com/, but I think it's no matter )

update: to refresh panel it's possible to call doLayout();

Sergey
  • 933
  • 2
  • 19
  • 48

2 Answers2

2

I'm not familiar with gwt-ext but in "vanilla" gwt you have two options:

  1. Refresh your widget (that should show the result) in the onSuccess method
  2. Proceed with the rest of your code not until the result returned.

To get a bit more precise i would need more of your code.

Ben
  • 366
  • 1
  • 13
  • it's to much code there, I have TabPanel layout and have acess to the Panel http://gwt-ext.com/docs/2.0.4/com/gwtext/client/widgets/Panel.html that contains my form, how do you refresh your widget in vanilla; and how you make Proceed, you block all application while(!result){}? – Sergey May 14 '13 at 13:50
  • A refresh can usually only be performed on certain widgets like tables or lists. So if your Form has no refresh / redraw method it should not need one. – Ben May 14 '13 at 14:04
  • To delay the rest of your code you could put it into a new method and call that in the onSuccess method. The new method could consist of the creation of that form and its attachment to the panel. – Ben May 14 '13 at 14:05
  • do delay it's not possible to do for me, because i should return panel to render it(so main application wait my form), onSuccess call will be skipped – Sergey May 14 '13 at 14:30
1

I had a similar challenge, the content of my widget was loading for a few seconds. I display a ""Loading, please wait ..."" label until the widget is loaded:

final VerticalPanel mainPanel = new VerticalPanel();

    initWidget(mainPanel); 
    mainPanel.add(new Label("Loading, please wait ..."));
    mainPanel.add(new myCustomWidget()); // this constructor uses RPC to get content

    Timer t = new Timer()
    {
        public void run()
        {
            if (!mainPanel.getWidget(1).isVisible()) { 
                // do nothing
            } else {
                // remove label "Loading, please wait ..."
                mainPanel.remove(0);
                // stop timer
                cancel(); 
            }
        }
    };
    // repeat every 30 miliseconds until myCustomWidget is visible
    t.scheduleRepeating(30); 
kiedysktos
  • 3,910
  • 7
  • 31
  • 40