Getting value from session using zk

zk
usman picture usman · Aug 6, 2010 · Viewed 7.7k times · Source

i am configured the zk with struts 1 . i created a list and set in the session.

List<String> nameList = new ArrayList<String>();
nameList.add( "xxx" );
nameList.add( "yyy" );
nameList.add( "nnn" );
nameList.add( "ddd" );

request.getSession().setAttribute("NAMES_LIST", nameList);

now from the zul file i am trying to get the session value. How do I do that?

Answer

Mo. picture Mo. · Aug 7, 2010

ZK session is a wrapper object on top of HttpSession, so the access is the same. With EL, just uses sessionScope, e.g., ${sessScope['xxx']}.

In Java, just use getAttribute. To get the session object, you can invoke Sessions.getCurrent().

Hope it helps.