• 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

retrieve beans value using EL expressions

 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im able to retrieve a beans value if its is primitive variabel, String or []String by using EL expression. But what i REALLY want to retrieve is an vector or hashtable, and print out each value of the collection-class. But I cant figure out how to define what kind of value the bean holds (is it called typecast?).

So it would look like this. Bean -> Vector -> Object.
First define Vector from Bean.
Second define Object from Vector.
Third print out optional values from each object.

Is this possible?
 
Sheriff
Posts: 67746
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
Sure it is. You would iterate over the collection using the <c:forEach> tag, and use EL to access each iteration's properties.

Is there a specific example you are having difficulty with?
 
Sebastian Green
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, this for ....



Now how do I retrieve myEvangelion from container witch is an Vector?
 
Bear Bibeault
Sheriff
Posts: 67746
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
I'm still not sure what your question is. You have a bean named Pilot -- by the way, you should be using standard Java naming conventions, so the id of the bean should be pilot -- then you create and populate an Evangelion instance and set it as the 'container' property of the bean.

Where's the Vector you speak of? Is the container property an indexed bean property? (If so, should it not be an array?)
 
Sebastian Green
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My bad, its supose to be a vector in the bean value not an object, so this is what it would look like

 
Bear Bibeault
Sheriff
Posts: 67746
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
OK, so to iterate over the Vector (why not an ArrayList?) you would use (again recommending pilot over Pilot):

 
Sebastian Green
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks I will try that one out. To be honest, I really dont now the big diffrent between Arraylist & Vector. All I need is an collection class that can handel objects. And i will change it to pilot . Thanks for the help, you have been most helpful!
 
Sebastian Green
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the deal. Im having still having problems to retrieve the value using EL c:forEach. Im able to get the value with this syntax. ${pilots.container[0].name} but when i try to fetch like this


the output is nothing, in the pagesource it says <c:forEach var="entry" items="[uppg4.Evangelion@1d742a1, uppg4.Evangelion@1579371]" >

Here is the jsp-file

And here is the java


As I mention before Im greatfull for help.
 
Bear Bibeault
Sheriff
Posts: 67746
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

in the pagesource it says <c:forEach var="entry" items="[uppg4.Evangelion@1d742a1, uppg4.Evangelion@1579371]" >



If the <c: tags are being sent to the browser, then you have not properly set up the JSTL taglibs.

Do you have a taglib definition for the 'c' tags in your page?
 
Sebastian Green
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doh! Wonder why my c-scope got printed out as html. I should thought of that... Anyway, I added this line to the jsp-page: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

and got this error: JSP Parsing Error:Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV

I also tried to add the jstl core localy throug defining taglib-uri in the web.xml. But still same error, any ideas?
 
Bear Bibeault
Sheriff
Posts: 67746
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
Do you have the JSTL jars in the class path?
 
Sebastian Green
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yepp! And that way its finally works, at last this thread is over thx!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic