我的bean中有一個布爾(原始)變量。根據用戶選擇的單選按鈕,我需要它的值爲true或false。錯誤:無法在bean中的布爾屬性中將屬性值設置爲null
我在一個jsf數據表的同一行的兩個不同列中實現JSF單選按鈕。 這是一個要求,我在同一行的兩列中使用單選按鈕。
現在,我必須確保只選擇其中一個按鈕id。
所以我的做法是,
我使用映射到bean作爲一個虛擬的另一個單選按鈕一個單選按鈕。
<h:column>
<h:selectOneRadio id="mixtas" value="#{bean.mixtas}">
<f:selectItem itemValue="true"></f:selectItem>
</h:selectOneRadio>
</h:column>
<h:column>
<h:selectOneRadio id="exclusi" >
<f:selectItem itemValue="true"></f:selectItem>
</h:selectOneRadio>
</h:column>
,我使用jquery
$('input[id*="mixtas"]').live("click",function(){
var $index = this.id.split(':')[2]; \\to identify the row index
var $id = $index+":exclusi:0"; \\generating id for other radio button
$('table[id$="'+$id+'"]').attr("checked",false); \\ to make the other radio false
});
$('input[id*="exclusi"]').live("click",function(){
var $index = this.id.split(':')[2]; \\ to identify the row index
var $id = $index+":mixtas:0"; \\generating id for other radio button
$('input[id$="'+$id+'"]').attr("checked",false); \\ to make the other radio false
});
該功能可以運行處理只選擇一個功能。至少有一半(我仍在繼續工作)。
但問題是。
如果我選中了「混合」單選按鈕,並且我嘗試進入另一頁面。 它給出錯誤「屬性不能設置爲null」。
有什麼辦法給它賦值false而不是null。也許在jQuery或通過豆。
請任何建議....
在此先感謝。
是這個錯誤被提出了一個特定的線,是從螢火蟲或服務器端的錯誤? – Daniel 2012-03-29 06:25:00
您使用的是JSF 2.0嗎? – 2012-03-29 06:49:15
這是serverError。它無法在頁面提交中將值null設置爲原始布爾類型。 – 2012-03-29 07:09:14