Monthly Archives: January 2024

SPRING MVC THE VALIDATION OF DATA

FORM VALIDATION Before addressing validation, let's see how we can externalize the labels of our forms to facilitate their internationalization. OUTSOURCE LABELS The more observant will have realized that in the forms we used labels wired directly into the code. As a first step to outsource labels, we need to make configuration-level changes. Let's open the WebApplicationContextConfig.java file and modify it as follows. As you see from the figure below, the Bean does nothing more than configure the message source. The setBasename property sets a text file to be the source. Now we need to create [...]

By |2024-01-01T00:35:27+00:00January 1, 2024|0 Comments

SPRING MVC UPLOAD PRODUCT IMAGE

UPLOAD PRODUCT IMAGE One of the most useful features in a project is server-side storage of files. In our case we will make sure to send product images, images in png format, to the server. The affected jsp page will be the item detail page. As you may recall, we have so far prepared a placeholder image, we will now give the user the option, when creating an item, to also add an image of the product displayed in the item detail. Our goal is to make sure that when an image exists that is consistent with the product [...]

By |2024-01-04T22:42:44+00:00January 4, 2024|0 Comments

SPRING MVC JPA AND HIBERNATE

JPA AND HIBERNATE The objects of the next articles will be two very important frameworks involving the persistence layer. JPA and Hibernate. Hibernate ORM (or simply Hibernate) is an object-relational mapping tool for the Java programming language. Provides a framework for mapping an object-oriented domain model to a relational database. Sostitutes direct and persistent database accesses with high-level object management functions. Hibernate is free software distributed under the GNU Lesser General Public License 2.1.The main feature of Hibernate is mapping from Java classes to database tables and mapping from Java data types to SQL data types. Hibernate also provides [...]

By |2024-01-07T11:19:34+00:00January 7, 2024|0 Comments

SPRING MVC ENTITY CREATION

CREATION OF THE CLIENTI ENTITY Entity classes are the schematic representation of the tables we are going to modify or read in our relational database. They are similar to the previously created domain classes, however, they have a different behavior. The first step is to create the package where Hibernate will look for them. Before creating the class let's look in our relational database at the tables involved. THE CLIENTI TABLE Let's look at the structure of the CLIENTI table. As can be seen, CODFIDELITY is the primary key. A primary [...]

By |2024-01-14T07:12:35+00:00January 14, 2024|0 Comments

SPRING MVC MANAGE BASIC QUERIES

WE IMPLEMENT THE ABSTRACT DAO CLASS TO HANDLE BASIC QUERIES We create a new package com.xantrix.webapp.dao with a GenericRepository interface and two generics that both extend serialization. I represents the entities AND the primary key. Having done this we specify which are the basic methods of our persistence layer and which constitute the fundamental operations on the DBMS. Now we create the class that implements this interface. We will call this class AbstractDao, which as the name implies is an abstract class. THE ENTITY MANAGER The first element we are [...]

By |2024-01-24T20:44:43+00:00January 24, 2024|0 Comments

SPRING MVC JPA2 ADVANCED

HEREDITY OF ENTITY CLASSES From a technical point of view, entity classes are for all intents and purposes Java classes that therefore follow the identical rules of any other class. Consequently, entity classes are also subject to inheritance; therefore, they can edit properties that come from superclasses. Let's look at the classes Clienti Cards and Utenti, these three classes have the same primary key. One could create a perhaps abstract class that implements CODFIDELITY and inherit it in the above classes. We create a new abstract class AbstractEntityClienti. Abstract classes defined as entities need a specific notation at the top [...]

By |2024-01-26T00:24:44+00:00January 26, 2024|0 Comments

SPRING MVC PRIMARY KEY GENERATION

THE EMBEDDED OBJECTS In some cases the class mapping is not exactly the same as the table structure. Let us look at the Premi table where more fields have been added. These elements are typical of a master table, however, they were equally included in the table, although in such cases it is good to split the two tables. Our goal is to distinguish within the entity classes the registry part from the more informative part of the flows. THE INFOPREMI CLASS So we have to create another class, however this class is special, it is an embedded class [...]

By |2024-01-27T23:25:03+00:00January 27, 2024|0 Comments

INTRODUCTION TO SPRING SECURITY

INTRODUCTION TO SPRING SECURITY Security, particularly so in web applications is critical, and it is not just about access or preventing data modification, but also give the user the ability to be able to access certain resources but not others. For example, entering a new item in the registry should not be allowed to a standard user but only to administrators. We can give many examples of authentication, for example when we withdraw money with our card we have to authenticate ourselves, the bank needs to know who we are and whether we are authorized to [...]

By |2024-01-30T20:47:50+00:00January 30, 2024|0 Comments
Go to Top