columns.add(new AbstractColumn(new Model("ColumnName"))
{
public void populateItem(Item cellItem, String
componentId, final IModel model)
{
cellItem.add(new AjaxEditableLabel(componentId, new
PropertyModel(model, 'attribute1'));
}
-igor
On Thu, Jan 22, 2009 at 4:59 AM, Philipp Daumke <[email protected]> wrote:
> Dear all,
>
> I try to create an editable column using DefaultDataTable and
> AjaxEditableLabel. My current version is posted below but it's quite a hack
> and I wonder whether there's an official good solution for that before I go
> on with my work.
>
> Thanks al lot for your help
> Philipp
>
> HTML:<table class="tablename" cellspacing="0"
> wicket:id="termTable">[table]</table>
>
> Java:
> columns = new ArrayList<IColumn>();
> columns.add(new AbstractColumn(new Model("ColumnName"))
> {
> public void populateItem(Item cellItem, String componentId,
> final IModel model)
> {
> cellItem.setModel(model);
> ObjectToDisplay to = (ObjectToDisplay
> )cellItem.getModelObject();
> String attribute1= to.getAttribute1();
> cellItem.add(new AjaxEditableLabel(componentId, new
> Model(attribute1))
> {
> @Override
> protected void onSubmit(AjaxRequestTarget target) {
> super.onSubmit(target);
> String newAttribute1 = (String) getModelObject();
> ObjectToDisplay obj = (ObjectToDisplay )
> getParent().getModelObject();
> obj.setAttribute1(newAttribute1);
> System.out.println("New Attribute for " + obj
> .getId() + ": " + obj .getAttribute1();
> }
> });
> }
> add(new DefaultDataTable("tablename", columns, provider, 20));
>
>
>
>
> SortableDataProvider provider = new SortableDataProvider() {
> public int size() {
> return resultList.getEntries().size();
> }
> public IModel model(Object object) {
> TableObject entry = (TableObject) object;
> return new Model((Serializable) entry);
> }
> /*public Iterator iterator(int first, int count) {
> return resultList.selectEntries(first, count).iterator();
> }*/
> public Iterator iterator(int first, int count)
> {
> SortParam sp = getSort();
> return resultList.selectEntries(first, count,
> sp).iterator();
> }
> };
> --
>
> Averbis GmbH
> c/o Klinikum der Albert-Ludwigs-Universität
> Stefan-Meier-Strasse 26
> D-79104 Freiburg
>
> Fon: +49 (0) 761 - 203 6707
> Fax: +49 (0) 761 - 203 6800
> E-Mail: [email protected]
>
> Geschäftsführer: Dr. med. Philipp Daumke, Kornél Markó
> Sitz der Gesellschaft: Freiburg i. Br.
> AG Freiburg i. Br., HRB 701080
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]