1

I'm using Swing and Java. I just started learning MVC.

I'm little bit confused of the way that I need to validate a form (view).

My thinking is to make method inside my view class and verify form components one by one, but I'm afraid that this would violate the MVC principle.

fejese
  • 4,601
  • 4
  • 29
  • 36
abdou amer
  • 819
  • 2
  • 16
  • 43

2 Answers2

2

A shown in How to Use the Focus Subsystem: Validating Input, you can use an InputVerifier to accept or reject specific values. Some examples are seen here. As discussed here, this usage is consonant with the Swing separable model approach to MVC.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
1

By the MVC princepal you have to create a validation method inside the controller level, either the controller level may call a service which makes the same.
But still, the validation method must be called from the view to the controller.

Try to see this example: http://www.oracle.com/technetwork/articles/javase/index-142890.html

roeygol
  • 4,908
  • 9
  • 51
  • 88