Skip to content
Snippets Groups Projects
Commit 1c038f7e authored by hkarwa2s's avatar hkarwa2s
Browse files

Anhand von Tutorial mal eine Tabellenfunktion implementiert, ist noch sehr...

Anhand von Tutorial mal eine Tabellenfunktion implementiert, ist noch sehr simpel gehalten und ohne Bezug auf eine Datenbank.
parent 4ee45ac3
No related branches found
No related tags found
No related merge requests found
......@@ -22,4 +22,25 @@
<goal>jetty:run</goal>
</goals>
</action>
<action>
<actionName>CUSTOM-run jetty</actionName>
<displayName>run jetty</displayName>
<goals>
<goal>jetty:run</goal>
</goals>
</action>
<action>
<actionName>debug</actionName>
<packagings>
<packaging>war</packaging>
<packaging>ear</packaging>
<packaging>ejb</packaging>
</packagings>
<goals>
<goal>package</goal>
</goals>
<properties>
<netbeans.deploy.debugmode>true</netbeans.deploy.debugmode>
</properties>
</action>
</actions>
......@@ -5,13 +5,24 @@ import javax.servlet.annotation.WebServlet;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Title;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.data.util.BeanContainer;
import com.vaadin.server.FontAwesome;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import java.util.List;
import org.s4s.modell.objects.dto.Product;
import org.s4s.process.controll.ProductSearch;
/**
* This UI is the application entry point. A UI may either represent a browser window
......@@ -27,11 +38,59 @@ public class MyUI extends UI {
@Override
protected void init(VaadinRequest vaadinRequest) {
Label label = new Label("Das erste Label unseres Shop in Shop System");
setContent(label);
// setContent(label);
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
final HorizontalLayout horizontalLayout = new HorizontalLayout();
TextField textfield = new TextField();
Button button = new Button("Suche" , FontAwesome.SEARCH);
horizontalLayout.addComponent(textfield);
horizontalLayout.addComponent(button);
layout.addComponent(label);
layout.setComponentAlignment(label, Alignment.TOP_LEFT);
layout.addComponent(horizontalLayout);
layout.setComponentAlignment(horizontalLayout, Alignment.TOP_RIGHT);
final BeanContainer<Integer, Product> data = new BeanContainer<Integer, Product>(Product.class);
data.setBeanIdProperty("id");
final Table table = new Table ("Products" , data);
table.setSizeFull();
table.setSelectable(true);
button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event){
String str = textfield.getValue();
if(str.equals("")){
Notification.show(null, "Bitte gesuchtes Produkt eingeben!", Notification.Type.WARNING_MESSAGE);
} else{
layout.addComponent(table);
List<Product> liste = ProductSearch.getInstance().getProductByTyp(str);
data.removeAllItems();
data.addAll(liste);
table.setPageLength(table.size());
}
}
});
}
@WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
public static class MyUIServlet extends VaadinServlet {
}
}
}
\ No newline at end of file
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.s4s.modell.objects.dto;
/**
*
* @author Holger Karwanni
*/
public class Product {
private String name;
private Integer id;
private String typ;
private double price;
private String description;
public Product(String name, Integer id, String typ, double price, String description){
this.name = name;
this.id = id;
this.typ = typ;
this.price = price;
this.description = description;
}
public Product(){
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public Integer getId(){
return id;
}
public void setId(Integer id){
this.id = id;
}
public String getTyp(){
return typ;
}
public void setTyp(String typ){
this.typ = typ;
}
public double getPrice(){
return price;
}
public void setPrice(double price){
this.price = price;
}
public String getDescription(){
return description;
}
public void setDescription (String description){
this.description = description;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.s4s.process.controll;
import java.util.ArrayList;
import java.util.List;
import org.s4s.modell.objects.dto.Product;
/**
*
* @author Holger
*/
public class ProductSearch {
Product p1 = new Product("Nachhilfe Algebra", 1, "Nachhilfe", 2.00, "Biete Nachhilfe in Algebra an!");
Product p2 = new Product("F&I", 2, "Mitschriften", 5.00, "Mitschriften aus dem WS16/17 in F&I!");
Product p3 = new Product("Übungen Eidip", 3,"Lösungen" , 10.50, "Lösungen zu alten Eidip Aufgaben!");
private ProductSearch(){
}
public static ProductSearch search = null;
public static ProductSearch getInstance(){
if(search== null){
search = new ProductSearch();
}
return search;
}
public List<Product> getProductByTyp(String typ){
ArrayList<Product> liste = new ArrayList<Product> ();
if(typ.equals("Nachhilfe")){
liste.add(p1);
}
if(typ.equals("Mitschriften")){
liste.add(p2);
}
if(typ.equals("Lösungen")){
liste.add(p3);
}
return liste;
}
}
No preview for this file type
No preview for this file type
org\s4s\MyUI$MyUIServlet.class
org\s4s\modell\objects\dto\Product.class
org\s4s\process\controll\ProductSearch.class
org\s4s\MyUI.class
org\s4s\MyUI$MyUIServlet.class
org\s4s\MyUI$1.class
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