On Thu, 17 Jan 2008, jnorris wrote:
> Here's the relevant code:

I find this hard to understand. For one, the formatting is 
very strange, but also some crucial bits seem to be missing.
Maybe it's better if you post also the irrelevant parts :)

>               userPageModel = new UserPageModel();
>               cb = new CheckBox( "destroyable", userPageModel );

What is the UserPageModel like?

>               form.add( new Link( "deleteButton" ) 

As it's a Link and not a Button, "deleteLink" might be a 
better name. And take on account that just clicking a Link 
on the Form probably doesn't submit; you should either use a
FormComponent that submits the form (Button?) or add a
suitable ajax behavior to the Link.


>                       @Override
>                       public void onClick() 
>                       {
>                               if( null == selected )
>                                       error( "You must select a user!" );
>                               else

What is the variable "selected"?
> 
> System.out.println( "checkbox state is: " + cb.getValue());           
> //                                                    boolean markAsDeleted = 
> ????????????????????
> //                                                    
> selected.setDestroyable( !markAsDeleted );
>                                                       
> TestApplication.get().getUserService().removeUser( selected,

What is happening here? And how is CheckBox.getValue() supposed
to work?

I didn't understand what is your checkbox trying to do. If 
it is checked, clicking a link deletes a selected user? 
Sounds like a strange user interface, but probably I just
don't get it.

>                                               catch( ServiceException e )
>                                               {
>                                                       error( 
> selected.getFullName() + " was not deleted: " +
> e.getMessage());
>                                                       e.printStackTrace();
>                                               }

You should show the full stack trace, or better yet, just
make ServiceException an unchecked exception and remove the
whole catch block.

>       private class MyModel extends AbstractCheckBoxModel

This class is not used in the code above. Was your idea to
use this for the model of the checkbox?

I don't remember having used AbstractCheckBoxModel, but it 
seems strange that you have two sets of accessors doing the
same (isDestroyable / setDestroyable and isSelected / select
/ unselect). 

For checkboxes I typically just use a simple Model subclass
(that you can name for reuse if needed) operating on some
domain object, for example

    Car car = ...;

    add(new CheckBox("airConditioning", new Model() {
        @Override public Object/*<Boolean>*/ getObject() {
            return car.hasAirConditioning();
        }

        @Override public void setObject(Object/*<Boolean>*/ choice) {
            car.setAirConditioning((Boolean) choice);
        }
    }));


>               /**
>                * <p>Gets the value of the <code>destroyable</code> 
> property.</p>
>                * @return Returns the value of the <code>destroyable</code> 
> property.
>                */
>               public boolean isDestroyable()

You can just delete these comments, because what the method
does is clear from its name (a Javabean property accessor
convention).

>                               <input wicket:id = "deleteButton" type="submit" 
> value="Delete" />

Did you check how this gets rendered in the end? Declaring
it as a submit input in HTML and Link in Java seems
contradictory.


Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to