Hi Igor,
I thought the problem would be simple enough to not include code but here it
is. BTW if I de-select the checkbox and click on the select link in the
table the checkbox becomes selected again. The debug stmt I threw in always
prints "true"
I'll be giving a presentation/demo in a couple of weeks or so to the rest of
my development team and hope Wicket opens their eyes to how sweet it is to
use so maybe we can start using it for new projects. That's why I'm
building a fairly simple demo app with some CRUD features using
JPA/hibernate and some AJAX updating. Our current system is a home-grown
JSP/Javascript/Oracle system which has been in the works for over 7 years
now and is a monster - ugh!
Thanks for any help,
Jim
Here's the relevant code:
public class UserListPage extends BasePage
{
private CheckBox cb;
private UserPageModel userPageModel;
public UserListPage()
{
Form form = new Form( "userListForm" );
add( form );
..... other components added including the AjaxFallbackDefaultDataTable
userPageModel = new UserPageModel();
cb = new CheckBox( "destroyable", userPageModel );
form.add( cb );
form.add( new Link( "deleteButton" )
{
private static final long serialVersionUID = 1L;
@Override
public void onClick()
{
if( null == selected )
error( "You must select a user!" );
else
{
if( "admin".equalsIgnoreCase(
selected.getUserName()))
error( "The admin account
cannot be deleted!" );
else
{
try
{
// Test the permanently
deleted entity function.
here is where I have tried to get the state of the checkbox which is always
true
System.out.println( "checkbox state is: " + cb.getValue());
// boolean markAsDeleted =
????????????????????
//
selected.setDestroyable( !markAsDeleted );
TestApplication.get().getUserService().removeUser( selected,
CurrentUser.getCurrentUser());
info( "User was
successfully deleted: " + name );
}
catch( ServiceException e )
{
error(
selected.getFullName() + " was not deleted: " +
e.getMessage());
e.printStackTrace();
}
}
}
}
});
..... other components (buttons)
}
Here's the model class:
private class MyModel extends AbstractCheckBoxModel
{
private static final long serialVersionUID = 1L;
private boolean destroyable = true;
/**
* <p>Gets the value of the <code>destroyable</code>
property.</p>
* @return Returns the value of the <code>destroyable</code>
property.
*/
public boolean isDestroyable()
{
return destroyable;
}
/**
* <p>Sets the value of the <code>destroyable</code>
property.</p>
* @param destroyable The new value for the
<code>destroyable</code>
property.
*/
public void setDestroyable( boolean destroyable )
{
this.destroyable = destroyable;
}
@Override
public boolean isSelected()
{
return destroyable;
}
@Override
public void select()
{
destroyable = true;
}
@Override
public void unselect()
{
destroyable = false;
}
}
}
Here's the html:
<wicket:extend>
<form wicket:id = "userListForm">
Selected User: [selected user]
<br/>
<table class="dataview" cellspacing="0"
wicket:id="table">[table]</table>
Permanently Delete the User:<input wicket:id =
"destroyable"
type="checkbox" /><br/>
<input wicket:id = "createButton" type="submit"
value="Create" />
<input wicket:id = "editButton" type="submit"
value=" Edit " />
<input wicket:id = "deleteButton" type="submit"
value="Delete" />
</form>
</wicket:extend>
--
View this message in context:
http://www.nabble.com/Checkbox-problem-tp14926922p14929826.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]