• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Servlets-4a - using supplied files without modification?  RSS feed

 
Greenhorn
Posts: 18
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just worked out how to solve a problem I was having using EL to print attributes of a VideoData object in the JSP with ${videoData.title}, but it involved modifying the supplied VideoData.java - is this allowed, or do I need to find some other way round the problem?  The instructions for this assignment say I "can use these files without modification", but do I have to?

A little context: I was getting a blank page and "javax.el.PropertyNotFoundException: Property 'title' not readable on type com.javaranch.drive.videos.VideoData" in localhost.[today's date].log.   The best I could do was print out the output of the object's toString() method, but any attempt to access its properties failed.  I added the example Employee class and tried accessing its properties, and that worked fine, so I could then see that the public access modifier was the difference, and once I made VideoData public, it also worked as expected.

Also, I haven't got as far as working with the booleans dvd and vhs, but I noticed that their accessor methods are called inDVD() and inVHS(), shouldn't they be isDVD() and isVHS() in order to work with ${videoData.dvd} and ${videoData.vhs}?  So I need to know if I'm able to change these myself or if I have to find another way around it.
 
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, sorry about that. The original assignments had inVHS() and inDVD(). I vaguely remember that wasn't simply a typo, but I don't really remember the details. In any case, EL works with classes that strictly follow the JavaBean specification -- and that means naming accessors with "get", except for booleans where "is" is preferred. I remember updating the sample files, but it looks like either I'm wrong or that update got reverted at some point. Here's the VideoData.java you should be using:



Feel free to make other changes if the sample files aren't working right for you. Just give me a heads up, so I can correct them online if need be.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!