cctech writes: > I have been constructing screens using Velocity for both displaying > Table data and for editing it. Trouble is, I seem to create Action > Classes for both display and for edit that are both exactly the same. > > E.g. ShowDetails.java for ShowDetails.vm > And EditDetails.java for EditDetails.vm (then goes to > UpdateDetails.java) > > In this case the code for the two java classes (Show, Edit) is exactly > the same except with different class names.
The way I usually approach this is to use the same Screen and template for both showing and editing. The difference is setting a read only flag when users shouldn't be able to edit the data. So one way is to test once in the velocity template: #if ($readonly) ## Contents of ShowDetails.vm #else ## Contents of EditDetails.vm #end But the way I do it is to set a readonly flag for each individual field (so that if a user doesn't have permission to update a given field, they can't), and test that field in the #formXXX generation macro. This is in a sort of homebrew Intake implementation which stores for definitions in the database, btw. The other advantage of checking at each item (in macros) is that when you change the template, you only have to change it once, rather than remembering to change two files or on both sides of an #else. -- Matt Hughes + [EMAIL PROTECTED] + http://susurrous.net/ + "Were there monkeys? Some terrifying space monkeys maybe got loose?" --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
