use of org.jboss.as.quickstarts.kitchensinkjsp.model.Member in project quickstart by wildfly.
the class MemberListProducer method retrieveAllMembersOrderedByName.
@PostConstruct
public void retrieveAllMembersOrderedByName() {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Member> criteria = cb.createQuery(Member.class);
Root<Member> member = criteria.from(Member.class);
// Swap criteria statements if you would like to try out type-safe criteria queries, a new
// feature in JPA 2.0
// criteria.select(member).orderBy(cb.asc(member.get(Member_.name)));
criteria.select(member).orderBy(cb.asc(member.get("name")));
members = em.createQuery(criteria).getResultList();
}
use of org.jboss.as.quickstarts.kitchensinkjsp.model.Member in project quickstart by wildfly.
the class MemberRegistrationServlet method doPost.
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
StringBuilder errorMessage = new StringBuilder();
try {
System.out.println("EMAIL='" + request.getParameter("email") + "'");
Member member;
while ((member = registrationService.getNewMember()) == null) {
registrationService.initNewMember();
}
String value;
if ((value = request.getParameter("name")).length() < 1) {
errorMessage.append("Name can not be null\n");
} else {
member.setName(value);
if ((value = request.getParameter("email")).length() < 1) {
errorMessage.append("email required!\n");
} else {
member.setEmail(value);
if ((value = request.getParameter("phoneNumber")).length() < 1) {
errorMessage.append("phoneNumber required \n");
} else // all parameters are filled, register
{
member.setPhoneNumber(value);
log("\n*****************Try Registration of Member=" + member);
registrationService.register();
request.setAttribute("infoMessage", member.getName() + " Registered!");
}
}
}
} catch (Exception e) {
Throwable t = e;
while ((t.getCause()) != null) {
t = t.getCause();
}
errorMessage.append("Error========>" + t.getMessage());
request.setAttribute("infoMessage", "");
e.printStackTrace();
} finally {
request.setAttribute("errorMessage", errorMessage.toString());
RequestDispatcher resultView = request.getRequestDispatcher("index.jsp");
resultView.forward(request, response);
}
}
use of org.jboss.as.quickstarts.kitchensinkjsp.model.Member in project quickstart by wildfly.
the class MemberRegistrationIT method testRegister.
@Test
public void testRegister() throws Exception {
Member newMember = memberRegistration.getNewMember();
newMember.setName("Jane Doe");
newMember.setEmail("jane@mailinator.com");
newMember.setPhoneNumber("2125551234");
memberRegistration.register();
assertNotNull(newMember.getId());
log.info(newMember.getName() + " was persisted with id " + newMember.getId());
}
use of org.jboss.as.quickstarts.kitchensinkjsp.model.Member in project quickstart by wildfly.
the class MemberRegistration method initNewMember.
@PostConstruct
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void initNewMember() {
newMember = new Member();
log.info("@PostConstruct:initNewMember called");
}
Aggregations