aliz-ai / dsweb

Doctusoft web framework
GNU General Public License v3.0
1 stars 0 forks source link

DropdownLink bindings #67

Open epfisztner opened 9 years ago

epfisztner commented 9 years ago

It would be great to have chance to change the text of the dropdown by binding.

gabor-farkas commented 9 years ago

Ok, so let's have a bindLabel() builder method. (anyway you can still bind it by calling Bindings.bind(Bindings.obs(dropdownLink.getModel()).get(DropdownButtonModel_._text), ...)

I extend the ticket to also support:

The javadocs should also show an example to show how can you create link items dynamically bound to some presenter data (as discussed today with @pkismarczi )

epfisztner commented 9 years ago

There isn't any field in DropdownButtonModel so this can't be used: Bindings.bind(Bindings.obs(dropdownLink.getModel()).get(DropdownButtonModel_._text), ...)

There's only a protected Link field in the DropdownLink:

protected Link dropdownButton; protected BaseContainer itemContainer;

public DropdownLink(String label) {
    super(new DropdownButtonModel());
    this.addStyleClass("dropdown");
    dropdownButton = new Link(label + " ", "#");
    dropdownButton.addStyleClass("dropdown-toggle");
    itemContainer = new BaseContainer("ul");

    itemContainer.removeStyleClass("container");
    itemContainer.addStyleClass("dropdown-menu");

    add(dropdownButton);
    add(itemContainer);
}
gabor-farkas commented 9 years ago

hmm, that's right