Skip to content
Snippets Groups Projects
Commit 05918547 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Upload of Dependencies.

parent 1fe8b86b
No related branches found
No related tags found
No related merge requests found
...@@ -21,12 +21,12 @@ ...@@ -21,12 +21,12 @@
<artifactId>jetty-maven-plugin</artifactId> <artifactId>jetty-maven-plugin</artifactId>
<version>8.1.0.RC1</version> <version>8.1.0.RC1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.ocpsoft</groupId> <groupId>com.ocpsoft</groupId>
<artifactId>prettyfaces-jsf2</artifactId> <artifactId>prettyfaces-jsf2</artifactId>
<version>3.3.2</version> <version>3.3.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sun.faces</groupId> <groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId> <artifactId>jsf-api</artifactId>
<version>2.1.6</version> <version>2.1.6</version>
......
package kieker.webgui.beans; package kieker.webgui.beans;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped; import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import kieker.webgui.common.FileManager; import kieker.webgui.common.FileManager;
...@@ -14,20 +16,20 @@ import org.primefaces.model.UploadedFile; ...@@ -14,20 +16,20 @@ import org.primefaces.model.UploadedFile;
@ManagedBean @ManagedBean
@SessionScoped @SessionScoped
public class DependencyUploadController { public class DependencyUploadController {
private UploadedFile file; private UploadedFile file;
public UploadedFile getFile() { public UploadedFile getFile() {
System.out.println(file);
return file; return file;
} }
public void setFile(UploadedFile file) { public void setFile(UploadedFile file) {
System.out.println(file);
this.file = file; this.file = file;
} }
public void upload() { public void upload() {
System.out.println(file); FacesMessage msg = new FacesMessage("Succesful", file.getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, msg);
FileManager.getInstance().uploadDependency(file); FileManager.getInstance().uploadDependency(file);
} }
} }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param> <context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name> <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>Development</param-value> <param-value>server</param-value>
</context-param> </context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
<init-param>
<param-name>thresholdSize</param-name>
<param-value>51200</param-value>
</init-param>
<init-param>
<param-name>uploadDirectory</param-name>
<param-value>C:\Temp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param> <context-param>
<param-name>primefaces.THEME</param-name> <param-name>primefaces.THEME</param-name>
...@@ -36,7 +57,7 @@ ...@@ -36,7 +57,7 @@
<listener-class>com.sun.faces.config.ConfigureListener</listener-class> <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener> </listener>
<filter> <filter>
<filter-name>Pretty Filter</filter-name> <filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class> <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter> </filter>
...@@ -49,13 +70,4 @@ ...@@ -49,13 +70,4 @@
<dispatcher>ERROR</dispatcher> <dispatcher>ERROR</dispatcher>
</filter-mapping> </filter-mapping>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
</web-app> </web-app>
...@@ -204,10 +204,15 @@ ...@@ -204,10 +204,15 @@
resizable="false" modal="true" widgetVar="DependenciesUploadDialog"> resizable="false" modal="true" widgetVar="DependenciesUploadDialog">
<h:form enctype="multipart/form-data"> <h:form enctype="multipart/form-data">
<p:fileUpload value="#{dependencyUploadController.file}" mode="simple" />
<p:messages showDetail="true" />
<p:fileUpload value="#{dependencyUploadController.file}"
mode="simple" />
<p:commandButton value="Submit" ajax="false" <p:commandButton value="Submit" ajax="false"
actionListener="#{dependencyUploadController.upload}" /> actionListener="#{dependencyUploadController.upload}" />
</h:form> </h:form>
</p:dialog> </p:dialog>
......
The project "Kieker.WebGUI" can be started via Maven. Just use the command The project "Kieker.WebGUI" can be started via Maven (3). Just use the command
mvn jetty:run mvn jetty:run
to pack the war-file, deploy it on jetty and start jetty. The web tool is then available at to pack the war-file, deploy it on jetty and start jetty. The web tool is then available at
http://localhost:8080/faces/main.xhtml http://localhost:8080/Kieker.WebGUI
\ No newline at end of file \ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment