Re: JSTL - Following MVC
david.karr wrote:
On Sep 12, 6:02 am, Christine Mayer <Doo...@gmx.de> wrote:
Hi, I've got a J2EE application (trying) to follow the MVC paradigm.
So far, there is a data model, which is sent to the view. The view
then calls java functions to html formate Strings from this model,
using inline java code, which I don't like very much. Would you:
a) leave it as it is
for: No work to do
against:Mixes JSTL tags with java inline code - ugly
b) add an additional "view-model" attribute for each attribute to be
displayed on the view, that already contains the necessary html style
informations
for: No more logic (java inline code) in the jsps
against: each attribute exists in 2 varieties in one hugh model
c) Add another view-model, and map from data-model to view model in a
huge loop before displaying the view model on the view?
pro: Data-model and view-model are totally separated, no more logic in
the jsps
against: lots of programming to do, and mapping all attributes from
one model to the other model would cost a lot of performance.
d) Simply add new getter methods for each attribute to the current
data-model.
So e.g. there would be a getName() method to get the data
representation of the name, and getFormatedName() which would first
call getName and then manipulate the name attribute to get a view
representation of it.
pro No more logic in the jsps, beans will not be "flooded" by
"duplicate attributes"
contra: Data model would still contain view-model getter methods.
None of the above.
No scriptlet.
Use CSS for the formatting, not Java.
Use a view-logic layer, as david.karr suggested, for validation and the like.
Switch to JSF. It has a learning curve, but it's solved these questions.
--
Lew