diff --git a/javaee-demo1-jsf/src/main/java/pl/tpolgrabia/trainings/javaee/controllers/HelloController.java b/javaee-demo1-jsf/src/main/java/pl/tpolgrabia/trainings/javaee/controllers/HelloController.java index f78c5ca..95747a6 100644 --- a/javaee-demo1-jsf/src/main/java/pl/tpolgrabia/trainings/javaee/controllers/HelloController.java +++ b/javaee-demo1-jsf/src/main/java/pl/tpolgrabia/trainings/javaee/controllers/HelloController.java @@ -2,14 +2,14 @@ package pl.tpolgrabia.trainings.javaee.controllers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import pl.tpolgrabia.trainings.javaee.javaeedemo.ejb.SimpleMessageSendingBean; import pl.tpolgrabia.trainings.javaee.javaeedemo.ejb.TodosDao; import pl.tpolgrabia.trainings.javaee.javaeedemo.ejb.UserDao; import pl.tpolgrabia.trainings.javaee.javaeedemo.entities.User; import javax.annotation.PostConstruct; -import javax.ejb.EJB; -import javax.enterprise.context.RequestScoped; import javax.faces.view.ViewScoped; +import javax.inject.Inject; import javax.inject.Named; import java.io.Serializable; import java.util.List; @@ -20,12 +20,15 @@ public class HelloController implements Serializable { private static final long serialVersionUID = 2780964279445984180L; private static final Logger logger = LoggerFactory.getLogger(HelloController.class); - @EJB + @Inject private TodosDao todosDao; - @EJB + @Inject private UserDao userDao; + @Inject + private SimpleMessageSendingBean simpleMessageSendingBean; + private String message; private boolean markedAsDanger = false; @@ -50,7 +53,8 @@ public class HelloController implements Serializable { } public String handleSubmit() { - logger.info("Hello submit"); + logger.info("Submitting message {}", message); + simpleMessageSendingBean.sendHello(message); return "index"; } @@ -62,5 +66,6 @@ public class HelloController implements Serializable { @PostConstruct public void init() { this.message = "Submit me"; + logger.info("Initialized with message {}", message); } } diff --git a/javaee-demo1-jsf/src/main/webapp/index.xhtml b/javaee-demo1-jsf/src/main/webapp/index.xhtml index af485fa..453a04b 100644 --- a/javaee-demo1-jsf/src/main/webapp/index.xhtml +++ b/javaee-demo1-jsf/src/main/webapp/index.xhtml @@ -89,7 +89,20 @@
- +
+
+ +
+
+
+

+ +

+
+
+
+