Skip to content
Snippets Groups Projects
Commit bfde7e5a authored by Emmanuel Bruno's avatar Emmanuel Bruno
Browse files

cleans up.

parent 80bba05c
No related branches found
No related tags found
No related merge requests found
...@@ -3,8 +3,6 @@ utils/src/main/resources/* ...@@ -3,8 +3,6 @@ utils/src/main/resources/*
*.jks *.jks
*.p12 *.p12
target/ target/
.classpath
.project
.settings/ .settings/
Thumbs.db Thumbs.db
......
...@@ -8,7 +8,7 @@ import java.util.List; ...@@ -8,7 +8,7 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
public class PersonDAO { public class PersonDAO {
private EntityManager entityManager; private final EntityManager entityManager;
@Inject @Inject
public PersonDAO(@H2Database EntityManager entityManager) { public PersonDAO(@H2Database EntityManager entityManager) {
...@@ -16,7 +16,7 @@ public class PersonDAO { ...@@ -16,7 +16,7 @@ public class PersonDAO {
} }
public List<Person> findAll() { public List<Person> findAll() {
return entityManager.createNamedQuery("Person.findAll").getResultList(); return entityManager.createNamedQuery("Person.findAll", Person.class).getResultList();
} }
public UUID persist(Person person) { public UUID persist(Person person) {
......
...@@ -22,14 +22,14 @@ public class AddPersonView implements Serializable { ...@@ -22,14 +22,14 @@ public class AddPersonView implements Serializable {
private transient PersonDAO personDAO; private transient PersonDAO personDAO;
@Getter @Getter
private Person newPerson = new Person(); private final Person newPerson = new Person();
@Getter @Getter
private Person addedPerson = new Person(); private Person addedPerson = new Person();
@Transactional @Transactional
public void addPerson() { public void addPerson() {
FacesMessage facesMessage; addedPerson = Person.builder().name(newPerson.getName()).build();
personDAO.persist(addedPerson = Person.builder().name(newPerson.getName()).build()); personDAO.persist(addedPerson);
FacesContext.getCurrentInstance().addMessage("growl-id", new FacesMessage(FacesMessage.SEVERITY_INFO, "Person added", addedPerson.getName() + "(" + addedPerson.getUuid() + ")")); FacesContext.getCurrentInstance().addMessage("growl-id", new FacesMessage(FacesMessage.SEVERITY_INFO, "Person added", addedPerson.getName() + "(" + addedPerson.getUuid() + ")"));
} }
} }
package fr.univtln.bruno.jee91.jsf;
import jakarta.enterprise.context.RequestScoped;
import jakarta.faces.application.FacesMessage;
import jakarta.faces.context.FacesContext;
import jakarta.inject.Named;
@Named
@RequestScoped
public class GrowlView {
public void addMessage(FacesMessage.Severity severity, String summary, String detail) {
FacesContext.getCurrentInstance().
addMessage(null, new FacesMessage(severity, summary, detail));
}
public void showInfo() {
addMessage(FacesMessage.SEVERITY_INFO, "Info Message", "Message Content");
}
public void showWarn() {
addMessage(FacesMessage.SEVERITY_WARN, "Warn Message", "Message Content");
}
public void showError() {
addMessage(FacesMessage.SEVERITY_ERROR, "Error Message", "Message Content");
}
public void showSticky() {
FacesContext.getCurrentInstance().addMessage("sticky-key", new FacesMessage(FacesMessage.SEVERITY_INFO, "Sticky Message", "Message Content"));
}
public void showMultiple() {
addMessage(FacesMessage.SEVERITY_INFO, "Message 1", "Message Content");
addMessage(FacesMessage.SEVERITY_INFO, "Message 2", "Message Content");
addMessage(FacesMessage.SEVERITY_INFO, "Message 3", "Message Content");
}
}
\ No newline at end of file
...@@ -15,7 +15,7 @@ public class ViewPersonBean { ...@@ -15,7 +15,7 @@ public class ViewPersonBean {
@Inject @Inject
PersonDAO personDAO; PersonDAO personDAO;
private String message = "Hello"; private final String message = "Hello";
public String getMessage() { public String getMessage() {
return this.message; return this.message;
......
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<p:spinner />
<div class="card">
<h:form>
<p:growl id="growl" showDetail="true"/>
<p:growl id="growl-sticky" for="sticky-key" showDetail="true" sticky="true"/>
<h5 class="p-mt-0">Severities</h5>
<p:commandButton actionListener="#{growlView.showInfo}" update="growl" value="Info" styleClass="p-mr-2"
style="width: 10rem"/>
<p:commandButton actionListener="#{growlView.showWarn}" update="growl" value="Warn"
styleClass="p-mr-2 ui-button-warning" style="width: 10rem"/>
<p:commandButton actionListener="#{growlView.showError}" update="growl" value="Error"
styleClass="ui-button-danger" style="width: 10rem"/>
<h5>Multiple</h5>
<p:commandButton actionListener="#{growlView.showMultiple}" update="growl" value="Multiple" style="width: 10rem"
styleClass="ui-button-outlined"/>
<h5>Sticky</h5>
<p:commandButton actionListener="#{growlView.showSticky}" update="growl-sticky" value="Info"
style="width: 10rem" styleClass="ui-button-help"/>
</h:form>
</div>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
xmlns:p="http://primefaces.org/ui"> xml:lang="en">
<h:head> <h:head>
<title>Person list</title>
</h:head> </h:head>
<h:body> <h:body>
<h3 style="text-align: center">#{viewPersonBean.message}</h3> <h3 style="text-align: center"><h:outputText value="#{viewPersonBean.message}"/></h3>
<div class="card"> <div class="card">
<p:dataTable var="person" value="#{viewPersonBean.persons}"> <p:dataTable var="person" value="#{viewPersonBean.persons}">
......
...@@ -32,7 +32,7 @@ public class SampleResource { ...@@ -32,7 +32,7 @@ public class SampleResource {
@Inject @Inject
PersonDAO personDAO; PersonDAO personDAO;
private String message = "Hello"; private final String message = "Hello";
@GET @GET
public Response message() { public Response message() {
......
...@@ -25,12 +25,6 @@ ...@@ -25,12 +25,6 @@
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>slf4j-log4j12</artifactId>
</dependency> </dependency>
<dependency>
<groupId>fr.univtln.bruno.samples.jee91</groupId>
<artifactId>utils</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -19,18 +19,18 @@ public class WsClient { ...@@ -19,18 +19,18 @@ public class WsClient {
public WsClient(URI endpointURI) { public WsClient(URI endpointURI) {
try { try {
WebSocketContainer container = ContainerProvider.getWebSocketContainer(); WebSocketContainer container = ContainerProvider.getWebSocketContainer();
var url = getClass().getClassLoader().getResource("mycert-pub.jks");
String pathtoCert = getClass().getClassLoader().getResource("mycert-pub.jks").toURI().getPath();
System.getProperties().put("javax.net.debug", "ssl"); System.getProperties().put("javax.net.debug", "ssl");
if (url != null) {
String pathtoCert = url.toURI().getPath();
System.getProperties().put(SSLContextConfigurator.KEY_STORE_FILE, pathtoCert); System.getProperties().put(SSLContextConfigurator.KEY_STORE_FILE, pathtoCert);
System.getProperties().put(SSLContextConfigurator.KEY_STORE_TYPE, "JKS"); System.getProperties().put(SSLContextConfigurator.KEY_STORE_TYPE, "JKS");
System.getProperties().put(SSLContextConfigurator.TRUST_STORE_FILE, pathtoCert); System.getProperties().put(SSLContextConfigurator.TRUST_STORE_FILE, pathtoCert);
System.getProperties().put(SSLContextConfigurator.TRUST_STORE_TYPE, "JKS"); System.getProperties().put(SSLContextConfigurator.TRUST_STORE_TYPE, "JKS");
System.getProperties().put(SSLContextConfigurator.KEY_STORE_PASSWORD, "storepass"); System.getProperties().put(SSLContextConfigurator.KEY_STORE_PASSWORD, "storepass");
System.getProperties().put(SSLContextConfigurator.TRUST_STORE_PASSWORD, "storepass"); System.getProperties().put(SSLContextConfigurator.TRUST_STORE_PASSWORD, "storepass");
}
final SSLContextConfigurator defaultConfig = new SSLContextConfigurator(); final SSLContextConfigurator defaultConfig = new SSLContextConfigurator();
defaultConfig.retrieve(System.getProperties()); defaultConfig.retrieve(System.getProperties());
container.connectToServer(this, endpointURI); container.connectToServer(this, endpointURI);
} catch (Exception e) { } catch (Exception e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment