我正在處理的東西似乎是一項微不足道的任務,但尚未找到解決方案:如何訪問RichSelectOneChoice上的文本?我只發現richSelectOneChoice.getValue()
和valueChangeEvent.getNewValue()
ADF RichSelectOneChoice獲取文本(標籤)
的值但是,如何訪問實際文本?
我的最後一次嘗試是這樣的:
private RichSelectOneChoice selClaim;
public void claimTypeVCL(ValueChangeEvent ve){
Map s = selClaim.getAttributes();
Object ss = s.get(ve.getNewValue());
System.out.println(ss);
}
目前控制檯輸出爲null爲相應的值,無論選擇是什麼。
綁定到RichSelectOneChoice對象的ADF組件被創建爲具有內部元素的組件。
我也嘗試由Frank Nimphius使用適當的對象類型(RichSelectOneChoice)這裏提出https://community.oracle.com/thread/1050821的解決方案,但如果該條款不執行,因爲孩子不是instanceof RichSelectOneChoice
的建議,而是javax.faces.component.UISelectItem
和此類不包括getLabel()
方法,並且運行代碼實際上會拋出大量與將對象轉換爲目標類型相關的錯誤,或者在嘗試訪問標籤時拋出空指針。
您是否試圖與UISelectItem對象的getAttribute(key)方法?類似於selectItem.gettAttribute(「description」) –
UISelectItem類沒有getAttribute()方法,只有getAttributes()方法返回Map。我會試試這個。 –
codeSwim