PDA

View Full Version : Models and casting command objects.


cerebis
Aug 29th, 2005, 06:23 AM
I am only a recent adopter of Java, coming from mainly the land of C/C++ and I still find some features of Java that throw me for a loop on occasion, but I do enjoy the language. Forgive me if this question is all too obvious for the more seasoned Java-ite.

Is it correct to think that the casting of an object when passed to ModelAndView is important? An object comes into a typical command class controller method, such as onSubmit(), as a plain old Object, but of course to use it properly I must recast it to the relevant class. However just today, although I did recast and manipulate it as a specific class, I lazily passed it to ModelAndView() using the original Object reference and found, I think, that the view JSP could not reference the more specific fields (though there was no error using c:out).

Does ModelAndView rely on the incoming cast to control what access is possible?