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]

Reply via email to