Sorry but the code works but I do not understand why it works...
this is all code of the method
// this method is call when click add button from web interface.
private void addStock(String s)
{
// TODO
int row;
lastUpdatedLabel.setText(s);
final String
symbol=newSymbolTextBox.getText().toUpperCase().trim();
if (!symbol.matches("^[0-9A-Z\\.]{1,10}$"))
{
Window.alert("'" + symbol + "' is not a valid symbol.");
newSymbolTextBox.setText("");
return;
}
if (stocks.contains(symbol))
return;
row = stocksFlexTable.getRowCount();
stocks.add(symbol);
stocksFlexTable.setText(row, 0, symbol);
Button removeStock=new Button("X");
removeStock.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event)
{
System.out.println(symbol);
// why
when I click on button remove (removestock) the symbol variable
contains
the value corresponding to the table row?
int removedIndex =
stocks.indexOf(symbol);
System.out.println(symbol);
stocks.remove(removedIndex);
stocksFlexTable.removeRow(removedIndex + 1);
}
});
stocksFlexTable.setWidget(row, 3, removeStock);
newSymbolTextBox.setText("");
}
with best regards,
Angel
On 4 Gen, 13:36, Amrutha Thomas <[email protected]> wrote:
> Button removeStockButton = new Button("x");
> removeStockButton.addStyleDependentName("remove");
> removeStockButton.addClickHandler(new ClickHandler() {
> public void onClick(ClickEvent event) {
> removeStock(symbol);
> }
> });
> stocksFlexTable.setWidget(row, 3, removeStockButton);
>
> try this it works
>
>
>
>
>
>
>
>
>
> On Wed, Jan 4, 2012 at 4:09 PM, ang <[email protected]> wrote:
> > Hi to everybody,
> > j'm new to gtw (sorry for my english) I have a problem with the
> > tutorial in question ... in step 5
>
> > [url]http://code.google.com/intl/it-IT/webtoolkit/doc/1.6/tutorial/
> > codeclient.html[/url]
>
> > how come when I click on button remove the symbol variable contains
> > the value corresponding to the table row?
>
> > [code]
> > ..
> > ...
> > // Add a button to remove this stock from the table.
> > Button removeStockButton = new Button("x");
> > removeStockButton.addClickHandler(new ClickHandler() {
> > public void onClick(ClickEvent event) {
> > int removedIndex = stocks.indexOf(symbol);
> > stocks.remove(removedIndex);
> > stocksFlexTable.removeRow(removedIndex + 1);
> > }
> > });
> > stocksFlexTable.setWidget(row, 3, removeStockButton);
>
> > [/code]
>
> > --
> > 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.
>
> --
> with best regards,
>
> Amrutha
--
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.