Hello,

I have following problem when creating custom widgets for UiBinder. In
short, it looks like when I extend Composite and implement the
HasWidgets interface and then add some arbitrary setters, the
HasWidgets.add(Widget) method is called before the setters are called.

For example I have class WizardPanel with method
setDirection(Direction). The class extends Composite and implements
HasWidgets so it looks like the following code snippet:

public class WizardPanel extends Composite implements HasWidgets
{
    private DockLayoutPanel panel = new DockLayoutPanel(Unit.PCT);
    private Direction direction = Direction.RIGHT_LEFT;
    int pageCount;

    public void setDirection(Direction direction)
    {
        this.direction = direction;
    }

    @Override
    public void add(Widget w)
    {
        double size = (pageCount == 0) ? 100.0 : 0.0;
        switch (direction)
        {
            case LEFT_RIGHT:
                panel.addEast(w, size);
                break;
            case RIGHT_LEFT:
                panel.addWest(w, size);
                break;
            case TOP_BOTTOM:
                panel.addSouth(w, size);
                break;
            case BOTTOM_TOP:
                panel.addNorth(w, size);
                break;
            default:
                break;
        }
        ++pageCount;
    }
}

So clearly the behaviour of the method add(Widget) depends on the
direction.

In UiBinder I have following declaration:

<my:WizardPanel direction="RIGHT_LEFT">
    <g:HTMLPanel>
        // some code
    </g:HTMLPanel>
    <g:HTMLPanel>
        // some code
    </g:HTMLPanel>
</my:WIzardPanel>

I would expect that the method setDirection(Direction) would be called
before the add(Widget) method but unfortunately it's not the case. And
that applies for all arbitrary setter methods "called" in the
declaration of the <my:WizardPanel> tag.

To me it would make more sense if the setter was called before the
children are added because it sets the state of the WizardPanel. What
am I missing?

I know that I can work around this issue by just adding the child
widgets to some collection and then actually add them to the
DockLayoutPanel in the onAttach or onLoad method but isn't there a
better way to solve this?

Thank you!

eQui

-- 
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.

Reply via email to