2010-03-16 8 views

답변

6

아니요, 이러한 유효성 검사기는 기본 JSF 구현에 존재하지 않습니다. 기본적으로 그룹의 마지막 구성 요소에서 유효성 검사기를 실행하고 UIViewRoot#findComponent()을 사용하여 유효성을 검사하려는 기타 구성 요소를 가져와야합니다. 예 :

public void validate(FacesContext context, UIComponent component, Object value) { 
    UIComponent otherComponent = context.getViewRoot().findComponent("otherClientId"); 
    Object otherValue = ((UIInput) otherComponent).getValue(); 
    // ... 
} 

자세한 배경 정보 및 구체적인 예는 this article을 참조하십시오. 한편

, 당신은 JSF2에 이미 있다면, 당신은 또한 ajaxical 검증을 사용할 수있다 :

public void validate(ComponentSystemEvent e) { 
    UIComponent form = e.getComponent(); 
    UIComponent oneComponent = form.findComponent("oneClientId"); 
    UIComponent otherComponent = form.findComponent("otherClientId"); 
    // ... 
} 

:

<h:form> 
    <f:event type="postValidate" listener="#{bean.validate}" /> 
    ... 
</h:form> 

..where #{bean.validate} 방법은 다음과 같이 JSF2 유효성 검증 예제에 대해서는 this article을 참조하십시오.

관련 문제