How to apply gwt-query on the elements which are declared in gwt entrypoint?

147 views Asked by At

We are showing messages after successful completion of creating, saving, updating the vouchers in our application, We are using gwt to do all the above processing and will get the success message from server side by using gwt-rpc and then put that message in the panel which is declared in the gwt entry point. We decided to use gwt-query to make the application effective like once we showed message to the user it should be hide after some time(secs).

We have tried for that but we were unable to apply the gquery on the panels or elements which were declared in the gwt entry point. We applied for the elements in the html or jsp file. We need some help regarding this.

Code snippet

Public class myGwtEntryPoint implements EntryPoint {
VerticalPanel fiscalSettingPanel = new VerticalPanel();
  AbsolutePanel messagePanel = new AbsolutePanel();
  SimplePanel finishPanel = new SimplePanel();
  BaseCurrency baseCurrencyGlobal;
  ListBox monthListBox = new ListBox();

  @Override
  public void onModuleLoad() {
    // Removing loading image in Jsp before loading gwt module.
    if (RootPanel.get("accountingsetup-div").getElement().hasChildNodes())
      RootPanel.get("accountingsetup-div").getElement().getFirstChildElement().removeFromParent();

      // Here i am getting success message from server(gwt-rpc) and that to the  "messagePanel", that messagePanel to the 'fiscalSettingPanel '   
         fiscalSettingPanel .add("messagePanel");
 }

In the above code snippet, once message is displayed, i want to make the message disappear after 5 secs by using gwt-query

2

There are 2 answers

1
Thomas Meyer On

like this?

import com.google.gwt.user.client.Timer;

private Timer myTimer = new Timer()
{   
    @Override
    public void run()
    {
        /**
         * remove your Panel
         */
        fiscalSettingPanel.remove("messagePanel");
    }
};
myTimer.schedule(5000);
0
Manolo Carrasco Moñino On

You can use gquery to select and interact with elements and widgets, you can use css selectors, elements and widgets as parameters, so in your case

1.- I will use gquery to remove the loading image from your jsp in this way, instead of dealing with large code:

// Removing loading image in Jsp before loading gwt module.
$("#accountingsetup-div").empty();

2.- And related with how to hide a panel after a while, I will use the effects queue, so chaining a delay and a hide effect could be enough.

 // Here i am getting success message from server(gwt-rpc) and that to the  "messagePanel", that messagePanel to the 'fiscalSettingPanel '

 messagePanel.clear();
 messagePanel.add(new Label("Server message"));

 // First show the panel, and them enqueue an effect to hide it
 $(messagePanel).show().delay(4000).fadeOut();