Update: I tried making the row variable a class variable instead of a
method variable. I want to be able to hide the row when the user
clicks the "dismiss" button. Here is my latest code. Any help is
appreciated.
public class GroupDataAlertDataGrid extends FlexTable {
private ClickListener dismissListener;
private Button dismissButton;
private int row = 0;
void addDataToFlexTable(final LocationsInfoDTO locationsInfoDTO)
{
for(final Info info : locationsInfoDTO.getInfos()){
dismissButton = new Button("Dismiss", dismissListener);
this.setWidget(row, 1, new Label(info.getLocationCode()));
this.setWidget(row, 2, new Label(info.getClientName()));
this.setWidget(row, 3, dismissButton);
dismissListener = new ClickListener() {
public void onClick(Widget sender) {
//make the row invisible
getRowFormatter().setVisible(row,
false);
//call server - tell session which
elements from list to remove
GwtAlertServicesDelegate.getService().removeLocationInfoFromSession(info,
new
AsyncCallback<LocationsInfoDTO>() {
@Override
public void
onFailure(Throwable arg0) {}
@Override
public void
onSuccess(LocationsInfoDTO arg0) {}
}
);
}
};
row++;
}
}
}
On Jul 9, 10:33 am, ccg123 <[email protected]> wrote:
> Have a FlexTable with made up of two columns of data and a third
> column with a button, that when clicked makes an asynchronous call and
> removes the data from the session. My problem is that when I click the
> button it refers to the info in the row above and not the same row
> that the button is in. Why?
>
> public class GroupDataAlertDataGrid extends FlexTable {
>
> private ClickListener dismissListener;
> private Button dismissButton;
>
> void addDataToFlexTable(final LocationsInfoDTO locationsInfoDTO)
> {
> int row = 0;
>
> for(final Info info : locationsInfoDTO.getInfos()){
>
> dismissButton = new Button("Dismiss", dismissListener);
>
> this.setWidget(row, 1, new Label(info.getLocationCode()));
> this.setWidget(row, 2, new Label(info.getClientName()));
> this.setWidget(row, 3, dismissButton);
>
> dismissListener = new ClickListener() {
> public void onClick(Widget sender) {
>
> GwtAlertServicesDelegate.getService().removeLocationInfoFromSession(info,
> new
> AsyncCallback<LocationsInfoDTO>() {
> @Override
> public void
> onFailure(Throwable arg0) {}
> @Override
> public void
> onSuccess(LocationsInfoDTO arg0) {}
> }
> );
> }
> };
> row++;
> }
> }
>
> }
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.