2011年4月2日土曜日

GWT UiBinder で RadioButton を使う




<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
  <ui:style>
    .my-RadioButton {
      font-weight: bold;
    }
  </ui:style>
  <g:HTMLPanel>
    <g:VerticalPanel>
      <g:HTML><h3>Select your favorite color:</h3></g:HTML>
      <g:RadioButton name="color" value="true">blue</g:RadioButton>
      <g:RadioButton name="color">red</g:RadioButton>
      <g:RadioButton name="color" enabled="false">yellow</g:RadioButton>
      <g:RadioButton name="color">green</g:RadioButton>
      <g:HTML><h3>Select your favorite sport:</h3></g:HTML>
      <g:RadioButton name="sport">Baseball</g:RadioButton>
      <g:RadioButton name="sport">Basketball</g:RadioButton>
      <g:RadioButton name="sport" value="true">Football</g:RadioButton>
      <g:RadioButton name="sport">Hockey</g:RadioButton>
      <g:RadioButton name="sport">Soccer</g:RadioButton>
      <g:RadioButton name="sport" styleName="{style.my-RadioButton}">Water Polo</g:RadioButton>
    </g:VerticalPanel>
  </g:HTMLPanel>
</ui:UiBinder> 


スコープを指定するための name 属性が必須になります。


package yanzm.example.hellowtgt.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

public class RadioButton extends Composite {

  private static RadioButtonUiBinder uiBinder = GWT.create(RadioButtonUiBinder.class);

  interface RadioButtonUiBinder extends UiBinder<Widget, RadioButton> {
  }

  public RadioButton() {
    initWidget(uiBinder.createAndBindUi(this));
  }
}

■ その他
Java code による実装例 (Showcase)
com.google.gwt.user.client.ui.RadioButton


 

1 件のコメント:

  1. Sports betting system makes +$3,624 profit last week!

    Z-Code System winning bets and predictions for MLB, NHL, NBA & NFL...

    返信削除