Return a HorizontalPanel to a DisclosurePanel when I perform an AsyncCallback

109 views
Skip to first unread message

Glyndwr Bartlett

unread,
Aug 7, 2016, 8:03:21 PM8/7/16
to GWT Users
I want to return a HorizontalPanel to a DisclosurePanel when I perform an AsyncCallback. The code is (please note the commented out text I need to work - //addressDisclosurePanel.add(addressHorizontalPanel);):


private DisclosurePanel addressDisclosurePanel(String nameId) {

    final DisclosurePanel addressDisclosurePanel = new DisclosurePanel("Address");

 

    //Get the Addresses

    AsyncCallback<List<Address>> callback = new GetAddressHandler<List<Address>>(PersonalDetailsView.this);

    rpc.getAddressList(nameId, callback);

 

    //addressDisclosurePanel.add(addressHorizontalPanel);

 

    return addressDisclosurePanel;

}

 

class GetAddressHandler<T> implements AsyncCallback<List<Address>> {

    //Get the list of Addresses.

    PersonalDetailsView view;

 

    final HorizontalPanel addressHorizontalPanel = new HorizontalPanel();

 

    public GetAddressHandler(PersonalDetailsView view) {

        this.view = view;

    }

 

    public void onFailure(Throwable ex) {

        System.out.println("RPC call failed - GetAddressHandler - Notify Administrator.");

        Window.alert("Connection failed - please retry.");

    }

    public void onSuccess(List<Address> result) {

        Window.alert("Render address.");

        addressHorizontalPanel.add(view.renderAddresses(result));

    }

}

 

private FlexTable renderAddresses(List<Address> addressList) {

    //Load each TabPanel with Addresses

    Window.alert("get address.");;

 

    final FlexTable flexTableAddress = new FlexTable();

 

    if (addressList == null || addressList.isEmpty()) {

        //Add a place to add an address

 

        //Address Type

        final Label lblAddressType = new Label("Address Type:");

        lblAddressType.setStyleName("gwt-Label-Login");

        flexTableAddress.setWidget(0, 0, lblAddressType);

 

        final TextBox textBoxAddressType = new TextBox();

        textBoxAddressType.setStyleName("gwt-TextBox");

        textBoxAddressType.setWidth("300px");

        flexTableAddress.setWidget(0, 1, textBoxAddressType);

 

    }else{

        int row = 0;

        //

        //Create a place to display each Address and allow update

        //

        for (final Address eachAddress : addressList) {

            //Store key

            final String addId = eachAddress.getAddId();

            Window.alert("addId = " + addId);

 

            //Address Type

            final Label lblAddressType = new Label("Address Type:");

            lblAddressType.setStyleName("gwt-Label-Login");

            flexTableAddress.setWidget(row, 0, lblAddressType);

 

            final TextBox textBoxAddressType = new TextBox();

            textBoxAddressType.setText(eachAddress.getAddType());

            textBoxAddressType.setStyleName("gwt-TextBox");

            textBoxAddressType.setWidth("300px");

            flexTableAddress.setWidget(row, 1, textBoxAddressType);

 

            row++;

        }

    }

    return flexTableAddress;

}

Jens

unread,
Aug 8, 2016, 4:31:20 AM8/8/16
to GWT Users
Move

//addressDisclosurePanel.add(addressHorizontalPanel);

into your GetAddressHandler and pass in the newly created addressDisclosurePanel? Alternatively use an anonymous class as callback.

-- J.

Glyndwr Bartlett

unread,
Aug 8, 2016, 5:17:25 AM8/8/16
to google-we...@googlegroups.com
Hi Jens,

When I do this (in onSuccess) I get the error: addressDisclosurePanel cannot be resolved

Are you ale to provide me with code examples please as I am not a real programmer I am doing this for Scouts.

Kind regards,

Glyn


--
You received this message because you are subscribed to a topic in the Google Groups "GWT Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/taQlLOMZ3zw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-web-toolkit+unsub...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Glyndwr Bartlett

unread,
Aug 9, 2016, 6:15:42 PM8/9/16
to google-we...@googlegroups.com
Hi Jens,

I have spent over three weeks trying to get this to work. I have tried to include your suggestion; however, I just can not get it to work. Any assistance you, or anyone else, can provide would be greatly appreciated.

Kind regards,

Glyn

On 8 August 2016 at 19:16, Glyndwr Bartlett <glyndwr....@gmail.com> wrote:
Hi Jens,

When I do this (in onSuccess) I get the error: addressDisclosurePanel cannot be resolved

Are you ale to provide me with code examples please as I am not a real programmer I am doing this for Scouts.

Kind regards,

Glyn

On 8 August 2016 at 18:31, Jens <jens.ne...@gmail.com> wrote:
Move

//addressDisclosurePanel.add(addressHorizontalPanel);

into your GetAddressHandler and pass in the newly created addressDisclosurePanel? Alternatively use an anonymous class as callback.

-- J.

--
You received this message because you are subscribed to a topic in the Google Groups "GWT Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/taQlLOMZ3zw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-web-toolkit+unsubscribe@googlegroups.com.

JonL

unread,
Aug 10, 2016, 10:11:00 AM8/10/16
to GWT Users

Your order of operations appears incorrect.  From your original code I don't see where GetAddressHandler.addressHorizontalPanel is ever actually added to the addressDisclosurePanel.



On Tuesday, August 9, 2016 at 3:15:42 PM UTC-7, Glyndwr Bartlett wrote:
Hi Jens,

I have spent over three weeks trying to get this to work. I have tried to include your suggestion; however, I just can not get it to work. Any assistance you, or anyone else, can provide would be greatly appreciated.

Kind regards,

Glyn
On 8 August 2016 at 19:16, Glyndwr Bartlett <glyndwr....@gmail.com> wrote:
Hi Jens,

When I do this (in onSuccess) I get the error: addressDisclosurePanel cannot be resolved

Are you ale to provide me with code examples please as I am not a real programmer I am doing this for Scouts.

Kind regards,

Glyn

On 8 August 2016 at 18:31, Jens <jens.ne...@gmail.com> wrote:
Move

//addressDisclosurePanel.add(addressHorizontalPanel);

into your GetAddressHandler and pass in the newly created addressDisclosurePanel? Alternatively use an anonymous class as callback.

-- J.

--
You received this message because you are subscribed to a topic in the Google Groups "GWT Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/taQlLOMZ3zw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-web-toolkit+unsub...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.

Jens

unread,
Aug 10, 2016, 10:51:56 AM8/10/16
to GWT Users
private DisclosurePanel addressDisclosurePanel(String nameId) {
    
final DisclosurePanel addressDisclosurePanel = new DisclosurePanel("Address");

   
//Get the Addresses

   
AsyncCallback<List<Address>> callback = new GetAddressHandler<List<Address>>(PersonalDetailsView.this, addressDisclosurePanel);
    rpc.getAddressList(nameId, callback);


    return addressDisclosurePanel;
}

class GetAddressHandler<T> implements AsyncCallback<List<Address>> {

   
//Get the list of Addresses.
   
PersonalDetailsView view;
    DisclosurePanel addressDisclosurePanel;

   
final HorizontalPanel addressHorizontalPanel = new HorizontalPanel();

   
public GetAddressHandler(PersonalDetailsView view, DisclosurePanel addressDisclosurePanel) {
        this.view = view;
        this.addressDisclosurePanel = addressDisclosurePanel;
    
}


   
public void onFailure(Throwable ex) {
        
System.out.println("RPC call failed - GetAddressHandler - Notify Administrator.");
        
Window.alert("Connection failed - please retry.");
    
}

   
public void onSuccess(List<Address> result) {
        
Window.alert("Render address.");
        addressHorizontalPanel
.add(view.renderAddresses(result));
        addressDisclosurePanel.add(addressHorizontalPanel);
    
}

}


Changed code is marked bold.

-- J.

Glyndwr Bartlett

unread,
Aug 10, 2016, 5:48:55 PM8/10/16
to google-we...@googlegroups.com
Jens,

You are magnificent! I can not express how grateful I am for your help :-)

Yours-in-Scouting,

Glyn (Wirrin)



-- J.

--
You received this message because you are subscribed to a topic in the Google Groups "GWT Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/taQlLOMZ3zw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-web-toolkit+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages