Store them in a separate list or iterate through all child widgets of your HATestPanel using FlowPanel.getWidgetCount() and FlowPanel.getWidget(int index). For each widget check if its a CompositePanel, cast it and call its getter to get the value.
Am Samstag, 14. April 2012 17:06:08 UTC+2 schrieb tong123123: > > I think you mean add a getter and setter in CompositePanel, but the > problem is how to access it in HATestPanel? > as I don't know the variable name of each CompositePanel. > just like I click the button three times, then what is the variaible name > of these 3 compositePanel? although in each click handler its name is > compositePanel. > > > Jens於 2012年4月14日星期六UTC+8下午10時36分21秒寫道: > >> Store your widgets in fields and add getter/setter methods so you can >> access their data. >> >> Also in your ClickHandler instead of: >> >> ((HATestPanel)((Button) >> event.getSource()).getParent()).add(compositePanel); >> >> you can simply do >> >> add(compositePanel) or HATextPanel.this.add(compositePanel) if you like. >> >> -- J. >> >> Am Samstag, 14. April 2012 16:17:36 UTC+2 schrieb tong123123: >>> >>> as shown in the attached image, if I want to access the value of the >>> textbox with value "value2" (the textbox in the second row after the "add" >>> button"), how to do it as seem there is no a specific name to access it. >>> >>> the code is as follow: >>> >>>> package com.mycompany.project.client; >>>> >>>> import com.google.gwt.event.dom.client.ClickEvent; >>>> import com.google.gwt.event.dom.client.ClickHandler; >>>> import com.google.gwt.user.client.ui.Button; >>>> import com.google.gwt.user.client.ui.FlowPanel; >>>> import com.google.gwt.user.client.ui.Widget; >>>> >>>> public class HATestPanel extends FlowPanel{ >>>> >>>> Button btnAdd = new Button("Add"); >>>> Button btnListWidget = new Button("List Widget"); >>>> >>>> public void onLoad(){ >>>> >>>> this.add(btnAdd); >>>> btnAdd.addClickHandler(new ClickHandler(){ >>>> >>>> @Override >>>> public void onClick(ClickEvent event) { >>>> // TODO Auto-generated method stub >>>> CompositePanel compositePanel = new CompositePanel(); >>>> ((HATestPanel)((Button) >>>> event.getSource()).getParent()).add(compositePanel); >>>> } >>>> >>>> }); >>>> >>>> } >>>> } >>>> >>> >>> and the implementation of CompositePanel is as follow: >>> >>>> package com.mycompany.project.client; >>>> >>>> import com.google.gwt.user.client.ui.FlowPanel; >>>> import com.google.gwt.user.client.ui.HorizontalPanel; >>>> import com.google.gwt.user.client.ui.Label; >>>> import com.google.gwt.user.client.ui.ListBox; >>>> import com.google.gwt.user.client.ui.TextBox; >>>> >>>> public class CompositePanel extends HorizontalPanel{ >>>> >>>> protected void onLoad(){ >>>> ListBox lb = new ListBox(); >>>> TextBox txt2 = new TextBox(); >>>> lb.addItem("field1"); >>>> lb.addItem("field2"); >>>> lb.addItem("field3"); >>>> this.add(lb); >>>> this.add(txt2); >>>> } >>>> >>>> } >>>> >>> >>> maybe my design is poor, any better method suggested? >>> in reality, the listbox is used for user select "searc field", and the >>> textbox is for user enter search value for that search field. >>> >>> >>> >>> >>> >> -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/kYzgE5sKoQIJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.