0

Chosenbox selectedObjects returns empty Set

asked 2013-08-27 13:58:51 +0800

phdsong gravatar image phdsong
13 3

updated 2013-08-27 14:47:05 +0800

I want to get the object selected from the Chosenbox. It always returns empty set although I selected multiple items. I used both selectedObjects and onSelect. But, both returns empty selectedObjects.

                    <chosenbox id="replaceProduct" hflex="1"
                    model="@load(vm.replaceProductListModel)"
                    onSelect="@command('selectReplacement', box=self)"
                    onSearch="@command('selectReplacementSearch', box=self, event=event)"
                    selectedObjects="@save(vm.replaceProductSet, before='ok')"
                    emptyMessage="type or select products"
                    noResultsText="No Such item - {0} - or it is already selected">
                        <template name="model">${each.productName} (${each.productNumber})</template>
                        <!-- <attribute name="onSearch">
                                    Object obj = event.getValue();
                                    ((ListModelList)model).add(obj);
                                    self.addItemToSelection(obj);
                        </attribute> -->
                    </chosenbox>




public ListModelList<Product> getReplaceProductListModel() {
    List<Product> products = getReplaceProducts();
    ListModelList<Product> listModel = null;
    if (products != null) {
        products.remove(element);
        listModel = new ListModelList<Product>(products);
        /* set selection */
        if (replacedProducts != null && !replacedProducts.isEmpty()) {
            for (Product product : replacedProducts) {
                listModel.addToSelection(product);
            }
        }
    } else {
        listModel = new ListModelList<Product>();
    }
    return listModel;
}


// Replacement Product
public void setReplaceProductSet(Set<Product> products) {
    if (products == null) {
        LOGGER.debug("paramater is null.");
        return;
    }
    replacementProduct = products;
}

@Command
public void selectReplacement(@BindingParam("box") Chosenbox box) {
    if (box == null) {
        return;
    }
    Set<Product> selectedSet = box.getSelectedObjects();
    replacementProduct = selectedSet;
}
delete flag offensive retag edit

1 Answer

Sort by » oldest newest most voted
0

answered 2013-08-27 15:33:22 +0800

phdsong gravatar image phdsong
13 3

I just confirmed it works if I remove template from my zul code.

                    <chosenbox id="replaceProduct" hflex="1"
                    model="@load(vm.replaceProductListModel)"
                    onSelect="@command('selectReplacement', box=self)"
                    onSearch="@command('selectReplacementSearch', box=self, event=event)"
                    selectedObjects="@save(vm.replaceProductSet, before='ok')"
                    emptyMessage="type or select products"
                    noResultsText="No Such item - {0} - or it is already selected">
                        <!-- <template name="model">${each.productName} (${each.productNumber})</template> -->
                        <!-- <attribute name="onSearch">
                                    Object obj = event.getValue();
                                    ((ListModelList)model).add(obj);
                                    self.addItemToSelection(obj);
                        </attribute> -->
                    </chosenbox>
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-08-27 13:58:51 +0800

Seen: 50 times

Last updated: Aug 27 '13

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