• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to access ModelAndView from jsp

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have pasted snippet of the code below:

Code:


now i have a ModelAndView object being returned from the controller which lists the paymentTransIds that i want to display as bold.
Now my problem is how do i iterate through this List being returned by controller and based on that decide to make the column bold or not.

I have a user defined tag lib as


Thanks
I would appreciate any help
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont see any relation between your custom action in jsp and in tld(present).
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch Manu ravi :)
 
Manu ravi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well what present does is that it checks if the bean exists in scope.
for eg:
<c:present name="mybean" property="beanproperty">
if condition is true then do something.
</c:present>

I think my question should have been how do i set a bean to the current _paymentTransId that i have initialized in <tr> so as to access my modelandview object in controller and then iterate through the list returned by the modelandview object
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ModelAndView is not a JSP class. If it's from a framework, perhaps you should tell us which?
 
Manu ravi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using spring framework. my flow is: jsp -> bean -> controller -> service method -> DAO
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can access model objects in the JSP as I described in this post:

https://coderanch.com/t/587317/Spring/Forms-Spring-MVC#2674378

As for iterating you can do something like I described in this post

https://coderanch.com/t/589779/Spring/Edit-object-collection-JSP-view#2686596
 
Manu ravi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to pass the modelandview object to a pojo which is then accessed by the jsp as a bean. I am pretty new to this.
I thought my controller returns a modelandview object to jsp. but its apparently not so. the table already uses an iterator. so can I use an iterator within this to validate if the parameter that I have declared in the code above exists in the list returned?


 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post your controller and relevant handler mappings.
 
Manu ravi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am unable to get to the handler mapping for the pojo to controller or jsp to pojo. All I have is a mapping for jsp to controller.

Actually I kind of figured it out. I was trying to get the data in a round about way. I was querying with the wrong parameter. I think its working for now.
Thanks for the help
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok glad you got it figured out. In one of those links I posted I showed a sample @RequestMapping on a controller. Anything you put on the model should be accessible in the view using the syntax I also demonstrated in the same post.
 
Manu ravi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the thing i need to do is that I need to pass _payment that was initialized in tr to a method in controller. Am I correct in assuming _payment in the following code:


can be passed on to the request???
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry but I really don't understand what you are trying to do at all. What taglib is the c prefix bound to? I asked you in my last response to post your Spring Controller code, that would give me a better idea of what Spring is expecting. So far none of what you have posted is Spring related. I don't see any Spring tags in your JSP and I don't see any Controller code. Spring is very flexible and will allow a lot of things but from what I can see you are trying to do things way outside the accepted way.

I don't see any objects being bound to a bean in your jsp I don't see any forms being submitted, I don't see any ajax calls, I don't see you calling the server anywhere. If I did see these things I would not be able to tell you if is correct because you have not shown us your @RequestMapping in your controller. You need to TellTheDetails.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic