Handling NULL values in a DropDownChoice

2010-01-08 Thread Norman Elton
I'm using a DropDownChoice to select one of a number of items loaded
from my DAO:

DropDownChoiceAuditTrain train_drop_down = new
DropDownChoiceAuditTrain(new-train, new_audit_train, new
DetachableAuditTrainsModel(this.train_dao.getList()));

This works fine. But my the property I'm setting is nullable; that is,
it accepts NULL values. So I'd like to add an item to the beginning of
the list entitled No Audit Train. I've tried a few ways, but all
seem to get dirtier and kludgier the farther down the rabbit hole I
dig. For instance, I've tried modifying my DAO to prepend the list
with NULL, then use a custom ChoiceRenderer to catch this and format
it properly. But then my DetachableLoadable model needs to be able to
catch and reload this NULL value. Things get out of hand quickly.

Is there a standard way to solve this problem?

Thanks,

Norman

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



Storing Objects vs Primary Key in Session

2010-01-03 Thread Norman Elton
In the phonebook application, there are check boxes that use a special
model (CheckBoxModel) to populate a SetLong. This set stores the
primary-key of all the checked contacts. These are then fed to the DAO
to delete all the selected contacts.

But, let's say that there is an option called change all selected
names to 'fred'. It would be silly to have a DAO method called,
changeFirstName(int id, String new_name). Instead, this would be
cleaner:

for (Contact curr_contact: selected_contacts) {
  curr_contact.setFirstName(fred);
  contact_dao.save(curr_contact);
}

This means that, instead of storing primary keys in a SetLong, we
should store the actual object in a SetContact. Assuming that the
object being stored is serializable and fairly small, are there any
performance implications here?

Thanks,

Norman

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



Re: DataTable's Handling of NULL Values

2010-01-02 Thread Norman Elton
Thanks for both responses. I'm going to try them both. Two
clarification questions:

- In Ernesto's idea (override populateItem()), would the model still
be dynamic? That is, if the table is used in a form and the data
updated, would the table reflect the new change? My terminology may be
a little off here.

- In Jason's idea (create a wrapped model), the notion of default is
actually an audit train object, not just a string? This wouldn't be
the end of the world, since AuditTrain is just an interface and I
could provide an instance of an anonymous inner class. It would have
to return undefined for it's name property, etc.

Thanks again, I will tinker with them both today.

Norman

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



DataTable's Handling of NULL Values

2010-01-01 Thread Norman Elton
I've created a DataTable, which works great. I'd like to define the
behavior if a property returns NULL. For instance, this column
retrieves the AuditTrain object for a given Asset:

columns.add(new PropertyColumnAsset(new ModelString(Audit
Train), audit_train);

If the AuditTrain is NULL, I get a null-pointer exception. Ideally,
I'd like to return a column-specific string and css class. Seems that
I need to define a new IColumn.

Any pointers? Has this been done before?

Thanks,

Norman

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