开发者

GWT/JAVA - Getting an AJAX call into a dialog box

开发者 https://www.devze.com 2023-01-09 13:07 出处:网络
I\'m new to GWT, an开发者_Go百科d having an issue getting the result of an AJAX call to show up in my Dialog box.

I'm new to GWT, an开发者_Go百科d having an issue getting the result of an AJAX call to show up in my Dialog box.

I set up my dialog box, Vpanel, and response label here:

   VerticalPanel eventDetailWindow = new VerticalPanel();

   final DialogBox dialogBox2 = new DialogBox();
   dialogBox2.setText("Event Detail");
   dialogBox2.setAnimationEnabled(true);

   final HTML serverResponse3 = new HTML("<b> ok, this is working</b>");
   serverResponse3.addStyleName("detailView");

   eventDetailWindow.add(serverResponse3);
   eventDetailWindow.addStyleName("detailWindow");
   dialogBox2.setWidget(eventDetailWindow);
   RootPanel.get("detailWindow").add(eventDetailWindow);

Then, in the onSuccess method I have this:

dialogBox2.setText("Remote Procedure Call");
serverResponse3.setHTML(result);
dialogBox2.center();
closeButton.setFocus(true);

However, when it fires, the response shows up on the page, not in the dialog box and the dialog box is empty. It looks like it's set up the same as the starter project - which works fine..

Can someone help me out...?


Dont use that RootPanel.get("detailWindow").add(eventDetailWindow); if you want to only add into dialogBox2

use like that:

dialogBox2.setWidget(eventDetailWindow);

and You dont have to add dialogBox2.show(); because dialogBox2.center(); that code will show the dialogBox2 initially.

package com.ex.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;


public class Example implements EntryPoint {

public void onModuleLoad() {
        VerticalPanel eventDetailWindow = new VerticalPanel();

       final DialogBox dialogBox2 = new DialogBox();
       dialogBox2.setText("Event Detail");
       dialogBox2.setAnimationEnabled(true);

       final HTML serverResponse3 = new HTML("<b> ok, this is working</b>");
       serverResponse3.addStyleName("detailView");

       eventDetailWindow.add(serverResponse3);
       eventDetailWindow.addStyleName("detailWindow");
       dialogBox2.setWidget(eventDetailWindow);
       Button b= new Button("click");
       b.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox2.setText("Remote Procedure Call");
            serverResponse3.setHTML("result");
            dialogBox2.center();
        }
    });

       RootPanel.get().add(b);

  }
}


You are adding the eventDetailWindow to something on the page and I don't see a call to .show() on the DialogBox. Can you post your full code?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号