This is simple question but there's No answer found on the Internet.

Ok, some widgets such as CheckBox have a method called myCHeckBox.setFormValue(text); so I take advantage of this method to store the unique ID into a CheckBox so that later on I just myCHeckBox.getFormValue(); to retrieve back the unique value.

However, there's no setFormValue on GWT Panel?

So if we want to store a unique value into a Panel (for example, FlowPanel, VerticalPanel)? Then Which method can i use to do that?

有帮助吗?

解决方案

The way I see it what you are really trying is to extend the purpose of the Panel. I cannot see why you would want a unique identifier, as the object of the Panel is as unique as it guess but that's not the point here.

Since you want to extend the Panel do just that. Extend the corresponding class and give it a unique value, implement the corresponding getters and setters and then you are set. It is as simple as that

class AbsolutePanelUnq extends AbsolutePanel
{
      private int uniqueId;

      public getUniqueId(){
          return uniqueId;
      }

      public setUniqueId(int uniqueId)
      {
          this.uniqueId = uniqueId;
      }

}

Then create the object and do whatever you need.

其他提示

Best way I can suggest:

Public class myPanel extends Panel {

  private myUniqueValue;

  //Getter setter for myUniqueValue
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top