0

Property 'selectedItems' not writable on type org.zkoss.zul.Tree

asked 2013-11-24 12:10:05 +0800

davout gravatar image davout
1435 3 18

I'm getting an error:

Property 'selectedItems' not writable on type org.zkoss.zul.Tree

... on the following zul...

<tree
                                                model="@load(vm.categories)" checkmark="true"
                                                multiple="true" width="100%" vflex="true" selectedItems="@bind(vm.selectedCategories)">
                                                <treecols>
                                                    <treecol
                                                        label="" />
                                                </treecols>
                                                <template name="model"
                                                    var="c">
                                                    <treeitem
                                                        checkable="@load(c.data.selectable)"
                                                        selected="@load(c.data.selected)" >
                                                        <treerow>
                                                            <treecell
                                                                label="@load(c.data.title)" />
                                                        </treerow>
                                                    </treeitem>
                                                </template>
                                            </tree>

... with the following mvvm class...

public abstract class AbstractAllResourcePricesListVM extends AbstractDataViewVM implements PageListModelErrorHandler {

    @WireVariable
    protected ResourcePriceManager resourcePriceManager;
    @WireVariable
    protected ResourceCategoryManager resourceCategoryManager;

    private AllResourcePricesPageListModel fPrices;
    private ResultSetOrder fResultSetOrder;
    private SearchCriteria fSearchCriteria;

    private DefaultTreeModel<DefaultTreeNode<SelectableTitledDO>> fCategories;
    private Set<SelectableTitledDO> fSelectedCategories;
    **

Any suggestions?

delete flag offensive retag edit

Comments

I've tried this another way, by putting bindings on both the tree model and the tree item 'selected' property and in both cases the binding is NOT updating the underlying model.

davout ( 2013-11-24 13:14:32 +0800 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2013-11-25 07:34:09 +0800

davout gravatar image davout
1435 3 18

Looking at the Tree Java API it seems to be missing a 'setSelectedItems' method, even though its has 'getSelectedItems' .

I solved the problem by passing 'getSelectedItems as a @command parameter to the button onClick method that confirms the selections

link publish delete flag offensive edit

Comments

I solved the problem by passing 'getSelectedItems as a @command parameter to the button onClick method that confirms the selections

Indeed, whats wrong with mine answer : You have to implement correct getters and setters in your MVVM? Vote for correct answer and not your own solution.

chillworld ( 2013-11-25 12:29:14 +0800 )edit
0

answered 2013-11-24 19:17:47 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

updated 2013-11-25 07:08:48 +0800

You have to implement correct getters and setters in your MVVM.

fSelectedCategories in MVVM and selectedCategories in zul.

And :

private DefaultTreeModel<defaulttreenode<selectabletitleddo>> fCategories; <==> model="@load(vm.categories)"

This could be wrong(I'm not 100% sure of that) : abstract class as viewmodel?

Greetz chill.

link publish delete flag offensive edit

Comments

Nah... my personal coding style has all class properties prefixed with a 'f', so that fCategories has a matching 'getCategories()' and 'setCategories()' methods

davout ( 2013-11-25 16:02:14 +0800 )edit

Thats not wrong by taking the f off the getter and setter, but you do an @bind, so you need a getter AND a setter otherwise it will be @load only. (answer you talk no setter and comment you have one?)

chillworld ( 2013-11-26 12:25:47 +0800 )edit
0

answered 2013-11-25 01:30:49 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

You might return a null tree model in VM, and causes zkbind can't set the selection to model(null), instead it set selection directly by 'setSelectedItems', however there is not such API in Tree, so you get [Property 'selectedItems' not writable on type org.zkoss.zul.Tree]

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2013-11-24 12:10:05 +0800

Seen: 53 times

Last updated: Nov 25 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More