0

SpringMVC: How to access Model attributes from ZUL view?

asked 2010-07-09 04:16:27 +0800

thrane gravatar image thrane
43 3

How can attributes on a SpringMVC Model object (e.g. ModelAndView) be resolved/accessed into variables from ZUL view?

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2010-07-09 06:00:53 +0800

samchuang gravatar image samchuang
4084 4

Hi

is this you are looking for: Accessing Spring Bean in the ZUML page

link publish delete flag offensive edit

answered 2010-07-09 06:24:34 +0800

thrane gravatar image thrane
43 3

No, it showns how to access Spring bean from the web application context.

I want to access the attributes from my Spring MVC model object, which is populated with data (as attributes) by my Spring MVC controllers.

If I use web application context, instead of the Spring MVC model then it degrades the purpose of the model which is reduced to do forwarding to views.

link publish delete flag offensive edit

answered 2010-07-09 08:21:15 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

I think the Spring ModelAndView is attached to the request as a request attribute (sorry, couldn't find the attr name). I certainly have not tried it, but all of the request attributes are accessible from ZUL, though that would be a long lookup name.

You could also do something along the lines of the org.zkoss.zkplus.spring.DelegatingVariableResolver. You could:

public Object resolveVariable(String name)
{
    Object value = null ;

    ...  do other stuff to find variable first...


    Map map = Executions.getCurrent().getParameterMap() ;
    //  get Spring MAV using correct map key
    value = mav.get( name ) ;

    return value ;
}

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2010-07-09 04:16:27 +0800

Seen: 381 times

Last updated: Jul 09 '10

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