My question is, Is it necessary to have a 'commandName' binding for forms and 'path' bindings for inputs?
I have a work flow which needs users to select data from a series of ajaxy select boxes. So the form doesn't exactly map to any model directly. It seems rather pointless to add another model just to accommodate this form, while everything on this form will be driven by ajax. Now I know I can always write a classic form and select tags, but I would like to take advantage of spring tags here for example:
<form:options items="${list}" itemLabel="name" itemValue="id"/>
which allows me to easily populate by form items. And plus I would like to maintain uniformity in the project and use spring tags through.
I would like to know thoughts and opinions on this topic.
Thanks!
PS: I am coming from ruby on rails background and am used to lot of syntactic sugar :P forgive me if the question sounds silly or answer obvious.
I don't know if it's useful, but here it goes:
If you don't set a 'commandName' in the form, the default value for this property will be set as 'command'. So, if you don't set it, the bound data will have the name 'command'.
If you want, you can set it with the name of your bound data.
==========================================================================
A solution without using data binding would be:
I would add a HttpServletRequest request parameter to the controller method and get the parameter like servlets do.
PS.: the 'path1' and 'path2' are the path names you set in the inputs. I know it seems do not use the Spring properly, but its a hack that Spring let us to use.
The form would be this way:
Hope its useful.
If we are not adding the commandName to spring form tags an exception willl be raised as
IllegalStateException: Neither BindingResult nor plain target object "command" available as request parameter...