开发者

how to edit an record from search result in GWT using hyperlink

I have an a situation where I display all search records in Flex table for employee records, and each record as emp id, So开发者_开发技巧 i need to make emp id as Hyperlink and and by clicking the hyperlink will take the emp id and get it from DB. Can you tel me how to pass emp id?


if you are sending the user to a new "place" then use the history token as described by Peter. If you are trying to do it another way or embed the edit you can try:

Creating a custom dynamic link and interface for a callback - CustomLink - CustomLinkCallback

CustomLink can extend composite or whatever you want to create your custom widget It can simple be an Anchor. you may want to make the generic so you know what method to call on the object to display any text (anchor.setText(obj.getName());

CustomLink<T extends MyObject> extends Composite {
  CustomLink(final T obj, final CustomLinkCallback<T> callback){
    Anchor a = new Anchor(obj.getName());
    a.addClickHandler(new ClickHandler(){
      public void onClick(ClickEvent event){
        callback.onClick(obj);
      }
    });
    setWidget(a);
  }
}


public interface CustomLinkCallback<T extends MyObject> {
 public void onClick(T obj);
}

Then you can use the CustomLink:

add(new CustomLink(myObj, new CustomLinkCallback(){
  public void onClick(O obj){
    showEdit(obj);//where show edit can call obj.getId()
  }
});

This will give you a good bit of flexibility to do whatever you want.

Again, this is just a different way of going about things and whatever you do depends on your situation and needs so hopefully the history token approach works for you :)


You pass is an argument in history token: look at point 4. of my previous answer - gwt multi-page application

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜