2013-07-09 4 views

답변

2

모델 옵션을 선택하려면 사용자 지정 특성 (title)을 추가하기 만하면됩니다. 당신이 당신의 자신의 OptionModel 구현 추가해야이하려면 :

public class CustomOptionModel implements OptionModel { 
    private final String label; 
    private final Object value; 
    private final Map<String, String> attributes; 

    public CustomOptionModel(final String label, 
          final Object value, 
          final String tooltip) { 
     this.label = label; 
     this.value = value; 

     if (tooltip != null) { 
      attributes = new HashMap<String, String>(); 
      attributes.put("title", tooltip); 
     } else { 
      attributes = null; 
     } 
    } 

    public String getLabel() { 
     return label; 
    } 

    public boolean isDisabled() { 
     return false; 
    } 

    public Map<String, String> getAttributes() { 
     return attributes; 
    } 

    public Object getValue() { 
     return value; 
    } 
} 

그리고 마지막 것은 팔레트를 선택 모델을 연결하는 것입니다

public SelectModel getMySelectModel() { 
    final List<OptionModel> options = new ArrayList<OptionModel>(); 
    options.add(new CustomOptionModel("First", 1, "First Item")); 
    options.add(new CustomOptionModel("Second", 2, "Second Item")); 
    options.add(new CustomOptionModel("Third", 3, "Third Item")); 
    return new SelectModelImpl(null, options); 
} 
+0

당신에게 sody 감사합니다, 나는 즉시 내가 가지고 그것을 시도 할 것이다 시간을 알려주고 – MartinC

+0

hm을 알려주십시오. 예외로 페이지를 렌더링 할 때 첫 번째 시도가 실패했습니다. Class SegmentCustomModel이 변형되었으며 직접 인스턴스화되지 않을 수 있습니다. 조사 할게. – MartinC

+0

ups, 나는 방금 모델 클래스를 다른 패키지로 옮겨야했다. 태피스트리는 그것을 예약하지 않았다. 감사! – MartinC