Wednesday, August 10, 2016

Re: Return a HorizontalPanel to a DisclosurePanel when I perform an AsyncCallback

Jens,

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

Yours-in-Scouting,

Glyn (Wirrin)


On 11 August 2016 at 00:51, Jens <jens.nehlmeier@gmail.com> wrote:
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.

--
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.
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.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@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.

No comments:

Post a Comment