commit | author | age
|
aaf094
|
1 |
package com.redhat.training.ui; |
RS |
2 |
|
|
3 |
import javax.enterprise.context.RequestScoped; |
|
4 |
import javax.inject.Named; |
|
5 |
|
|
6 |
import com.redhat.training.model.Person; |
|
7 |
import com.redhat.training.services.PersonService; |
|
8 |
|
|
9 |
import javax.inject.Inject; |
|
10 |
import java.util.List; |
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
@RequestScoped |
|
15 |
@Named("hello") |
|
16 |
public class Hello { |
|
17 |
private String name; |
|
18 |
private Long id; |
|
19 |
private List<Person> results; |
|
20 |
|
|
21 |
@Inject |
|
22 |
private PersonService personService; |
|
23 |
|
|
24 |
public String getName() { |
|
25 |
return name; |
|
26 |
} |
|
27 |
|
|
28 |
public void setName(String name) { |
|
29 |
this.name = name; |
|
30 |
} |
|
31 |
|
|
32 |
public Long getId() { |
|
33 |
return id; |
|
34 |
} |
|
35 |
|
|
36 |
public void setId(Long id) { |
|
37 |
this.id = id; |
|
38 |
} |
|
39 |
|
|
40 |
//View all persons in the database table |
|
41 |
public List<Person> getPersons() { |
|
42 |
return personService.getAllPersons(); |
|
43 |
} |
|
44 |
|
|
45 |
//view all persons whose name matches the name given in the query |
|
46 |
public void search() { |
|
47 |
results = personService.getPersonsWithName(name); |
|
48 |
} |
|
49 |
|
|
50 |
public List<Person> getResults() { |
|
51 |
return results; |
|
52 |
} |
|
53 |
|
|
54 |
public void setResults(List<Person> results) { |
|
55 |
this.results = results; |
|
56 |
} |
|
57 |
|
|
58 |
|
|
59 |
} |