I have created a LabelTextBox widget that emits pretty streamlined
HTML/DOM like the following:
<div class="LabelTextBox">
<label class="esf-Label" for="gwt-uid-44">ESF Name</label>
<input id="gwt-uid-44" class="gwt-TextBox required" type="text"
tabindex="0"/>
</div>
The LabelTextBox uses a FlowPanel which results in the <div> with the
specified class to style it.
It emits a <label> tag (using the Label widget I posted earlier) with
the 'for' being the id of the <input> tag, and if none is set, uses a
unique gwt-generated id.
And it emits a <input> using a regular TextBox widget.
Then I use CSS styling based on prior recommendation in this list to
allow them to be stacked or otherwise controlled, as well as the
default width of these input fields:
.LabelTextBox {
float: left;
width: 225px;
}
.LabelTextBox label {
float: left;
width: 225px;
margin-left: 1px;
}
.LabelTextBox .gwt-TextBox {
float: left;
width: 225px;
}
If anybody is interested, here's the code I wrote for it (and I have a
similar one for LabelTextArea):
package com.esignforms.open.gwt.client.widget;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.TextBox;
/**
* A <label> and <input type="text"> that essentially is a TextBox,
with an added Label, but one that emits a <label> tag instead of
* the GWT Label.
*/
public class LabelTextBox
extends Composite
{
com.esignforms.open.gwt.client.widget.Label label;
TextBox textBox;
FlowPanel panel;
public LabelTextBox(String labelText)
{
this(labelText,false);
}
public LabelTextBox(String labelText, boolean labelIsHtml)
{
this(labelText,labelIsHtml,"LabelTextBox");
}
public LabelTextBox(String labelText, boolean labelIsHtml, String
className)
{
label = new com.esignforms.open.gwt.client.widget.Label();
if ( labelIsHtml )
label.setHTML(labelText);
else
label.setText(labelText);
textBox = new TextBox();
panel = new FlowPanel();
panel.setStyleName(className);
String uid = DOM.createUniqueId();
setId(uid);
panel.add(label);
panel.add(textBox);
initWidget(panel);
}
public void setId(String id)
{
label.setHtmlFor(id);
textBox.getElement().setId(id);
}
public com.esignforms.open.gwt.client.widget.Label getLabel()
{
return label;
}
public TextBox getTextBox()
{
return textBox;
}
public boolean isEnabled()
{
return textBox.isEnabled();
}
public void setEnabled(boolean v)
{
textBox.setEnabled(v);
}
public String getValue()
{
return textBox.getValue();
}
public void setValue(String v)
{
textBox.setValue(v);
}
public void addStyleName(String v)
{
textBox.addStyleName(v);
}
}
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.