2017-09-19 4 views
0

스프링 웹 플로우는 selectPatient 상태에서 selectDoctor 상태로 전환하는 동안 Patient 모델의 유효성을 검사하기 위해 사용자 정의 유효성 검사기 PatientValidator을 사용하지 않습니다. 여기 스프링 웹 플로우는 구현 된 유효성 검사기를 사용하지 않습니다.

Patient.java

내 코드입니다
@Data 
@Entity 
public class Patient implements Serializable { 
    private static final long serialVersionUID = -5116169782847291743L; 

    ... 
} 

PatientValidator.java

@Component 
public class PatientValidator extends FieldValidator { 
    public PatientValidator() { } 

    public void validateSelectPatient(Patient patient, Errors errors) { 
     System.out.println("PatientValidator . validateSelectPatient"); 
    } 

    public void validateSelectDoctor(Patient patient, Errors errors) { 
     System.out.println("PatientValidator . validateSelectDoctor"); 
    } 
} 

제출 요청-flow.xml 내가 사용하는 경우에도

<?xml version="1.0" encoding="UTF-8"?> 
<flow xmlns="http://www.springframework.org/schema/webflow" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://www.springframework.org/schema/webflow 
          http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> 

    <secured attributes="ROLE_OFFICER" match="any"/> 

    <on-start> 
    <evaluate expression="submitRequestFlow.getPatient()" result="flowScope.patient"></evaluate> 
    </on-start> 


    <view-state id="selectPatient" view="flows/requests/new/select-patient" model="patient"> 
    <transition on="select" to="selectDoctor"></transition> 
    </view-state> 


    <view-state id="selectDoctor" view="flows/requests/new/select-doctor"> 
    <transition on="select" to="selectTestType"></transition> 
    <transition on="back" to="selectPatient"></transition> 
    </view-state> 


    ... 


    <end-state id="finishFlow" view="externalRedirect:#{uri.get('requests')}"> 
    <output name="success" value="'Request has been added successfully'"/> 
    </end-state> 

    <end-state id="cancelFlow" view="externalRedirect:#{uri.get('requests')}"> 
    </end-state> 

    <global-transitions> 
    <transition on="cancel" to="cancelFlow" history="discard" bind="false" validate="false"></transition> 
    </global-transitions> 

</flow> 

을 내부의 검증 메소드 Patient.java, 웹 플로우가 그것을 사용합니다.

@Data 
@Entity 
public class Patient implements Serializable { 
    private static final long serialVersionUID = -5116169782847291743L; 

    ... 

    public void validateSelectPatient(Errors errors) { 
     errors.reject("NoResultFound"); 
    } 
} 

나는 그냥 처음 작동, 사용자 정의 검증보다는 모델 하나를 사용해야합니다,하지만 난 봄 부트 프로젝트를 다시 부팅 한 후에는 더 이상 작동하지 않는 것 같아요.


업데이트 # 내가

  • 봄 부팅 1.5.6.RELEASE
  • 봄 WebFlow 2.4.5.RELEASE
  • Thymeleaf 3.0.7을 사용하고 1

    . 릴리즈

  • Thymeleaf SpringSecurity4 3.0.2.RELEASE

답변