2014-06-27 68 views
0

我的jsff上有一個SelectManyChecbox,它綁定到託管bean中的列表。以編程方式更改Oracle ADF中SelectManyCheckbox列表的錯誤

現在我的問題是,當我點擊某個單選按鈕時,一些複選框應該被刪除,即列表應該被更新爲具有較少數量的複選框。

現在當我選擇了可​​以說10個複選框中的5個,現在當我更新列表時,它僅在複選框中僅有2個選項......並且此時ADF面臨提出問題選擇應該是有限的和所有。

請告訴我如何在更新列表之前將複選框重置爲默認/未選定狀態。

或是否有任何其他的方式來擺脫這種錯誤

回答

0

這裏是我的榜樣,而它的工作原理:

<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"> 
<af:document title="main.jsf" id="d1"> 
    <af:form id="f1"> 
     <af:panelGroupLayout id="pgl1"> 
      <af:selectOneRadio label="setValues" id="sor1" autoSubmit="true" 
           valueChangeListener="#{viewScope.test.onSetValues}" value="#{viewScope.test.values}"> 
       <af:selectItem label="5 values" value="0" id="si2"/> 
       <af:selectItem label="3 values" value="1" id="si3"/> 
      </af:selectOneRadio> 
      <af:selectManyChoice label="selectManyCheckBox" id="smc1" binding="#{viewScope.test.comp}"> 
       <f:selectItems value="#{viewScope.test.list}" id="si1"/> 
      </af:selectManyChoice> 
     </af:panelGroupLayout> 
    </af:form> 
</af:document> 

public class TestBean { 

private ArrayList<SelectItem> list; 
private long values; 
private RichSelectManyChoice comp; 

public TestBean() { 
    super(); 
    list = new ArrayList<SelectItem>(); 
    restoreList(); 
} 

private void restoreList() { 
    list.clear(); 
    list.add(new SelectItem(false, "value 1")); 
    list.add(new SelectItem(false, "value 2")); 
    list.add(new SelectItem(false, "value 3")); 
    list.add(new SelectItem(false, "value 4")); 
    list.add(new SelectItem(false, "value 5")); 
} 

private void cutList() { 
    list.clear(); 
    list.add(new SelectItem(false, "value 1")); 
    list.add(new SelectItem(false, "value 2")); 
    list.add(new SelectItem(false, "value 3")); 
} 

public void setList(ArrayList<SelectItem> list) { 
    this.list = list; 
} 

public ArrayList<SelectItem> getList() { 
    return list; 
} 

public void onSetValues(ValueChangeEvent valueChangeEvent) { 
    if ((Long)valueChangeEvent.getNewValue() == 0) 
     restoreList(); 
    else {    
     cutList(); 
    } 
    comp.setValue(null); 
    comp.processUpdates(FacesContext.getCurrentInstance()); 
    AdfFacesContext.getCurrentInstance().addPartialTarget(comp);   
} 

public void setValues(long values) { 
    this.values = values; 
} 

public long getValues() { 
    return values; 
} 

public void setComp(RichSelectManyChoice comp) { 
    this.comp = comp; 
} 

public RichSelectManyChoice getComp() { 
    return comp; 
} 
相關問題