Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
토스3 책내용중 궁금한곳이 있습니다!!
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
용이  
View profile   Translate to Translated (View Original)
 More options Jan 13 2011, 5:13 am
From: 용이 <clov4l...@naver.com>
Date: Thu, 13 Jan 2011 02:13:18 -0800 (PST)
Local: Thurs, Jan 13 2011 5:13 am
Subject: 토스3 책내용중 궁금한곳이 있습니다!!
어쩌다보니 질문을 많이하게되네요.^^;;

토스3 13장 스프링 @MVC

P1227

*서비스계층 오브젝트에서의 검증

음 테스트를 해보았는데요.
책에는 간단하게 기술하셨는데, 컨트롤러와 같은방법으로는 DI가 되지 않는군요.
xxxxService, xxxxServiceImpl, xxxxDao, xxxxDaoImpl
Service와 Dao는 인터페이스고
~Impl은 구현체인데요. 구현체에 DI하고 로직작성하는것이 맞지요?
예제코드가 조금이라도 있었음 좋았을텐데 ㅠㅠ

제상황은...
org.springframework.validation.Validator 스프링 Validator를 사용하고요.

물론 <mvc:annotation-driven />을 기입해서
디폴트 발리데이터가 빈검증기 이긴합니다 (JSR-303)
하지만

<bean id="productValidator"
class="com.test.validation.validator.ProductValidator" />
와 같이 빈등록을 하고 org.springframework.validation.Validator구현체를 작성해서
@Autowired로 DI받아서
컨트롤러에서는 무리없이 잘쓰고있습니다.

JSR-303을 여러가지 이유로 포기했는데, (메시지 컨트롤이 힘들고 등등.....그룹등등)
이부분에서 막히네요...

도움 부탁드립니다^^

참 그리고 여기 계신분들중에서도 JSR-303대신 Spring Validator를 사용하고 계신 분이 계시다면
왜그러신지 질문 드려봐도 될까요?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
백기선  
View profile   Translate to Translated (View Original)
 More options Jan 13 2011, 5:19 am
From: 백기선 <whiteship2...@gmail.com>
Date: Thu, 13 Jan 2011 19:19:18 +0900
Local: Thurs, Jan 13 2011 5:19 am
Subject: Re: 토스3 책내용중 궁금한곳이 있습니다!!

> ~Impl은 구현체인데요. 구현체에 DI하고 로직작성하는것이 맞지요?

넵 맞습니다. 예제코드는 CD에 들어있을지도 모릅니다.

왜그러신지 질문 드려봐도 될까요?

JSR 303 만으로는 해결이 안되는 검증 로직도 있습니다. 그런 경우에는 스프링 Validator를 구현해서 복잡한 검증 로직을 그
안에 넣기도 합니다.

그나저나 1227p까지 보셨다니... 멋지십니다!!!

2011년 1월 13일 오후 7:13, 용이 <clov4l...@naver.com>님의 말:

--
좋은 하루 되세요~

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
용이  
View profile   Translate to Translated (View Original)
 More options Jan 13 2011, 6:35 am
From: 용이 <clov4l...@naver.com>
Date: Thu, 13 Jan 2011 03:35:25 -0800 (PST)
Local: Thurs, Jan 13 2011 6:35 am
Subject: Re: 토스3 책내용중 궁금한곳이 있습니다!!
예제 CD를 분해할정도로 살펴봤는데요^^:;
예제에서는 Validator구현체에서 서비스 오브젝트를 가져와서 사용하는거네요.

책내용 대로라면 서비스 구현체에서 컨트롤러처럼 구현한 validator를 DI받고
this.validator.validate(product, BeanPropertyBindingReult bpResult);
이런식으로 해야할것 같은 분위기인데요.ㅎㅎ

흑...

근데 서비스 계층에서 쓸때는 체크예외를 던지라고 나와있던데,
이건 어떻게 해야한다는 거죠?^^

On 1월13일, 오후7시19분, 백기선 <whiteship2...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
백기선  
View profile   Translate to Translated (View Original)
 More options Jan 13 2011, 7:31 am
From: 백기선 <whiteship2...@gmail.com>
Date: Thu, 13 Jan 2011 21:31:28 +0900
Local: Thurs, Jan 13 2011 7:31 am
Subject: Re: 토스3 책내용중 궁금한곳이 있습니다!!

넹 예제 코드에는 안나와있나보네요.

책을 열어봤더니 그렇게 적혀 있군요. Validator를 서비스 계층에서도 활용할 수 있다는.. 그래서 서비스 계층에 validator
주입해놓고 검증 로직을 수행하느라..

this.validator.validate(product, BeanPropertyBindingReult bpResult);이런식으로

> 해야할것 같은 분위기인데요.ㅎㅎ

이렇게 될 수도 있겠네요. 근데.. 이렇게 하면 안되나요? 왜 '흑' 이라고 하셨는지 궁금하기도.. 안궁금하기도.. @_@

근데 서비스 계층에서 쓸때는 체크예외를 던지라고 나와있던데,이건 어떻게 해야한다는 거죠?^^

이건 또 몇 페이지에 나와있는 이야기인지.. 궁금하기도 하고 안궁금하기도.. @_@

친절한 박성철님과 정상혁님께서 해결해 주실겁니다.

2011년 1월 13일 오후 8:35, 용이 <clov4l...@naver.com>님의 말:

--
좋은 하루 되세요~

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
용이  
View profile   Translate to Translated (View Original)
 More options Jan 13 2011, 7:56 am
From: 용이 <clov4l...@naver.com>
Date: Thu, 13 Jan 2011 04:56:37 -0800 (PST)
Local: Thurs, Jan 13 2011 7:56 am
Subject: Re: 토스3 책내용중 궁금한곳이 있습니다!!
아 제가 바보였습니다.
Maven을 쓰는데, pom.xml <dependency> 설정때문에 참조를 못하는모듈쪽에서 작업해서 ㅡ.ㅡ;;;
당연히 import조차 안돼는건데 ㅎㅎㅎ
백기선님 정말 감사하고 죄송합니다.ㅡㅡ

참고로 서비스객체에서 사용할때는
@Autowired
ProductValidator productValidator;
.
.
BeanPropertyBindingResult result = new
BeanPropertyBindingResult(product, "Errors");
this.categoryValidator.validate(product, result);

이런식으로 해서 result를 사용하면 되는군요.

근데 아직도 P1227 맨밑에 단락에 나온말들은 어떻게 해야할지 모르겠네요^^

On 1월13일, 오후9시31분, 백기선 <whiteship2...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
백기선  
View profile   Translate to Translated (View Original)
 More options Jan 13 2011, 8:06 am
From: 백기선 <whiteship2...@gmail.com>
Date: Thu, 13 Jan 2011 22:06:53 +0900
Local: Thurs, Jan 13 2011 8:06 am
Subject: Re: 토스3 책내용중 궁금한곳이 있습니다!!

헐... 왜그러세요 ㅠ.ㅠ 제가 머랬다고..
저 나쁜 사람 아니에요;;

맨 밑에줄은 이런 내용인것 같습니다.

서비스에서 검증했는데 실패하면 예외를 던지게 하고, 그걸 컨트롤러에서 무조건 잡아서 화면으로 에러 전달하도록..  예외처리를 강제화 할
수 있게 체스 예외를 사용하는게 좋겠다는 내용입니다.

(흠.. 마치.. 제가 무슨 성경을 해석해드리는 사람 같군요.ㅋㅋㅋ)

public class BookService {

...

  public showMeThe(Book book) throws BookError {
      ...
      validator.validate(book, result)
      if(result.hasErrors() {
          throw new BookError();
      }
  }

}

public class BookController {

    @RequestMapping("/show/me/the/book/{id}")
    public void whiteship(@PathVariable("id") Book book, Model model) {
        ....
        try {
            bookService.showMeThe(book);
        catch {
            //하악하악... @_@;;
         }
    }

}

//하악하악 저기서... 모델에다 에러 정보 담아서 화면에 전달해주면 어떤 검증 에러나 난건지 사용자에게 보여줄 수 있겠죠. 아마도..
그런 내용이지 싶습니다.

2011년 1월 13일 오후 9:56, 용이 <clov4l...@naver.com>님의 말:

--
좋은 하루 되세요~

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »