我有一個數據表,其中第一個組件是刪除按鈕,最後是複選框。 現在的問題是,當我刪除一行它重置在其他行中選擇的複選框 我不想取消選中其他行中的複選框。從數據表中刪除而不影響複選框事件
<h:dataTable id="languageTableBody" value="#{countryBean.countryLanguageList}" var="countryLangObj" >
<h:column>
<f:facet name="header">#{msg['country.language.label.delete']}</f:facet>
<p:commandLink action="#{countryBean.deleteRow}" immediate="true" update="@form" process="@this">
<h:graphicImage value="../images/delete.png" />
<f:setPropertyActionListener target="#{countryBean.langId}" value="#{countryLangObj.language.languageCode}" />
</p:commandLink>
</h:column>
<h:column>
<f:facet name="header">#{msg['country.language.label.assignlanguage']}</f:facet>
<h:inputText readonly="true" value="#{countryLangObj.language.languageName}" id="languageName" />
</h:column>
<h:column>
<f:facet name="header">#{msg['country.language.label.languagecode']}</f:facet>
<h:inputText readonly="true" value="#{countryLangObj.language.languageCode}" />
</h:column>
<h:column>
<f:facet name="header">#{msg['country.language.label.defaultlanguage']}</f:facet>
<h:selectBooleanCheckbox id="checkBox" value="#{countryLangObj.isDefaultLanguage}" onclick="dataTableSelectOneRadio(this)" />
</h:column>
</h:dataTable>
countryBean.java
public String deleteRow(){
System.out.println("deleteRow()::Enter");
String delLangId = getLangId();
System.out.println("getLangId(): "+getLangId());
if(null != delLangId && delLangId.trim().length() > 0){
System.out.println("Delete Language Code: "+delLangId);
List<CountryLanguageDTO> countryLangList = getCountryLanguageList();
System.out.println("countryLangList: "+ (null == countryLangList));
List<CountryLanguageDTO> tempCountryLangList = new ArrayList<CountryLanguageDTO>();
for (CountryLanguageDTO countryLanguage : countryLangList) {
System.out.println("wewewewew: "+delLangId.equalsIgnoreCase(countryLanguage.getLanguage().getLanguageCode()));
if(!delLangId.equalsIgnoreCase(countryLanguage.getLanguage().getLanguageCode())){
tempCountryLangList.add(countryLanguage);
}
}
setCountryLanguageList(tempCountryLangList);
}
return SUCCESS;
}
addCountry.js
function dataTableSelectOneRadio(radio) {
var id = radio.name.substring(radio.name.lastIndexOf(':'));
var el = radio.form.elements;
for (var i = 0; i < el.length; i++) {
if (el[i].name.substring(el[i].name.lastIndexOf(':')) == id) {
el[i].checked = false;
}
}
radio.checked = true;
}