Getting value from session using zk
i开发者_Python百科 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?
You have to call getNativeSession on the zk session then cast that to be a javax.servlet.http.Session which the one that struts is using.
Trying to mix zk with struts is missing the point. With zk do whatever you need to do and update the zk components and the browser will automatically be updated. Putting data into old style forms to send to the server then update the page is old style programming and less efficient than zk event driven programming where you just update the zk desktop (not bothering to think about pages) and the screen is updated. Your uses can work all day with rich behavior without ever posting a form to interact with struts.
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.
精彩评论