Keep it as current. If you want tri-state logic, then you have to
implement that. What are you going to do with int, long, double,
float? make it 0? make it -1?

Defaulting to false is very context dependent, and shouldn't be
implemented as such.

Martijn

On 1/9/07, Johan Compagner <[EMAIL PROTECTED]> wrote:
> my checkbox works fine:
>
> class MyDataObject
> {
>  Boolean myBoolean;
>
>  void setMyBoolean(Boolean b)
>  Boolean getMyBoolean()
> }
>
> so it is not directly the checkbox. But if you map it to a boolean
> (primitive) then you don't have
> the three-state thing yes. (null, false, true)
>
> So i dont know if this is a bug or not that really needs to be fixed.
> Because what is the fix?
>
> I can't do what you do here. Because if it is a Boolean object then
> null/empty string is valid.
>
> Maybe for booleans we can make an exception that null will be false in the
> converter
> What do others think?
>
> johan
>
>
>
> On 1/9/07, Erik van Oosten <[EMAIL PROTECTED]> wrote:
> > Johan,
> >
> > I got it working as below. Shall I create a Jira issue for this? I think
> > it would be more logical if checkbox could deal with cleared input.
> >
> >      Erik.
> >
> >
> >         // The reset button
> >         Button resetButton = new Button("resetbutton") {
> >             /** [EMAIL PROTECTED] */
> >             protected void onSubmit() {
> >                 // Clear the form
> >                 form.visitChildren(FormComponent.class, new
> > Component.IVisitor() {
> >                     public Object component(Component component) {
> >                         FormComponent formComponent =
> ((FormComponent)
> > component);
> >                         if (formComponent instanceof CheckBox) {
> >                             ((CheckBox)
> > formComponent).setModelObject("false");
> >                         } else {
> >                             formComponent.clearInput();
> >                             formComponent.updateModel();
> >                         }
> >                         return
> > Component.IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
> >                     }
> >                 });
> >             }
> >         };
> >         // Perform only the onSubmit, no validation
> >         resetButton.setDefaultFormProcessing (false);
> >         form.add(resetButton);
> >
> >
> >
> > Erik van Oosten wrote:
> > > Yes, correct. The model should be cleared as well.
> > > And it indeed uses setDefaultFormProcessing(false).
> > >
> > > The approach your describing below will throw exceptions for checkboxes:
> > >
> > > WicketMessage: unable to set object null, model:
> > >
> Model:classname=[wicket.model.PropertyModel]:attached=true:[EMAIL PROTECTED]
> ]:expression=[searchInHistoricNames]:propertyType=[null],
> > > called with component [MarkupContainer [Component id = formelement, page
> > > = nl.amsterdam.rbrb.web.search.SearchPage, path =
> > >
> 2:maincontent:searchform:form:formElements:2:inputfragment:
> formelement.CheckBox,
> > > isVisible = true, isVersioned = false]]
> > >
> > > Root cause:
> > >
> > > wicket.util.convert.ConversionException: Can't convert
> null value to a
> > > primitive class: boolean for setting it on
> > >
> [EMAIL PROTECTED]
> > > at
> > >
> wicket.util.lang.PropertyResolver$MethodGetAndSet.setValue(Ljava.lang.Object;Ljava.lang.Object;Lwicket.util.convert.IConverter;)V(
> PropertyResolver.java:838)
> > > at
> > >
> wicket.util.lang.PropertyResolver$ObjectAndGetSetter.setValue(Ljava.lang.Object;Lwicket.util.convert.IConverter;)V(PropertyResolver.java:447)
> > > at
> > > wicket.util.lang.PropertyResolver.setValue
> (Ljava.lang.String;Ljava.lang.Object;Ljava.lang.Object;Lwicket.util.convert.IConverter;)V(PropertyResolver.java:136)
> > > at
> > >
> wicket.model.AbstractPropertyModel.onSetObject(Lwicket.Component;Ljava.lang.Object;)V(
> AbstractPropertyModel.java:182)
> > > at
> > >
> wicket.model.AbstractDetachableModel.setObject(Lwicket.Component;Ljava.lang.Object;)V(AbstractDetachableModel.java:131)
> > > at
> > > wicket.Component.setModelObject
> (Ljava.lang.Object;)Lwicket.Component;(Component.java:2042)
> > > at
> > >
> wicket.markup.html.form.FormComponent.updateModel()V(FormComponent.java:840)
> > > at
> > > nl.amsterdam.rbrb.web.form.FormPanel$5.component
> (Lwicket.Component;)Ljava.lang.Object;(FormPanel.java:214)
> > > <--- the line with formComponent.updateModel();
> > >
> > >
> > > Regards,
> > >      Erik.
> > >
> > >
> > >
> > >
> > > Johan Compagner wrote:
> > >
> > >> why do you want to call updateFormComponentModels?
> > >> You also want to clear all model data? So the models already did get
> > >> some data from a previous request?
> > >> (i take the reset button has setDefaultFormProcessing(false) ?)
> > >>
> > >> but why not do this:
> > >>
> > >>  form.visitChildren(FormComponent.class, new
> > >> Component.IVisitor() {
> > >>                     public Object component(Component component) {
> > >>                         ((FormComponent) component).clearInput();
> > >>                         ((FormComponent) component).updateModel();
> > >>                         return
> > >> Component.IVisitor.CONTINUE
> > >>
> > >>     _TRAVERSAL_BUT_DONT_GO_DEEPER;
> > >>                         }
> > >>                     });
> > >>
> > >>
> > >> On 1/9/07, *Erik van Oosten* < [EMAIL PROTECTED]
> > >> <mailto:[EMAIL PROTECTED]>> wrote:
> > >>
> > >>     Hi,
> > >>
> > >>     I am trying the make a reset button (clears all fields) with code
> > >>     below.
> > >>     According to the class comment of Form I can call
> > >>     updateFormComponentModels, however that method is not visible.
> > >>
> > >>     What can I do to get the desired effect? I am using wicket-1.2.4.
> > >>
> > >>     Regards,
> > >>          Erik.
> > >>
> > >>
> > >>             // The reset button
> > >>             Button resetButton = new Button("resetbutton") {
> > >>                 /** [EMAIL PROTECTED] */
> > >>                 protected void onSubmit() {
> > >>                     // Clear the form
> > >>                     form.visitChildren(FormComponent.class , new
> > >>     Component.IVisitor() {
> > >>                         public Object component(Component component) {
> > >>                             ((FormComponent) component).clearInput();
> > >>                             return
> > >>
> Component.IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
> > >>                         }
> > >>                     });
> > >>     *                form.updateFormComponentModels();   // <------
> method
> > >>     not visible
> > >>     *            }
> > >>             };
> > >>             // Perform only the onSubmit, no validation
> > >>
> resetButton.setDefaultFormProcessing(false);
> > >>             form.add(resetButton);
> > >>
> > >>
> > >>
> > >>     --
> > >>     Erik van Oosten
> > >>     http://www.day-to-day-stuff.blogspot.com/
> > >>
> > >>
> > >>
> -------------------------------------------------------------------------
> > >>     Take Surveys. Earn Cash. Influence the Future of IT
> > >>     Join SourceForge.net 's Techsay panel and you'll get the chance to
> > >>     share your
> > >>     opinions on IT & business topics through brief surveys - and earn
> cash
> > >>
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> > >>
> <http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> >
> > >>     _______________________________________________
> > >>     Wicket-user mailing list
> > >>     Wicket-user@lists.sourceforge.net
> > >>     <mailto:Wicket-user@lists.sourceforge.net>
> > >>
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> > >>
> > >>
> > >>
> ------------------------------------------------------------------------
> > >>
> > >>
> -------------------------------------------------------------------------
> > >> Take Surveys. Earn Cash. Influence the Future of IT
> > >> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> > >> opinions on IT & business topics through brief surveys - and earn cash
> > >>
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> > >>
> ------------------------------------------------------------------------
> > >>
> > >> _______________________________________________
> > >> Wicket-user mailing list
> > >> Wicket-user@lists.sourceforge.net
> > >>
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> > >>
> > >>
> > >
> > >
> >
> > --
> > Erik van Oosten
> > http://www.day-to-day-stuff.blogspot.com/
> >
> >
> >
> -------------------------------------------------------------------------
> > Take Surveys. Earn Cash. Influence the Future of IT
> > Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> > opinions on IT & business topics through brief surveys - and earn cash
> >
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> > _______________________________________________
> > Wicket-user mailing list
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
>


-- 
Vote for Wicket at the http://www.thebeststuffintheworld.com/vote_for/wicket
Wicket 1.2.4 is as easy as 1-2-4. Download Wicket now!
http://wicketframework.org

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to