Using a hyperlink may not be the best way to do something like this, because you should not use a ClickHandler with a hyperlink. The hyperlink sets the HistoryToken, and you must respond to a change in History.
I would use a shortcut and possibly use it as a regular link if you want to have the same look. (I will use the shortcut in the following example, but you can change it to a hyperlink if you want.)
, Label. ID, . , FlexTable. ClickHandler, id , FlexTable.
public class FlexTableLabel extends Label implements ClickHandler {
int id=0;
public FlexTableLabel(String text, int id) {
this.id=id;
this.setText=text;
this.addCickHandler(this);
}
public void onClick(ClickEvent event) {
yourService.getNewFlexTable(this.id);
}
}
( , ArrayList . ArrayList id):
for(int i=0; i<result.size;i++) {
FlexTable.setWidget(i,0, new FlexTableLabel(result.get(i).text, result.get(i).id);
}
, - , - , .
Chirayu:
- .
Singleton Pattern, .
:
public static YourPanel extends Panel {
private static YourPanel instance=null;
public static YourPanel getInstance() {
if(instance==null) {
instance=new YourPanel();
}
return instance;
}
}
EntryPointClass - :
public class YourEntryClass extends EntryPoint {
public void onModuleLoad() {
RootPanel.get().add(YourPanel.getInstance());
}
}
YourPanel.getInstance() onSuccess() , :
yourService.getNewFlexTable(this.id, new AsyncCallback<ArrayList<String>>() {
public void onSuccess(ArrayList<String> result) {
For(int i=0;i<result.size;i++) {
YourPanel.getInstance().add(result.get(i);
}
}
});
, . , .