US06: Add a button for the owner create form to the owners list, fix bug where all whitespaces were considered valid input
This commit is contained in:
parent
be37d5ce86
commit
a01405e3cc
@ -127,7 +127,7 @@ public class OwnerJdbcDao implements OwnerDao {
|
|||||||
int changes = jdbcTemplate.update(connection -> {
|
int changes = jdbcTemplate.update(connection -> {
|
||||||
PreparedStatement ps = connection.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS);
|
PreparedStatement ps = connection.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS);
|
||||||
|
|
||||||
ps.setString(1, owner.getName());
|
ps.setString(1, owner.getName().trim());
|
||||||
ps.setObject(2, owner.getCreatedAt());
|
ps.setObject(2, owner.getCreatedAt());
|
||||||
ps.setObject(3, owner.getUpdatedAt());
|
ps.setObject(3, owner.getUpdatedAt());
|
||||||
return ps;
|
return ps;
|
||||||
|
@ -12,7 +12,7 @@ import java.util.Map;
|
|||||||
@Component
|
@Component
|
||||||
public class Validator {
|
public class Validator {
|
||||||
public void validateNewOwner(Owner owner) throws ValidationException {
|
public void validateNewOwner(Owner owner) throws ValidationException {
|
||||||
if(owner.getName() == null || owner.getName().isEmpty()) {
|
if(owner.getName() == null || owner.getName().isEmpty() || owner.getName().isBlank()) {
|
||||||
throw new ValidationException("Required value name missing");
|
throw new ValidationException("Required value name missing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<form (ngSubmit)="addOwner()" #ownerForm="ngForm">
|
<form (ngSubmit)="addOwner()" #ownerForm="ngForm">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name">Name</label>
|
<label for="name">Name</label>
|
||||||
<input type="text" class="form-control" name="name" [(ngModel)]="owner.name" required>
|
<input type="text" class="form-control" name="name" [(ngModel)]="owner.name" pattern="\s*\S+.*" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-success" [disabled]="!ownerForm.form.valid" (submit)="addOwner()">Submit</button>
|
<button type="submit" class="btn btn-success" [disabled]="!ownerForm.form.valid" (submit)="addOwner()">Submit</button>
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary"><i class="fas fa-search"></i></button>
|
<button type="submit" class="btn btn-primary"><i class="fas fa-search"></i></button>
|
||||||
<button type="button" onclick="document.getElementById('searchForm').reset();" class="btn btn-danger"><i class="fas fa-times"></i></button>
|
<button type="button" onclick="document.getElementById('searchForm').reset();" class="btn btn-danger"><i class="fas fa-times"></i></button>
|
||||||
|
<a href="owner/add" class="btn btn-success"><i class="fas fa-plus"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
|
Reference in New Issue
Block a user