2016-08-04 3 views
0

간단한 작업 인 것처럼 보이지만 해결책을 찾지 못한 무언가를 다루고 있습니다. RichSelectOneChoice의 텍스트에 어떻게 액세스합니까? 나는 단지 richSelectOneChoice.getValue()valueChangeEvent.getNewValue()ADF RichSelectOneChoice 텍스트 가져 오기 (레이블)

으로 값을 찾았습니다. 그러나 실제 텍스트에 어떻게 접근 할 수 있습니까? 콘솔 출력에 상관없이 선택이 무엇인지, 해당 값에 대한 널 (null)입니다 순간

private RichSelectOneChoice selClaim; 

public void claimTypeVCL(ValueChangeEvent ve){ 
    Map s = selClaim.getAttributes(); 
    Object ss = s.get(ve.getNewValue()); 
    System.out.println(ss); 
} 

:

내 마지막 시도는이이었다.

RichSelectOneChoice 개체에 바인딩 된 ADF 구성 요소는 내부 요소가있는 구성 요소로 만들어집니다.

나는 또한 적절한 개체 유형 (RichSelectOneChoice) 여기 프랭크 Nimphius에 의해 https://community.oracle.com/thread/1050821을 제안 된 솔루션 만을 시도한 아이들이 제안 instanceof RichSelectOneChoice을하지 않은 것이 아니라 javax.faces.component.UISelectItem이 클래스는하지 않기 때문에 절은 실행하지 않는 경우 getLabel() 메서드를 포함하고 코드를 실행하면 실제로 레이블을 액세스하려고 할 때 대상 유형으로 객체를 캐스팅하거나 null 포인터와 관련된 다양한 오류가 발생합니다.

+0

당신이 UISelectItem 객체의 getAttribute를 (키) 방법으로 시도 했습니까? like selectItem.gettAttribute ("description") –

+0

UISelectItem 클래스에는 getAttribute() 메서드가 없으며 Map 을 반환하는 getAttributes() 메서드 만 있습니다. 나는 이것을 시도 할 것이다. – codeSwim

답변

0

getLabel() 또는 getValue() 대신 UISelectionItem 개체와 getItemValue() 및 getItemLabel() 메서드를 사용하여 해결했습니다. 후자는 사용할 수 있지만 예상 결과는 렌더링하지 않았습니다.

실무 코드는 다음과 같습니다

public String selectedOptionStr; 
public void socClaimTypeVCL(ValueChangeEvent ve){ 
    selectedOptionStr = ""; 
    RichSelectOneChoice sct = (RichSelectOneChoice)ve.getSource(); 
    List childList = sct.getChildren(); 
    for (int i = 0; i < childList.size(); i++) { 
     if (childList.get(i) instanceof javax.faces.component.UISelectItem) {     
      javax.faces.component.UISelectItem csi = (javax.faces.component.UISelectItem) childList.get(i); 
      if (csi.getItemValue().toString() == ve.getNewValue().toString()) { 
       selectedOptionStr = csi.getItemLabel(); 
      } 
     } 
    } 
} 
관련 문제