This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I have a requirement to do a bunch of enrollment forms in the context of jsp. The same questions appear on many forms, but sometimes with different labels, or different options. So the same question could be marked up with one xsl in form A but another xsl in form B. So I plan to implement each question as an xml file:
The xsl will turn the question into an input, or a checkbox or a textarea and so on.
Response data will be captured in xml columns, so I have the option of exposing existing data through the view as xml, or Strings or lists or whatever.
What I don't know how to do is combine existing response data into the markup in some cases. For input fields that's easy, I can have the transform spit out the markup necessary to retrieve the field value from the view. What I don't understand is how to populate things like checkboxes. For example how can my transform know whether to insert the checked="checked" attribute if, for a <question> whose options are RED BLUE GREEN and whose presentation should be checkbox format, the existing data says the user selected GREEN?
Usually you do that by passing parameters to the transform. I'm not sure if you can pass parameters to the transform via JSTL -- after a quick look around the web it looks like you can't, but you should do a more thorough look than what I did.
I suppose you could make it work by having a servlet which generated a suitable XSL transformation based on input parameters, instead of a fixed transformation like you have there, but if I found myself going down that road I would think hard about whether there was a different approach.
Joined: Jan 20, 2008
Looking over this again I think most questions could be handled as well with tag files. A given question mat have different text on different forms but I think that can be handled adequately with tags. A completely different skin on the same question is more of an edge case. The boilerplate almost certainly needs transforms, but does not need params.