CRUD operations on listbox

asked 2017-06-13 19:19:30 +0800

ryanGeldmaker gravatar image ryanGeldmaker

updated 2017-06-13 21:11:55 +0800

I have two listboxes: Categories and Items. When you select a Category it populates Items. At the moment saving is working but any update does not.

So if we initially check off 2 of 3 listitems, they save ok. When we go back and uncheck 1 of the 2 checked items that change does not save, either in memory or to the DB.

Pretty new to ZK still so hoping someone may have some experience with. Code:

//TODO: Check the current input in the Items tab.
    if (((CompPanel) pan).rowItemBox.getItems() == null) {
        ((CompPanel) pan).rowCatgBox.addEventListener(Events.ON_SELECT, new EventListener() {
            public void onEvent(Event event) throws Exception {
                // add selected items to list in memory and inactivate unselected items to list in memory.
                // Search the current comps list: compItemList
                ArrayList<CompItemObj> saveItems = new ArrayList<CompItemObj>(0);
                for (Component component : ((CompPanel) pan).rowItemBox.getChildren()) {
                    if (component instanceof Listhead)
                    if (((Listitem) component).isSelected()) {
                        if (component.getChildren().size() < 3)
                            saveItems.add(new CompItemObj(0, ((Listitem) component).getLabel(), Integer.parseInt(((CompPanel) pan).rowIDText.getValue()), (Integer) ((Listcell) component.getLastChild()).getValue(), false));
                // If save items not in comp items, add to comp items list
                for (CompItemObj saveItem : saveItems) {
                    if (!compItemList.contains(saveItem))
                itemList = setCatgItems(((CompPanel) pan).rowCatgBox.getSelectedItem().getLabel(), categoryList);
                ((CompPanel) pan).rowItemBox.getItems().clear();
                for (Object item : itemList) {
                    OneMetrixBaseObj view = (OneMetrixBaseObj) item;
                    Listcell lc = new Listcell();
                    Listitem ci = new Listitem();
                    ((CompPanel) pan).rowItemBox.appendChild(ci);

                    for (Object compItemObj : compItemList) {
                        if (((CompItemObj) compItemObj).getMerchID() == view.getID()) {
                            if (((CompItemObj) compItemObj).isActive())
                            Listcell lc2 = new Listcell();
                            lc2.setValue(((CompItemObj) compItemObj).getMerchID());

                    if (lc.getValue() == null || lc.getValue() == "")
delete flag offensive retag edit


can you please provide a runnable example on zkfiddle.org? I can't see how your current code relates to what you are describing.

cor3000 ( 2017-06-14 02:28:47 +0800 )edit

cor3000 let me try to figure out a way to put it on zkfiddle. It's part of a large project with a large zul otherwise I would have done that from the start. I am currently looking here: https://www.zkoss.org/zkdemo/listbox/list_group

ryanGeldmaker ( 2017-06-14 14:11:57 +0800 )edit

The add/remove functionality is what I am trying to achieve. It saves the initial input/list item selection, however I am stuck on updating to reflect unchecking a list item.

ryanGeldmaker ( 2017-06-14 14:13:20 +0800 )edit

Since I still I don't understand the problem you are trying to solve, a runnable ZK fiddle example is the way to go. Besides ZK doesn't have any built in DB functionalities so that can only be handled by your own code. What is "add/remove functionality" in your case?

cor3000 ( 2017-06-15 04:06:02 +0800 )edit
Be the first one to answer this question!
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

1 follower



Asked: 2017-06-13 19:19:30 +0800

Seen: 14 times

Last updated: Jun 13 '17

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