Hi,
I am creating my own widgets library using gwt 2.5 for my application to be 
used.But facing issues while creating this widget component.Widgets 
creation will be like this-textbox with label,checkbox with label,datebox 
with label,radio button with label.Here label field is common for all 
widget creation.
See the below code,

/*basebox code which will create the default label with corresponding 
component(widget)*/
public abstract class BaseBox extends FlowPanel{
protected Widget box;
private String title;
private String name;
Widget labelWidget;
private LabelBoxField boxLabel;

public BaseBox(String name){
this.name=name; 
addMembers(name);
}

protected void addMembers(final String name) {
this.name = name;
box = createBox(name);
}

protected abstract Widget createBox(String name);

public void setTitle(String title) {
this.title=title;
labelWidget = createLabel(title);
}

/*code for creating label*/
protected Widget createLabel(final String title) {
if (title == null || title.isEmpty()
|| title.equals(Constants.EMPTY_STRING)) {
this.boxLabel = new LabelBoxField();
} else {
if (getIsHintButtonRequired()) {
this.boxLabel = new LabelBoxField(title,
getIsHintButtonRequired(),getRequired());
} else {
this.boxLabel = new LabelBoxField(title,getRequired());
}
}
boxLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
return boxLabel;
}

public void showTitle(Boolean showTitle){
this.showTitle=showTitle;
}


/*this method will render the component before adding it to 
main-panel----should not call this method implicitly*/
public void redraw(){

addStyleName(ROW_FLUID);

if(showTitle){
((LabelBoxField)labelWidget).getBoxLabel().setVisible(true);
}else{
if(labelWidget!=null){
((LabelBoxField)labelWidget).getBoxLabel().setVisible(false);
}
}
 if(labelWidget!=null){
labelWidget.addStyleName(getStyleName(labelOrientation));
} 
box.addStyleName(getStyleName(labelOrientation));
 if(showTitle){
add(labelWidget);
}
 add(box);
}


/**code for textbox which extends Basebox*/
public class TextItemBox extends BaseBox {

public TextItemBox(String name) {
super(name);
}

@Override
protected Widget createBox(String name) {
TextBox box = new TextBox();
box.setName(name);

return box;
}
}

/*code which create textbox and added to main-panel*/

TextBox txt=new TextBox("txtItem");
txt.setTitle("Enter the Name to Display");
txt.showTitle(false);
hp.add(txt);


First we create the widget by calling new TextBox() and we set the 
properties like(setTitle,showAlignment,etc).After setting this property how 
do we render the component again.Like for example in smartgwt after 
creating the widget we set the properties,widgets render by itself without 
calling any specific methods like redraw().How can this be achieved in 
GWT?Please give suggestion?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to