0

Is it possible to bind a form element to a List<Long>?

ie. <form:input path="formValues[0]" /> binding to an element in List<Long> formValues; in the form backing object?

When I try this, it fails because Long does not have a default constructor new Long().

I've worked around it by creating a dummy holder class

class DummyLong {
    private Long value;
    ...
}

making the list in the formbacking object a List<DummyLong> and changing the form tag to <form:input path="formValues[0].value" /> but this seems unnecessarily hideous and I'm sure there must be a better way. Haven't been able to find it though.

4
  • Did you try List<Long> formValues with <form:input path="formValues" />? Commented Aug 1, 2011 at 10:11
  • I didn't but I have now and it worked perfectly! Thanks! Commented Aug 1, 2011 at 12:34
  • If you want to put that as an answer, I'll accept it. Commented Aug 1, 2011 at 12:54
  • OK, I posted. Sorry that mu answer too short. Commented Aug 1, 2011 at 17:42

1 Answer 1

2

Use List<Long> formValues with <form:input path="formValues" />

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.