簡體   English   中英

帶有selectbooleancheckbox的jsf數據表

[英]jsf datatable with selectbooleancheckbox

我有以下代碼:JSF PAGE

<h:dataTablevalue="#{bean.records}" var="app">
  <h:column>
    <h:selectBooleanCheckbox value="#{bean.checked[app.id]}"/>
    <f:facet name="footer">
      <h:commandButton value="submit" action="#{bean.submitPublic}"/>
    </f:facet>
</h:column>

和BEAN代碼:

@SessionScoped
public class bean 

private Map<Long, Boolean> checked = new HashMap<Long, Boolean>();
private List<Application> checkedItems = new ArrayList<Application>();

public void submit() {

for (Application app : getRecords()) {
    if (checked.get(app.getId())) {
        checkedItems.add(app);
    }
}
checked.clear();
//here logic for selected apps
}

    public Map<Long, Boolean> getChecked() {
        return checked;
    }
    public void setChecked(Map<Long, Boolean> checked) {
        this.checked = checked;
    }

問題是當我單擊按鈕時,未提交所選值。 我正在閱讀本文: 如何在<h:dataTable>中使用<h:selectBooleanCheckbox>選擇多行?

以相同的方式完成了所有操作,但沒有用。

選中Checkbox更新數據表。

<h:selectBooleanCheckbox value="#{bean.checked[app.id]}">
    <f:ajax event="valueChange" render=":YOUR_FORM_ID:YOUR_TABLE_ID"/>
</h:selectBooleanCheckbox>

暫無
暫無

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

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