diff --git a/pom.xml b/pom.xml index 666016a..36a587e 100755 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 com.github.adminfaces admin-starter @@ -11,7 +11,7 @@ UTF-8 - 1.0.0 + 1.0.2 @@ -37,6 +37,11 @@ 6.1.1 + + org.omnifaces + omnifaces + 3.2 + @@ -93,6 +98,11 @@ ejb ${version.wildfly-swarm} + + org.omnifaces + omnifaces + 2.1 + diff --git a/src/main/java/com/github/adminfaces/starter/bean/CarListMB.java b/src/main/java/com/github/adminfaces/starter/bean/CarListMB.java index 3df4ee3..0f1aa61 100644 --- a/src/main/java/com/github/adminfaces/starter/bean/CarListMB.java +++ b/src/main/java/com/github/adminfaces/starter/bean/CarListMB.java @@ -36,7 +36,7 @@ public class CarListMB implements Serializable { List selectedCars; //cars selected in checkbox column List filteredValue;// datatable filteredValue attribute (column filters) - + @PostConstruct public void initDataModel() { cars = new LazyDataModel() { @@ -68,6 +68,8 @@ public Car getRowData(String key) { return carService.findById(new Integer(key)); } }; + + } public void clear() { @@ -135,4 +137,5 @@ public Integer getId() { public void setId(Integer id) { this.id = id; } + } diff --git a/src/main/java/com/github/adminfaces/starter/bean/IndexMB.java b/src/main/java/com/github/adminfaces/starter/bean/IndexMB.java new file mode 100644 index 0000000..16d1ea7 --- /dev/null +++ b/src/main/java/com/github/adminfaces/starter/bean/IndexMB.java @@ -0,0 +1,86 @@ +/* + * 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 com.github.adminfaces.starter.bean; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.IntStream; +import javax.annotation.PostConstruct; +import javax.inject.Named; +import org.omnifaces.cdi.ViewScoped; + +/** + * + * @author rmpestano + */ +@Named +@ViewScoped +public class IndexMB implements Serializable { + + List itens; + + List subItens; + + List filteredSubItens = new ArrayList<>(); + + String selectedItem; + + String selectedSubItem; + + @PostConstruct + public void init() { + itens = new ArrayList<>(15); + subItens = new ArrayList<>(150); + + IntStream.rangeClosed(1, 15) + .forEach(i -> { + itens.add("item " + i); + IntStream.rangeClosed(1, 10) + .forEach(j -> { + subItens.add("subitem " + i + "" + j); + }); + }); + } + + public List getItens() { + return itens; + } + + public void setItens(List itens) { + this.itens = itens; + } + + public List getFilteredSubItens() { + return filteredSubItens; + } + + public void setFilteredSubItens(List filteredSubItens) { + this.filteredSubItens = filteredSubItens; + } + + public String getSelectedItem() { + return selectedItem; + } + + public void setSelectedItem(String selectedItem) { + this.selectedItem = selectedItem; + } + + public String getSelectedSubItem() { + return selectedSubItem; + } + + public void setSelectedSubItem(String selectedSubItem) { + this.selectedSubItem = selectedSubItem; + } + + public void onItemChange() { + filteredSubItens.clear(); + subItens.stream().filter(subItem -> selectedItem != null && subItem.contains(selectedItem)) + .forEach(filteredSubItens::add); + } +} diff --git a/src/main/java/com/github/adminfaces/starter/util/Utils.java b/src/main/java/com/github/adminfaces/starter/util/Utils.java index 88847a3..e495d3b 100644 --- a/src/main/java/com/github/adminfaces/starter/util/Utils.java +++ b/src/main/java/com/github/adminfaces/starter/util/Utils.java @@ -11,21 +11,22 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.IntStream; +import javax.inject.Named; /** * Created by rmpestano on 07/02/17. */ +@Named @ApplicationScoped public class Utils implements Serializable { private List cars; - @PostConstruct public void init() { cars = new ArrayList<>(); IntStream.rangeClosed(1, 50) - .forEach(i -> cars.add(create(i))); + .forEach(i -> cars.add(create(i))); } private static Car create(int i) { diff --git a/src/main/webapp/index.xhtml b/src/main/webapp/index.xhtml index 6746cbc..5409d47 100644 --- a/src/main/webapp/index.xhtml +++ b/src/main/webapp/index.xhtml @@ -2,7 +2,9 @@ + template="#{layoutMB.template}" + xmlns:f="http://xmlns.jcp.org/jsf/core" + xmlns:h="http://xmlns.jcp.org/jsf/html"> @@ -19,6 +21,39 @@ +
+ + + +
+
+
+ +
+
+ + + + + +
+
+ +
+
+ +
+
+ + + + +
+
+
+
+
+