1

I have an application in ZK providers in my database, and i have my DAO to return all the names of my database.

And i have this view in ZK:

<zk>
    <window id="Mnos" border="normal" mode="modal" width="320px"
        apply="org.zkoss.bind.BindComposer"
        viewModel="@id('vm') @init('operator')">
        <listbox model="@load(vm.provider)" onClick="@command('provider', provider = each)"/>

    </window>
</zk>

I need that when a user do click in some provider, save a session variable to use in my application, because i have a crud of services and when i create a service i need create the service related with the provider that the user choose in the menu, and i need create workers and i need create a worker related with the provider that the user choose in the menu,

and i have this java class:

public class operator {

    Collection<String> provider = MnoDAO.getAllProvidersByName();

    public Collection<String> getMno() {
            return mno;
        }
    @Command
    public void provider(@BindingParam("provider") String provider){
        Messagebox.show("Hola ... "+mnoList);
    }

}

My main problem is that each is always null, and second i do not know how can i save a sesion variable to use in all application, and this variable can be change when i select other provider.

Somebody can help me?

user2768380
  • 151
  • 1
  • 5
  • 21

1 Answers1

1

ZK provides a Session object, accessible through the Sessions static getters. This can be used from anywhere in the ZK life cycle (any ZK managed thread).

String name = "myCoolVariable";
MyObject originalValue = getMyCoolVariable();
Session session = Sessions.getCurrent();
session.setAttribute(name, originalValue);

...

if (session.hasAttribute(name)) {
    MyObject retrievedValue = (MyObject) session.getAttribute(name);
}
Sean Connolly
  • 5,692
  • 7
  • 37
  • 74