Question
Please help fix below coding of 1-9. Thanks package comps368.tma02; import org.springframework.validation.Errors; /******* IMPORTANT : You can refer to u5p99 to complete this class *******/
Please help fix below coding of 1-9. Thanks
package comps368.tma02;
import org.springframework.validation.Errors;
/******* IMPORTANT : You can refer to u5p99 to complete this class *******/ /******* * IMPORTANT : But 10000% guarantee that you cannot complete with direct * copy and paste, nor without understand what the course * material coding is doing for *******/
/* 1. Annotation */ public class ItemValidator implements /* 2. The interface for Spring Validation */ {
/* 3. This is the tricky point. You need to validate whether the item code is already exists. Therefore you need to retrieve the DB to see whether search by same item code has results. So, how can you retrieve DB in Spring? */ /* 4. You should Override supports() method. However, beware what is the class you are validating? It is the view model of Items */
@Override public void validate(Object o, Errors errors) { /* 5. Cast to which class type? */ _i = (/* 5. Cast to which class type? */)o; //6. Validate the item code is null or empty (use the .isEmpty() method of string) //7. If null or empty, set the reject value by the errors.rejectValue() method // Go to u5p75 to check what are the 3 parameters need to pass to that function // Read start from the sentence "As shown in Listing 5.43,....." //check the item code is used before //8. Validate the item code is exists in DB //7. If exists, set the reject value by the errors.rejectValue() method // Go to u5p75 to check what are the 3 parameters need to pass to that function // Read start from the sentence "As shown in Listing 5.43,....." //9. Validate the price range from 0 to 999.99 //7. If the price is smaller than 0 or greater than 999.99, set the reject value by the errors.rejectValue() method // Go to u5p75 to check what are the 3 parameters need to pass to that function // Read start from the sentence "As shown in Listing 5.43,....." } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started