Thursday, August 7, 2014

Re: How to render a component after setting its property without calling any implicit method in gwt?

Jens,Thanks for your valuable suggestions.I am applying the same approach which you have suggested.Need one more clarification,which method will first invoke Widget.onLoad() and scheduleFinally.execute(),Why need to use this two different method.Can't implement this in scheduleFinally.execute() method.

On Thursday, July 10, 2014 5:24:44 PM UTC+5:30, Mohammed Sameen wrote:
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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment