Hi,
I'm working on a problem at the moment where a form has an arbitrary
number of questions, each of which has an arbitrary number of answers.
In some cases, it's ok for the customer to select zero or more of the
options, in other cases they must select exactly one.
I've got a form that looks like this (simplified with values hard
coded and loops removed for clarity):
[...]
<s:form beanclass="${actionBean.class.name}" name="frmExam">
<p>(Q1). In which country were you born?</p>
<p><s:radio name="answer[1]" value="1"/>Australia</p>
<p><s:radio name="answer[1]" value="2"/>Other</p>
<p> </p>
<p>(Q2). Do you speak any of these languages?</p>
<p><s:checkbox name="answer[2]" value="1"/>English</p>
<p><s:checkbox name="answer[2]" value="2"/>French</p>
<p> </p>
[...]
And an action that looks like this:
public class SomeAction {
public String[][] answer = null;
@DefaultHandler
public Resolution submit() {
if (answer == null)
logger.debug("No answers provided by customer");
else
logger.debug(String.format("answer[][] first dimension is %d items
long", answer.length));
}
}
When I answer the questions and submit, my debugging output says
"answer[][] first dimension is 0 items long". So answer gets set to a
non-null, but of zero length. My reading of the section of the
(excellent) stripes book on indexed properties suggests that I might
be able to do this, but doesn't give an example that maps to exactly
what I'm doing.
My experience when dealing with one dimensional arrays (changing
answer[][] to answer1[], answer2[]) is that you get an array of
answers propagated for you. eg. If you speak both English and French,
you get answer2[] = {"1", "2"}; if you live in Australia you get
answer1[] = {"1"}
So, I would have thought that with the example I list the code for, if
you live in Australia and speak English and French you should get
answer[][] = {{}, {"1"}, {"1", "2"}} (my arrays are one indexed, so
the zero index should be null or an empty array). Is this not the
case?
Thanks for any help you can give.
Nathan.
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users