On 9 juil, 19:33, 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?
Because that's what you coded.
> 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);
Let's create a button with a (@Deprecated) ClickListener.
On first iteration, dismissListener hasn't been initialized, so it has
its default value: null.
> this.setWidget(row, 1, new Label(info.getLocationCode()));
> this.setWidget(row, 2, new Label(info.getClientName()));
> this.setWidget(row, 3, dismissButton);
>
> dismissListener = new ClickListener() {
Now that the button is created and "used", let's create a
ClickListener for the current Info, but don't use it.
On first iteration, this sets dismissListener from 'null' to a
ClickListener for the first row (but notice that the button has been
created with a null listener, and added the first row already; so this
listener will only be used on second iteration, so that the second
button's listener will be related to the first Info, and so on for
other rows)
--
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.