Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@Model annotation and MVC

The Weld documentation states that the javax.enterprise.inject.Model annotation is designed for Controllers (logical because it marks bean as @RequestScoped and @Named).

But why is it named as Model instead of Controller?

like image 376
Deniz Avatar asked Mar 28 '12 07:03

Deniz


People also ask

What are Annotations in MVC?

Data Annotations are nothing but certain validations that we put in our models to validate the input from the user. ASP.NET MVC provides a unique feature in which we can validate the models using the Data Annotation attribute. Import the following namespace to use data annotations in the application.

Why data annotation is not working in MVC?

Answers. You have added the Assessment type as a parameter in the post action method. Hence MVC try to create a new instance of Assessment class. If the value for Title field is not provided in the view, then it will try to set the value for Title property as null.

Which namespaces are required to data annotation using MVC?

ComponentModel. DataAnnotations Namespace. Provides attribute classes that are used to define metadata for ASP.NET MVC and ASP.NET data controls.

Can we do validation in MVC using data Annotations *?

In Asp.net MVC, we can easily apply validation to web application by using Data Annotation attribute classes to model class. Data Annotation attribute classes are present in System.


1 Answers

Because the specification does not assume you use a pattern that involves having controllers in the first place.

There's other patterns and naming conventions out there. For example seam uses a "Action" instead of "Controller" (all though those concepts do not map entirely)

like image 170
Karl Kildén Avatar answered Oct 18 '22 01:10

Karl Kildén