0

EventQueue working, but data not refreshing

asked 2013-08-22 14:58:49 +0800

lnac98 gravatar image lnac98
3 1

Ok, so I have spent way too much time on this already, but it is really bugging me! So, I have a page with a bunch of tabs on it. To keep things manageable, I want to turn each of those tabs into their own .zul page with their own ViewModel. I have implemented an EventQueue in order to pass the main object (the Tournament object) from the main page to all of the sup-pages.

The problem is, whenever the event is fired and it updates the Tournament object, the page will not refresh its data even though it has changed in the ViewModel. I have tried adding the @NotifyChange annotation with no success. While debugging, I have eliminated the extra .zul. See code below.

tournamentsTab.zul:

<tabpanel apply="org.zkoss.bind.BindComposer"
                          viewModel="@id('bcvm') @init('com.cannon.tnt.trm.mvvm.BeltClassViewModel')">
                    <vlayout vflex="1">
                        <grid model="@load(bcvm.tournament.beltClasses)" emptyMessage="No belt ranks created yet."
                              vflex="1">
                            <columns>
                                <column label="Name" align="center" width="200px"/>
                                <column label="Description" align="center"/>
                                <column label="Delete" align="center" width="120px"/>
                            </columns>
                            <template name="model">
                                <row>
                                    <textbox value="@bind(each.name)" width="95%"
                                             onChanging="@command('setStateEditing')"/>
                                    <textbox value="@bind(each.description)" width="95%"
                                             onChanging="@command('setStateEditing')"/>
                                    <button label="Delete" onClick=""/>
                                </row>
                            </template>
                        </grid>
                    </vlayout>
                    <!--<include src="beltClassPanel.zul"/>-->
                </tabpanel>

BeltClassViewModel.java:

public class BeltClassViewModel {

private EventQueue eq;
private Tournament tournament;

@Init
public void init() {
    eq = EventQueues.lookup("tournamentQueue");
    eq.subscribe(new EventListener() {
        public void onEvent(Event event) throws Exception {
            setTournament((Tournament) event.getData());
        }
    });
}

public Tournament getTournament() {
    return tournament;
}

@NotifyChange("{tournament}")
public void setTournament(Tournament selectedTournament) {
    this.tournament = selectedTournament;
}

}

As I mentioned, the EventQueue part is working perfectly. The event is being fired and then received by the listener who makes the call to set the tournament object on the view model. The problem is, the referenced tournament object is not being updated in the UI. I have put a break point in the getTournament() call and verified that the ONLY time that gets called is when the page first loads.

PLEASE HELP!!! I know that usually these things are just something stupid I'm overlooking. Please prove my idiocy! :)

delete flag offensive retag edit

Comments

Yeah...another follower. That means someone else is interested in the answer to this question also. C'mon, guys...help a brother out! ;)

lnac98 ( 2013-08-23 01:24:59 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-08-23 15:22:32 +0800

rickcr gravatar image rickcr
704 7

Your notify change is wrong. You have:

"{tournament}"

You want

{"tournament"}

brackets are used so you can add multiples..

{"tournament","somethingElse"}

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
2 followers

RSS

Stats

Asked: 2013-08-22 14:58:49 +0800

Seen: 14 times

Last updated: Aug 23 '13

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