Hi Guys,
I'm having similar problem (I guess) but not sure what went wrong.
I'm using:
- Appfuse 2.0 RC1 with basic Spring MVC
- iBatis
I tried using form:select where the path for form:select is the command's
setter/getter and with it i'm using
form:option (for displaying "Please select xxx") and form:options where all
the dropdown list will come in. The list is made of appfuse's LabelValue
class.The list came from referenceData.
<form:select path="hostelSessionId">
<form:option some stuff here>
<form:options items="${hostelSessionList}" itemValue="id"
itemLabel="name"/>
</form:select>
What happen whas.. the screen is not rendered at all. I got a blank screen
when using this. But if replace the form:select&form:option with something
else like form:input, i immediately can see the value coming from my
backingObject being displayed.
So, I guess my model does have data when it passed to the screen. But i
wonder why form:select wont work.
Any idea?
Mike Horwitz wrote:
>
> On 8/7/07, syg6 <[EMAIL PROTECTED]> wrote:
>>
>>
>> Thanks for the explanation, that cleared up a lot of questions I had.
>> Have
>> you ever considered writing your own documentation / book on Spring or
>> Spring MVC? You'd be doing us all a favor!
>
>
> Pleasure. Good news on the book front, it's already been done, although
> not
> by me! There is a list here: http://www.appfuse.org/display/APF/Spring
>
> In the end it worked with the code Absolut posted. The only glitch was
> when
>> I have a new PackageInspection it was choking saying my Inspector object
>> was
>> null. This was because I didn't initialize the
>> PackageInspection.Inspector
>> object in my constructor. Once I did that, all was well.
>
>
> O.K.! As long as it works... ;-)
>
> For the moment it seems I do not need to create a Custom Property Editor;
>> all CRUD operations are working a-ok. But something tells me I'll need to
>> use them at some point (not really clear on what they do) so I'll have to
>> look into it ...
>>
>> Many thanks for the timely help!
>> Bob
>>
>>
>> Michael Horwitz wrote:
>> >
>> > The select list tag needs several elements to work:
>> >
>> > 1) A collection of objects to populate the list (items)
>> > 2) A property on each object in the collection used to populate the
>> > corresponding option label (itemLabel)
>> > 3) A property on each object in the collection used to populate the
>> > corresponding option value (itemValue)
>> > 3) The value currently set on your command object so that the
>> appropriate
>> > element in the collection can be marked as 'selected' (path).
>> >
>> > So the path performs two functions: it sets the name of the input, and
>> it
>> > tells the form which option in the select list should be marked as
>> > 'selected'.
>> >
>> > Also worth noting, if you have not done so already, that you will most
>> > likely need to register a custom property editor to handle your
>> inspector
>> > class (assuming the inspector is a class.....).
>> >
>> > Mike.
>> >
>> > On 8/6/07, syg6 <[EMAIL PROTECTED]> wrote:
>> >>
>> >>
>> >> Excellent! That's the piece I was missing! I didn't know what to put
>> for
>> >> the
>> >> path. I still don't think it's very intuitive. I thought path referred
>> to
>> >> a
>> >> getter in your command object. Which I thought was quite limiting as
>> you
>> >> wouldn't be able to use it for other objects in the request. But now I
>> >> see
>> >> it can work with any old object. But I am curious why 'country.id' is
>> >> used
>> >> as the path. Is the path nothing more than the name of the form input
>> id
>> >> you
>> >> send to the server when you submit?
>> >>
>> >> At any rate, I'll try it first thing in the morning at work.
>> >>
>> >> Many thanks!
>> >>
>> >> Bob
>> >>
>> >>
>> >>
>> >> Absolut wrote:
>> >> >
>> >> > It is possible to write a list of objects to the request in order to
>> >> use
>> >> > this values to populate a drop down.
>> >> >
>> >> > Here a short example code:
>> >> >
>> >> > SpringController:
>> >> > ....
>> >> > @Override
>> >> > protected Map referenceData(HttpServletRequest request) throws
>> >> > Exception {
>> >> > Map<String, Object> model = new HashMap<String,
>> >> Object>();
>> >> > model.put("countryList", countryManager.getCountries
>> ());
>> >> > return model;
>> >> > }
>> >> > ....
>> >> >
>> >> > JSP:
>> >> > <form:select path="country.id">
>> >> > <form:options items="${countryList}" itemValue="id"
>> >> itemLabel="name"/>
>> >> > </form:select>
>> >> >
>> >> > Bye,
>> >> >
>> >> > Peter
>> >> >
>> >> >
>> >> > -----Ursprüngliche Nachricht-----
>> >> > Von: syg6 [mailto:[EMAIL PROTECTED]
>> >> > Gesendet: Montag, 6. August 2007 15:07
>> >> > An: [email protected]
>> >> > Betreff: Re: [appfuse-user] AW: AW: Can I use form:select with data
>> >> bound
>> >> > using referenceDate()
>> >> >
>> >> >
>> >> > Yes, I see that the problem is with the 'path' attribute.
>> >> >
>> >> > The problem is that I want to use the form:select tag with an object
>> in
>> >> > the
>> >> > request, not my command object. Overriding the referenceData()
>> method
>> >> > causes
>> >> > Spring to stick whatever data you load there in the request (I think
>> >> ...).
>> >> > It's that data that I want to use to populate my select.
>> >> >
>> >> > It is rightly not a part of the command object, but rather data from
>> >> which
>> >> > I
>> >> > choose an Inspector. And that Inspector is assigned to my command
>> >> object
>> >> > when I submit.
>> >> >
>> >> > I am not opposed to using spring:bind, I just thought I could
>> somehow
>> >> tell
>> >> > the form:select tag, 'oy! don't use the command object, use the
>> >> request!'
>> >> >
>> >> > But I guess not ...
>> >> >
>> >> > Bob
>> >> >
>> >> >
>> >> > Absolut wrote:
>> >> >>
>> >> >> It is possible to use a collection of objects generated in the
>> >> >> referenceData method, I don't think that this the problem in your
>> >> >> code.
>> >> >> I think that you have a wrong value in your "path" attribute:
>> >> >>
>> >> >> If your command object has a setter called "setInspector(String
>> >> >> inspector)", your form tag would look like <form:select
>> >> >> path="inspector"
>> >> >> items="${inspectors}" itemLabel="name" itemValue="id"/>
>> >> >>
>> >> >> Please take a close look at the "path" notation:
>> >> >> The value must be the same as the corresponding setter / getter in
>> >> >> your command object (...setInspector(...) / getInspector(...)->
>> >> >> path="inspector"). In your example (1. mail), the value is
>> >> >> "...path="inspectors"....". Maybe the "s" is wrong there...
>> >> >>
>> >> >>
>> >> >> Bye,
>> >> >>
>> >> >> Peter
>> >> >>
>> >> >> PS: The error message corresponds to the "path" attribute, not to
>> one
>> >> >> of the other attributes (items, itemValue od itemLabel):
>> >> >>>>Invalid property 'inspectors' of bean class
>> >> >> [com.mycompany.myapp.model.PackageInspection]: Bean property
>> >> >> >'inspectors'
>> >> >> is not readable or has an invalid getter method
>> >> >>
>> >> >>
>> >> >>
>> >> >> -----Ursprüngliche Nachricht-----
>> >> >> Von: syg6 [mailto:[EMAIL PROTECTED]
>> >> >> Gesendet: Montag, 6. August 2007 14:49
>> >> >> An: [email protected]
>> >> >> Betreff: Re: [appfuse-user] AW: Can I use form:select with data
>> bound
>> >> >> using
>> >> >> referenceDate()
>> >> >>
>> >> >>
>> >> >> Hi Peter, thanks for the response,
>> >> >>
>> >> >> I read the reference guide already and unfortunately it only has
>> one
>> >> >> example, when your command object has a getter for the reference
>> data
>> >> >> you want to use to populate a Select. I don't have this option
>> because
>> >> >> my command object, PackageInspection, has exactly one Inspector,
>> not
>> a
>> >> >> list of Inspectors.
>> >> >>
>> >> >> I would think this is a pretty normal thing to want to do, but it
>> >> >> looks as if the form:select tag only works with objects within the
>> >> >> command
>> >> > object.
>> >> >>
>> >> >> Am I wrong about this?
>> >> >>
>> >> >> Cheers,
>> >> >> Bob
>> >> >>
>> >> >>
>> >> >> Absolut wrote:
>> >> >>>
>> >> >>> Hi Bob!
>> >> >>>
>> >> >>> I think the problem is the part ... path="inspectors"... It seems
>> >> >>> that your command object of the type "PackageInspection" has no
>> >> >>> property "inspectors"
>> >> >>> (or no method "getInspectors()")
>> >> >>>
>> >> >>> There are many ohter possibilities how to generate an "select" tag
>> >> >>> with the new Spring Taglib.
>> >> >>> For more details i would recomend to read
>> >> >>> "
>> http://static.springframework.org/spring/docs/2.0.x/reference/mvc.ht
>> >> >>> m
>> >> >>> l#mvc-
>> >> >>> formtaglib"
>> >> >>>
>> >> >>> Bye,
>> >> >>>
>> >> >>> Peter
>> >> >>>
>> >> >>> -----Ursprüngliche Nachricht-----
>> >> >>> Von: syg6 [mailto:[EMAIL PROTECTED]
>> >> >>> Gesendet: Montag, 6. August 2007 14:34
>> >> >>> An: [email protected]
>> >> >>> Betreff: [appfuse-user] Can I use form:select with data bound
>> using
>> >> >>> referenceDate()
>> >> >>>
>> >> >>>
>> >> >>> All the posts I see, here on the AppFuse mailing list and all over
>> >> >>> the net, use the old spring:bind tag. Can I use the Spring 2.0
>> >> >>> form:select tag?
>> >> >>>
>> >> >>> I have implemented referenceData() in my XxFormController class,
>> and
>> >> >>> add a Map of Inspectors to the Model. But in the jsp, the
>> following
>> >> >>> code:
>> >> >>>
>> >> >>> <form:select path="inspectors"
>> >> items="${inspectors}" itemLabel="name"
>> >> >>> itemValue="id"/>
>> >> >>>
>> >> >>> gives me this:
>> >> >>>
>> >> >>>>Invalid property 'inspectors' of bean class
>> >> >>> [com.mycompany.myapp.model.PackageInspection]: Bean property
>> >> >>> >'inspectors'
>> >> >>> is not readable or has an invalid getter method
>> >> >>>
>> >> >>> Ostensibly this is because Inspectors is not part of the 'command'
>> >> >>> class, PackageInspection, but rather a list of Inspectors added to
>> >> >>> the request via
>> >> >>> referenceData() to populate a Select.
>> >> >>>
>> >> >>> Can I use the select tag or do I have to use the old bind tag?
>> >> >>>
>> >> >>> Thanks,
>> >> >>> Bob
>> >> >>> --
>> >> >>> View this message in context:
>> >> >>>
>> http://www.nabble.com/Can-I-use-form%3Aselect-with-data-bound-using-r
>> >> >>> e
>> >> >>> ferenc
>> >> >>> eDate%28%29-tf4223839s2369.html#a12015409
>> >> >>> Sent from the AppFuse - User mailing list archive at Nabble.com.
>> >> >>>
>> >> >>>
>> ---------------------------------------------------------------------
>> >> >>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >> >>> For additional commands, e-mail: [EMAIL PROTECTED]
>> >> >>>
>> >> >>> No virus found in this incoming message.
>> >> >>> Checked by AVG Free Edition.
>> >> >>> Version: 7.5.476 / Virus Database: 269.11.6/938 - Release Date:
>> >> >>> 05.08.2007
>> >> >>> 16:16
>> >> >>>
>> >> >>>
>> >> >>> No virus found in this outgoing message.
>> >> >>> Checked by AVG Free Edition.
>> >> >>> Version: 7.5.476 / Virus Database: 269.11.6/938 - Release Date:
>> >> >>> 05.08.2007
>> >> >>> 16:16
>> >> >>>
>> >> >>>
>> >> >>>
>> ---------------------------------------------------------------------
>> >> >>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >> >>> For additional commands, e-mail: [EMAIL PROTECTED]
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> http://www.nabble.com/Can-I-use-form%3Aselect-with-data-bound-using-re
>> >> >> ferenc
>> >> >> eDate%28%29-tf4223839s2369.html#a12015604
>> >> >> Sent from the AppFuse - User mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >> >> For additional commands, e-mail: [EMAIL PROTECTED]
>> >> >>
>> >> >> No virus found in this incoming message.
>> >> >> Checked by AVG Free Edition.
>> >> >> Version: 7.5.476 / Virus Database: 269.11.6/938 - Release Date:
>> >> >> 05.08.2007
>> >> >> 16:16
>> >> >>
>> >> >>
>> >> >> No virus found in this outgoing message.
>> >> >> Checked by AVG Free Edition.
>> >> >> Version: 7.5.476 / Virus Database: 269.11.6/938 - Release Date:
>> >> >> 05.08.2007
>> >> >> 16:16
>> >> >>
>> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >> >> For additional commands, e-mail: [EMAIL PROTECTED]
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >> > --
>> >> > View this message in context:
>> >> >
>> >>
>> http://www.nabble.com/Can-I-use-form%3Aselect-with-data-bound-using-referenc
>> >> > eDate%28%29-tf4223839s2369.html#a12015922
>> >> > Sent from the AppFuse - User mailing list archive at Nabble.com.
>> >> >
>> >> >
>> ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >> > For additional commands, e-mail: [EMAIL PROTECTED]
>> >> >
>> >> > No virus found in this incoming message.
>> >> > Checked by AVG Free Edition.
>> >> > Version: 7.5.476 / Virus Database: 269.11.6/938 - Release Date:
>> >> 05.08.2007
>> >> > 16:16
>> >> >
>> >> >
>> >> > No virus found in this outgoing message.
>> >> > Checked by AVG Free Edition.
>> >> > Version: 7.5.476 / Virus Database: 269.11.6/938 - Release Date:
>> >> 05.08.2007
>> >> > 16:16
>> >> >
>> >> >
>> >> >
>> ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >> > For additional commands, e-mail: [EMAIL PROTECTED]
>> >> >
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Can-I-use-form%3Aselect-with-data-bound-using-referenceDate%28%29-tf4223839s2369.html#a12022790
>> >> Sent from the AppFuse - User mailing list archive at Nabble.com.
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >> For additional commands, e-mail: [EMAIL PROTECTED]
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Can-I-use-form%3Aselect-with-data-bound-using-referenceDate%28%29-tf4223839s2369.html#a12029565
>> Sent from the AppFuse - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Can-I-use-form%3Aselect-with-data-bound-using-referenceDate%28%29-tf4223839s2369.html#a12726084
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]