You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Petr Fejfar <pe...@gmail.com> on 2009/09/25 07:30:47 UTC
DataTable, ChoiceFilteredPropertyColumn, Choice renderer and values
translated via M:1 association
Hi all,
please, could somebody push me forward how to implement ChoiceRenderer
of ChoiceFilteredPropertyColumn? I seem to be lost among data
providers and models little bit...
I followed Wicket-stuff's phonebook example and I show list of
persistent entities in the DataTable. I'd like to have a choice
filtered column containing subcription names got from phone numbers
via @ManyToOne association. But I'm not able to create proper Choice
renderer to be returned to DataTable for filtering purposes. My code
looks like this (choice filtering is commented out):
private PropertyColumn<String> createSenderColumn()
{
return new PropertyColumn<String>(new
ResourceModel("columnPhone"), "phone", "phone") {
// return new ChoiceFilteredPropertyColumn(
// new ResourceModel("columnPhone"), "phone","phone",
// new LoadableDetachableModel() {
// private static final long serialVersionUID = 1L;
// @Override
// protected Object load() {
// List names =
TTraceWebSession.get().getUser().listSubscriptionNames();
// names.add(0,"");
// return names;
// }
// }) {
private static final long serialVersionUID = 1L;
public void populateItem(Item cellItem, String
componentId, IModel model) {
AttitudeHistory history = (AttitudeHistory) model.getObject();
Label label = new Label(componentId, createLabelModel(model));
label.add(new AttributeModifier("title", true, new
Model<String>(history.getPhone())));
cellItem.add(label);
}
@Override
protected IModel createLabelModel(IModel rowModel) {
final AttitudeHistory history = (AttitudeHistory)
rowModel.getObject();
return new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return history.getSubscription().getSubscriptionName();
}
};
}
// @Override
// protected IChoiceRenderer getChoiceRenderer() {
// return null;
// }
public String getCssClass() {
return "column-phone";
}
};
}
Thanks, Petr
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org