I forgot the methods for setting the "for" attribute id!  I used the
setHtmlFor() method name to match the dom LabelElement class (my own pref
would have been setFor(id)).

  /**
   * Sets the attribute "for" on the label tag to be the specified id.
   * @param id the String id to use.
   */
  public void setHtmlFor( String id )
  {
      ((LabelElement)getElement().cast()).setHtmlFor(id);
  }

  /**
   * Sets the attribute "for" on the label tag to be the id of the specified
widget.
   * @param forWidget the Widget that should have an id.  Note that if
forWidget does not have
   * an id, both it and the label "for" will be set to a unique id.
   */
  public void setHtmlFor( Widget forWidget )
  {
      assert forWidget != null;
      String wid = forWidget.getElement().getId();
      if ( wid == null || "".equals(wid) )
      {
          wid = DOM.createUniqueId();
          forWidget.getElement().setId(wid);
      }
      setHtmlFor(wid);
  }

--

You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@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.


Reply via email to