You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Sven Meier <sv...@meiers.net> on 2014/06/02 16:14:42 UTC

Re: NPE in AbstractSingleSelectChoice

Hi Martin,

I'd say AbstractSingleSelectChoice should throw a WicketRuntimeException 
when the id is null.

The reporter of the issue should use #setNullValid(true) instead of his 
nullItem.

Sven

On 05/27/2014 03:14 PM, Martin Grigorov wrote:
> Improved to not fail with NPE with
> https://issues.apache.org/jira/browse/WICKET-5601
>
> I think Wicket should warn you somehow when the returned idValue is null
> though. Because now it sets null as a model object and the client choice is
> being lost.
> @Sven, @Igor: what do you think ?
>
> Martin Grigorov
> Wicket Training and Consulting
>
>
> On Sun, May 25, 2014 at 10:29 PM, Francois Meillet <
> francois.meillet@gmail.com> wrote:
>
>> When the DropDownChoice try to convert the submitted choice id back to the
>> choice object
>> there is an iteration over the choices.
>> You get the NPE in this iteration because nullItem has no id.
>>
>> Have a look to AbstractSingleSelectChoice's setNullValid(true) method to
>> include a null value.
>>
>> http://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/markup/html/form/AbstractSingleSelectChoice.html#setNullValid(boolean)
>>
>>
>>
>> François Meillet
>> Formation Wicket - Développement Wicket
>>
>>
>>
>>
>>
>> Le 25 mai 2014 à 21:18, Marco Springer <ma...@glitchbox.nl> a écrit :
>>
>>> Haven't run the code but my guess is that the idValue returns a null
>> instead
>>> of  "0".
>>> Take a look at
>> AbstractSingleSelectChoice.convertChoiceIdToChoice(String) line
>>> 281. (Wicket 6.15.0)
>>> "if(renderer.getIdValue(choice, index).equals(id)"
>>> This would trigger a NPE if a null is returned, which would be the case
>> with
>>> your "nullItem".
>>>
>>> Cheers,
>>> Marco
>>>
>>> On Sunday 25 May 2014 21:06:41 Lucio Crusca wrote:
>>>> I'm pretty sure it's my fault, but I can't spot it. I'm trying to use a
>>>> DropDownChoice with custom renderer and a PropertyModel, without a Form.
>>>>
>>>> I get a NullPointerException in AbstractSingleSelectChoice, here is the
>>>> quickstart:
>>>>
>>>> http://www.sulweb.org/download/sparsi/quickstart.zip
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>


Re: NPE in AbstractSingleSelectChoice

Posted by Sven Meier <sv...@meiers.net>.
I believe so, but I'll have to check that.

Sven

On 06/02/2014 05:27 PM, Martin Grigorov wrote:
> Thanks, Sven!
>
> I guess this is true for all places where IChoiceRenderer#getIdValue() is
> used ?
>
> Martin Grigorov
> Wicket Training and Consulting
>
>
> On Mon, Jun 2, 2014 at 4:14 PM, Sven Meier <sv...@meiers.net> wrote:
>
>> Hi Martin,
>>
>> I'd say AbstractSingleSelectChoice should throw a WicketRuntimeException
>> when the id is null.
>>
>> The reporter of the issue should use #setNullValid(true) instead of his
>> nullItem.
>>
>> Sven
>>
>>
>> On 05/27/2014 03:14 PM, Martin Grigorov wrote:
>>
>>> Improved to not fail with NPE with
>>> https://issues.apache.org/jira/browse/WICKET-5601
>>>
>>> I think Wicket should warn you somehow when the returned idValue is null
>>> though. Because now it sets null as a model object and the client choice
>>> is
>>> being lost.
>>> @Sven, @Igor: what do you think ?
>>>
>>> Martin Grigorov
>>> Wicket Training and Consulting
>>>
>>>
>>> On Sun, May 25, 2014 at 10:29 PM, Francois Meillet <
>>> francois.meillet@gmail.com> wrote:
>>>
>>>   When the DropDownChoice try to convert the submitted choice id back to
>>>> the
>>>> choice object
>>>> there is an iteration over the choices.
>>>> You get the NPE in this iteration because nullItem has no id.
>>>>
>>>> Have a look to AbstractSingleSelectChoice's setNullValid(true) method to
>>>> include a null value.
>>>>
>>>> http://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/
>>>> wicket/markup/html/form/AbstractSingleSelectChoice.
>>>> html#setNullValid(boolean)
>>>>
>>>>
>>>>
>>>> François Meillet
>>>> Formation Wicket - Développement Wicket
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Le 25 mai 2014 à 21:18, Marco Springer <ma...@glitchbox.nl> a écrit :
>>>>
>>>>   Haven't run the code but my guess is that the idValue returns a null
>>>> instead
>>>>
>>>>> of  "0".
>>>>> Take a look at
>>>>>
>>>> AbstractSingleSelectChoice.convertChoiceIdToChoice(String) line
>>>>
>>>>> 281. (Wicket 6.15.0)
>>>>> "if(renderer.getIdValue(choice, index).equals(id)"
>>>>> This would trigger a NPE if a null is returned, which would be the case
>>>>>
>>>> with
>>>>
>>>>> your "nullItem".
>>>>>
>>>>> Cheers,
>>>>> Marco
>>>>>
>>>>> On Sunday 25 May 2014 21:06:41 Lucio Crusca wrote:
>>>>>
>>>>>> I'm pretty sure it's my fault, but I can't spot it. I'm trying to use a
>>>>>> DropDownChoice with custom renderer and a PropertyModel, without a
>>>>>> Form.
>>>>>>
>>>>>> I get a NullPointerException in AbstractSingleSelectChoice, here is the
>>>>>> quickstart:
>>>>>>
>>>>>> http://www.sulweb.org/download/sparsi/quickstart.zip
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>


Re: NPE in AbstractSingleSelectChoice

Posted by Martin Grigorov <mg...@apache.org>.
Thanks, Sven!

I guess this is true for all places where IChoiceRenderer#getIdValue() is
used ?

Martin Grigorov
Wicket Training and Consulting


On Mon, Jun 2, 2014 at 4:14 PM, Sven Meier <sv...@meiers.net> wrote:

> Hi Martin,
>
> I'd say AbstractSingleSelectChoice should throw a WicketRuntimeException
> when the id is null.
>
> The reporter of the issue should use #setNullValid(true) instead of his
> nullItem.
>
> Sven
>
>
> On 05/27/2014 03:14 PM, Martin Grigorov wrote:
>
>> Improved to not fail with NPE with
>> https://issues.apache.org/jira/browse/WICKET-5601
>>
>> I think Wicket should warn you somehow when the returned idValue is null
>> though. Because now it sets null as a model object and the client choice
>> is
>> being lost.
>> @Sven, @Igor: what do you think ?
>>
>> Martin Grigorov
>> Wicket Training and Consulting
>>
>>
>> On Sun, May 25, 2014 at 10:29 PM, Francois Meillet <
>> francois.meillet@gmail.com> wrote:
>>
>>  When the DropDownChoice try to convert the submitted choice id back to
>>> the
>>> choice object
>>> there is an iteration over the choices.
>>> You get the NPE in this iteration because nullItem has no id.
>>>
>>> Have a look to AbstractSingleSelectChoice's setNullValid(true) method to
>>> include a null value.
>>>
>>> http://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/
>>> wicket/markup/html/form/AbstractSingleSelectChoice.
>>> html#setNullValid(boolean)
>>>
>>>
>>>
>>> François Meillet
>>> Formation Wicket - Développement Wicket
>>>
>>>
>>>
>>>
>>>
>>> Le 25 mai 2014 à 21:18, Marco Springer <ma...@glitchbox.nl> a écrit :
>>>
>>>  Haven't run the code but my guess is that the idValue returns a null
>>>>
>>> instead
>>>
>>>> of  "0".
>>>> Take a look at
>>>>
>>> AbstractSingleSelectChoice.convertChoiceIdToChoice(String) line
>>>
>>>> 281. (Wicket 6.15.0)
>>>> "if(renderer.getIdValue(choice, index).equals(id)"
>>>> This would trigger a NPE if a null is returned, which would be the case
>>>>
>>> with
>>>
>>>> your "nullItem".
>>>>
>>>> Cheers,
>>>> Marco
>>>>
>>>> On Sunday 25 May 2014 21:06:41 Lucio Crusca wrote:
>>>>
>>>>> I'm pretty sure it's my fault, but I can't spot it. I'm trying to use a
>>>>> DropDownChoice with custom renderer and a PropertyModel, without a
>>>>> Form.
>>>>>
>>>>> I get a NullPointerException in AbstractSingleSelectChoice, here is the
>>>>> quickstart:
>>>>>
>>>>> http://www.sulweb.org/download/sparsi/quickstart.zip
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>