Thursday, March 11, 2010

JSTL expression language, what in the world?

This past week was full of confusions about the how to access Java methods in JSP; however it seems like this week it's still the same. I changed the returning string (in Java) that indicates the label of the complex obs display, but I did it in the way i can't even explain i wrote -fieldHolder.label- even thoough I thought it would be fieldHolder.getLabel(). We thought there is something else going behind the scene, so that Tyler asked this issue at the mailing list.

Here is the answer from Darius
"The idea behind MVC is that the JSP page is purely for view, and therefore you never really call any methods there. So we use JSTL-EL, which lets you access objects and their properties in the model, e.g. ${patient.gender}, but you cannot do ${patient.setGender(...)}.

Anyway I'm not exactly sure what the code you're working with looks like, but your options are probably:
1. write a custom tag, like
2. generate the preview in the controller and pass it to the view precomputed.
"

He cites these two options, so we are trying to figure out which one we can be able to build.

No comments:

Post a Comment