簡體   English   中英

小門:在ListView中使用可編輯的Inline標簽,並在更改此標簽值后更新模型

[英]Wicket: Using a editable Inline-label inside a ListView and update a model after change this label value

我需要在ListView中使用可編輯標簽或內聯標簽,更改此組件的值后,我想知道如何更新此ListView中顯示的Object的屬性。

add(new ListView[SomeObject]("listSomeObject", listData) {

    override protected def onBeforeRender() {
     ...
      super.onBeforeRender()
    }

    def populateItem(item: ListItem[SomeObject]) = {
      var objValue = item.getModelObject()

      item.add(new Label("total", objValue.toString(getFormatter())))
     }
    }
  })

在上面的代碼中,對象SomeObject具有一個名為total的屬性,listView顯示了一組SomeObject,當在listview的某行中更改標簽total時,應使用標簽total的新值來更新相應的對象SomeObject。

有人可以提供一些有用的示例來幫助我完成此任務嗎?

謝謝

您應該使用模型來顯示您的屬性。 例如,一個propertyModel。 方法getObject()將在顯示時被調用。 PropertyModel將為所選屬性調用getter。 您可以讓您的對象具有一個getter,該getter檢索您感興趣的格式化值。

item.add(new Label("total", new PropertyModel(item.getModel(), "formattedValue")))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM