I have built a web app game that uses Ajax and Spring MVC.
When the player presses the “Start a new game” button on the screen, my code in the View hides that button and displays other game buttons. This logic is in the View and not in the Model.
My question is, is it bad MVC practice to have such logic in the View? Should the View be “as dumb as possible”?
All the rest of the logic is in my Model.
This seems to me a philosophical question.
In MVC the model should be logic-free, the controller contains the controller-logic, and your view contains the view-logic. This means there is supposed to be logic in your view, but just logic related to the display of your model.
The best you can do here in order to place all logic in the controller is to fire off an Ajax call when the “start a new game” button is pressed, and return a true from the controller. Then you have to have some view logic bit in your Javascript that hides the Start button and shows the other game buttons.
In iturning the buttons on and off is view-logic. You cannot avoid putting it into the view.