If your properties can be null, then you need to make sure your
PropertyEditor can handle null values properly - a bit of unit
testing should provide the test cover you need. You also need to
provide an option in your dropdown list to match to the null value.
Something like:
<form:select path="contact.country">
<form:option value="" label="label for no value"/>
<form:options items="${countries}" itemLabel="name" itemValue="id" />
</form:select>
Mike
On 7/8/07, *Aled Rhys Jones* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Further to this (still can't save drop down list changes :-( ), I
have
an example where an object x contains an object y that can be
selected
using a drop down list, but y is currently null as I haven't added
it to
x yet (would be done using the drop down list).
Is the trick here to create y in the formBackingObject and set the
id to
-1? Currently I get a null pointer in the property editor,
presumably
as its trying to compare the id or name of a null object.
Aled Rhys Jones wrote:
> Thanks for the replies Mike.
>
> Two issues with the below is that it doesn't seem to like me using
> spring:form. Everything else seems to be form:form which seems
to work.
> I therefore tried the below using form:select, and I get the
following
> exception:
> java.lang.NullPointerException
> at
>
org.springframework.web.servlet.tags.form.SelectedValueComparator.exhaustiveCompare
(SelectedValueComparator.java:154)
>
> at
>
org.springframework.web.servlet.tags.form.SelectedValueComparator.isSelected(SelectedValueComparator.java:90)
>
> at
>
org.springframework.web.servlet.tags.form.OptionWriter.isSelected
(OptionWriter.java:184)
>
> at
>
org.springframework.web.servlet.tags.form.OptionWriter.renderOption(OptionWriter.java:172)
>
> at
>
org.springframework.web.servlet.tags.form.OptionWriter.doRenderFromCollection
(OptionWriter.java:155)
>
>
> Cheers
> Aled
> Michael Horwitz wrote:
>> Hmm. In that case you might want to take a look at Spring's
form tags
>> to make life a little easier:
>>
http://static.springframework.org/spring/docs/2.0.x/reference/spring-form.tld.html
>> <
http://static.springframework.org/spring/docs/2.0.x/reference/spring-form.tld.html>
>>
>>
>> So your JSP would look something like:
>>
>> <spring:form commandName="website" ...>
>>
>> ...
>>
>> <spring:select path="contact.country" items="${countries}"
>> itemLabel="name" itemValue="id"/>
>> ....
>>
>> </spring:form>
>>
>> A lot simpler and Spring will do all the hard work for you. As
long
>> as your form backing object has a non-null contact attribute, it
>> should all work like magic. I think the problem in your code is
the
>> name you attach to the select element - Spring expects specific
names
>> to get its bindings sorted out.
>>
>> Mike.
>>
>> On 7/6/07, *Aled Rhys Jones* < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
>> <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>>
wrote:
>>
>> m4, wanted to finish off some functionality before updating
to m5.
>>
>>
>> Cheers
>>
>> Aled
>>
>>
>>
>>
------------------------------------------------------------------------
>>
>> *From:* Michael Horwitz [mailto: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
>> <mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>]
>> *Sent:* 06 July 2007 08:39
>> *To:* [email protected]
<mailto:[email protected]>
<mailto:[email protected]
<mailto:[email protected]>>
>> *Subject:* Re: [appfuse-user] Drop down list population
>>
>>
>> Which version of AppFuse are you using Aled?
>>
>> On 7/5/07, *Tsung* < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> <mailto: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>>
>> wrote:
>>
>>
>> Aled - Rather than having setCountryManager method, pass the
>> CountryManager
>> referene in CountryEditor's constructor.
>>
>>
>> --
>> View this message in context:
>>
>>
http://www.nabble.com/Add-ManyToOne-relationship-between-user-and-a-new-pojo-tf3993393s2369.html#a11454095
>>
>>
>> <
http://www.nabble.com/Add-ManyToOne-relationship-between-user-and-a-new-pojo-tf3993393s2369.html#a11454095>
>>
>> Sent from the AppFuse - User mailing list archive at
Nabble.com <http://Nabble.com>
>> <http://nabble.com/>.
>>
>>
>>
---------------------------------------------------------------------
>> To unsubscribe, e-mail:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
>> <mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> >
>> For additional commands, e-mail:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
>> <mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
>>
>>
>>
>>
------------------------------------------------------------------------
>>
>> No virus found in this incoming message.
>> Checked by AVG Free Edition. Version: 7.5.476 / Virus Database:
>> 269.10.1/888 - Release Date: 06/07/2007 06:36
>>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition. Version: 7.5.476 / Virus Database:
269.10.2/893 - Release Date: 09/07/2007 17:22