Skip to main content

Introduction to CreateAccountJson

Introduction to CreateAccountJson

The CreateAccountJson class represents the JSON structure required for creating a new account. It encapsulates the account details within a field named creAcc, which is an instance of the CreaccJson class.


The constructor of CreateAccountJson initializes the creAcc field using data from a CreateAccountForm object. This example shows how the account type, customer number, overdraft limit, and interest rate are extracted from the form and used to create a CreaccJson object.

	public CreateAccountJson(CreateAccountForm createAccountForm)
{
creAcc = new CreaccJson(createAccountForm.getAccountType().toString(),
createAccountForm.getCustNumber(),
createAccountForm.getOverdraftLimit(),
createAccountForm.getInterestRate());

}

Methods

The CreateAccountJson class provides several methods to interact with the account details:

  1. getCreAcc: This method retrieves the creAcc field, allowing access to the account details.

  2. toPrettyString: This method formats the account details into a readable string, making it easier to display or log the information.

  3. toString: This method provides a string representation of the CreateAccountJson object, which can be useful for debugging or logging purposes.

Usage in WebController

The CreateAccountJson class is utilized in the WebController class to handle account creation requests. The showCreateAccForm method displays the account creation form, while the processCreateAcc method processes the form data and creates a new account using CreateAccountJson.


The showCreateAccForm method in the WebController class displays the account creation form.

	@GetMapping("/createacc")
public String showCreateAccForm(CreateAccountForm createAccForm,
Model model)
{
model.addAttribute(ACCOUNT_TYPES, AccountType.values());
return CREATE_ACCOUNT_FORM;
}


The processCreateAcc method in the WebController class processes the form data and creates a new account using CreateAccountJson.

	@PostMapping("/createacc")
public String processCreateAcc(@Valid CreateAccountForm createAccForm,
BindingResult bindingResult, Model model)

 

This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human