Re: NPE in AbstractSingleSelectChoice

2014-05-27 Thread Martin Grigorov
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.meil...@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-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 




NPE in AbstractSingleSelectChoice

2014-05-25 Thread Lucio Crusca
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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: NPE in AbstractSingleSelectChoice

2014-05-25 Thread Marco Springer
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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: NPE in AbstractSingleSelectChoice

2014-05-25 Thread Francois Meillet
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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org