1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
public class FormInput extends WebPage
{
private class ActionPanel extends Panel
{
public ActionPanel(String id, IModel<Contact> model)
{
super(id, model);
add(new Link("lock")
{
@Override
public void onClick()
{
//Sur l'evenement "onClick" je souhaiterai verrouiller les
//TextField de ma table (setEnable(false))
ActionPanel.this.get("lastName").setEnabled(false);
}
});
}
}
private class InputForm extends Form<FormInputModel>
{
/** Data Table ***********************************/
add(new Label("selectedLabel", new PropertyModel<String>(this, "selectedContactLabel")));
SortableContactDataProvider dp = new SortableContactDataProvider();
RefreshingView<Contact> refreshingView = new RefreshingView<Contact>("simple")
{
@Override
protected Iterator<IModel<Contact>> getItemModels()
{
// for simplicity we only show the first 10 contacts
Iterator<Contact> contacts = DatabaseLocator.getDatabase().find(0, 6, "firstName",
true).iterator();
// the iterator returns contact objects, but we need it to
// return models, we use this handy adapter class to perform
// on-the-fly conversion.
return new ModelIteratorAdapter<Contact>(contacts)
{
@Override
protected IModel<Contact> model(Contact object)
{
return new CompoundPropertyModel<Contact>(
new DetachableContactModel(object));
}
};
}
@Override
protected void populateItem(final Item<Contact> item)
{
// populate the row of the repeater
IModel<Contact> contact = item.getModel();
item.add(new ActionPanel("actions", contact));
item.add(new TextField<Long>("id"));
item.add(new TextField<String>("firstName"));
item.add(new TextField<String>("lastName"));
item.add(new TextField<String>("cellPhone").setEnabled(false));
}
@Override
protected Item<Contact> newItem(String id, int index, IModel<Contact> model)
{
// this item sets markup class attribute to either 'odd' or
// 'even' for decoration
return new OddEvenItem<Contact>(id, index, model);
}
};
refreshingView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
add(refreshingView);
}
} |
Partager