├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── README.adoc ├── mvnw ├── mvnw.cmd ├── pom.xml ├── run.cmd ├── run.sh ├── src └── main │ ├── java │ └── com │ │ └── github │ │ └── adminfaces │ │ └── starter │ │ ├── AdminBootApplication.java │ │ ├── AdminBootMain.java │ │ ├── bean │ │ ├── CarFormMB.java │ │ └── CarListMB.java │ │ ├── infra │ │ ├── converter │ │ │ └── EntityConverter.java │ │ ├── model │ │ │ ├── Filter.java │ │ │ └── SortOrder.java │ │ └── security │ │ │ └── LogonMB.java │ │ ├── model │ │ └── Car.java │ │ ├── service │ │ └── CarService.java │ │ └── util │ │ └── Utils.java │ ├── resources │ ├── admin-config.properties │ └── starter.properties │ └── webapp │ ├── WEB-INF │ ├── beans.xml │ ├── faces-config.xml │ ├── glassfish-web.xml │ ├── jboss-web.xml │ ├── templates │ │ ├── template-top.xhtml │ │ └── template.xhtml │ └── web.xml │ ├── car-form.xhtml │ ├── car-list.xhtml │ ├── includes │ ├── controlsidebar-tabs-content.xhtml │ ├── menu.xhtml │ ├── menubar.xhtml │ └── top-bar.xhtml │ ├── index.xhtml │ ├── login.xhtml │ └── resources │ ├── css │ └── starter.css │ ├── favicon │ ├── favicon-144x144.png │ ├── favicon-16x16.png │ ├── favicon-196x196.png │ ├── favicon-32x32.png │ ├── favicon-96x96.png │ └── favicon.ico │ └── images │ ├── login-bg-mobile.jpeg │ └── login-bg.jpg ├── starter1.png ├── starter2.png ├── starter3.png └── starter4.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | 3 | .project 4 | 5 | .classpath 6 | 7 | .settings/ 8 | 9 | 10 | 11 | # IntelliJ 12 | 13 | *.iml 14 | 15 | *.ipr 16 | 17 | *.iws 18 | 19 | .idea 20 | 21 | .settings 22 | 23 | 24 | 25 | # Maven 26 | 27 | target/ 28 | 29 | 30 | 31 | #Gradle 32 | 33 | .gradle 34 | 35 | 36 | 37 | # TestNG 38 | 39 | test-output/ 40 | 41 | 42 | 43 | 44 | *.log 45 | 46 | #linux te files 47 | *~ 48 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adminfaces/admin-starter-springboot/a3b41535e1490e5397b328340f12e852bfeacd76/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = AdminFaces Starter SpringBoot project 2 | 3 | 4 | A simple project to get you started with https://github.com/adminfaces[AdminFaces^]. 5 | 6 | .Login page 7 | image:starter1.png[link="https://github.com/adminfaces/admin-starter/blob/master/starter1.png"] 8 | 9 | .Car list 10 | image:starter2.png[link="https://raw.githubusercontent.com/adminfaces/admin-starter/master/starter2.png"] 11 | 12 | .Car form 13 | image:starter3.png[link="https://raw.githubusercontent.com/adminfaces/admin-starter/master/starter3.png"] 14 | 15 | .Car form responsive 16 | image:starter4.png[link="https://raw.githubusercontent.com/adminfaces/admin-starter/master/starter4.png"] 17 | 18 | == Running 19 | 20 | This starter runs via *SpringBoot* using the `maven` command: 21 | 22 | 23 | `mvn spring-boot:run` *or* 24 | 25 | `mvn clean package && java -jar target/admin-starter.war` *or* 26 | 27 | `./run.sh/run.cmd` 28 | 29 | 30 | The application will be available at http://localhost:8080/admin-starter 31 | 32 | == Maven archetype 33 | 34 | We have https://github.com/adminfaces/admin-starter-springboot-archetype[a maven arcuetype^] for this project and it is available on the maven central, you can generate the project with: 35 | 36 | ---- 37 | mvn archetype:generate -Dfilter=com.github.adminfaces:admin-starter-springboot-archetype 38 | ---- 39 | 40 | == Demo 41 | 42 | A live demo is available on https://adminfaces.github.io/admin-showcase/[Openshift here^] 43 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # 58 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look 59 | # for the new JDKs provided by Oracle. 60 | # 61 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then 62 | # 63 | # Apple JDKs 64 | # 65 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home 66 | fi 67 | 68 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then 69 | # 70 | # Apple JDKs 71 | # 72 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 73 | fi 74 | 75 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then 76 | # 77 | # Oracle JDKs 78 | # 79 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 80 | fi 81 | 82 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then 83 | # 84 | # Apple JDKs 85 | # 86 | export JAVA_HOME=`/usr/libexec/java_home` 87 | fi 88 | ;; 89 | esac 90 | 91 | if [ -z "$JAVA_HOME" ] ; then 92 | if [ -r /etc/gentoo-release ] ; then 93 | JAVA_HOME=`java-config --jre-home` 94 | fi 95 | fi 96 | 97 | if [ -z "$M2_HOME" ] ; then 98 | ## resolve links - $0 may be a link to maven's home 99 | PRG="$0" 100 | 101 | # need this for relative symlinks 102 | while [ -h "$PRG" ] ; do 103 | ls=`ls -ld "$PRG"` 104 | link=`expr "$ls" : '.*-> \(.*\)$'` 105 | if expr "$link" : '/.*' > /dev/null; then 106 | PRG="$link" 107 | else 108 | PRG="`dirname "$PRG"`/$link" 109 | fi 110 | done 111 | 112 | saveddir=`pwd` 113 | 114 | M2_HOME=`dirname "$PRG"`/.. 115 | 116 | # make it fully qualified 117 | M2_HOME=`cd "$M2_HOME" && pwd` 118 | 119 | cd "$saveddir" 120 | # echo Using m2 at $M2_HOME 121 | fi 122 | 123 | # For Cygwin, ensure paths are in UNIX format before anything is touched 124 | if $cygwin ; then 125 | [ -n "$M2_HOME" ] && 126 | M2_HOME=`cygpath --unix "$M2_HOME"` 127 | [ -n "$JAVA_HOME" ] && 128 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 129 | [ -n "$CLASSPATH" ] && 130 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 131 | fi 132 | 133 | # For Migwn, ensure paths are in UNIX format before anything is touched 134 | if $mingw ; then 135 | [ -n "$M2_HOME" ] && 136 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 137 | [ -n "$JAVA_HOME" ] && 138 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 139 | # TODO classpath? 140 | fi 141 | 142 | if [ -z "$JAVA_HOME" ]; then 143 | javaExecutable="`which javac`" 144 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 145 | # readlink(1) is not available as standard on Solaris 10. 146 | readLink=`which readlink` 147 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 148 | if $darwin ; then 149 | javaHome="`dirname \"$javaExecutable\"`" 150 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 151 | else 152 | javaExecutable="`readlink -f \"$javaExecutable\"`" 153 | fi 154 | javaHome="`dirname \"$javaExecutable\"`" 155 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 156 | JAVA_HOME="$javaHome" 157 | export JAVA_HOME 158 | fi 159 | fi 160 | fi 161 | 162 | if [ -z "$JAVACMD" ] ; then 163 | if [ -n "$JAVA_HOME" ] ; then 164 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 165 | # IBM's JDK on AIX uses strange locations for the executables 166 | JAVACMD="$JAVA_HOME/jre/sh/java" 167 | else 168 | JAVACMD="$JAVA_HOME/bin/java" 169 | fi 170 | else 171 | JAVACMD="`which java`" 172 | fi 173 | fi 174 | 175 | if [ ! -x "$JAVACMD" ] ; then 176 | echo "Error: JAVA_HOME is not defined correctly." >&2 177 | echo " We cannot execute $JAVACMD" >&2 178 | exit 1 179 | fi 180 | 181 | if [ -z "$JAVA_HOME" ] ; then 182 | echo "Warning: JAVA_HOME environment variable is not set." 183 | fi 184 | 185 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 186 | 187 | # traverses directory structure from process work directory to filesystem root 188 | # first directory with .mvn subdirectory is considered project base directory 189 | find_maven_basedir() { 190 | local basedir=$(pwd) 191 | local wdir=$(pwd) 192 | while [ "$wdir" != '/' ] ; do 193 | if [ -d "$wdir"/.mvn ] ; then 194 | basedir=$wdir 195 | break 196 | fi 197 | wdir=$(cd "$wdir/.."; pwd) 198 | done 199 | echo "${basedir}" 200 | } 201 | 202 | # concatenates all lines of a file 203 | concat_lines() { 204 | if [ -f "$1" ]; then 205 | echo "$(tr -s '\n' ' ' < "$1")" 206 | fi 207 | } 208 | 209 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} 210 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 211 | 212 | # For Cygwin, switch paths to Windows format before running java 213 | if $cygwin; then 214 | [ -n "$M2_HOME" ] && 215 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 216 | [ -n "$JAVA_HOME" ] && 217 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 218 | [ -n "$CLASSPATH" ] && 219 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 220 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 221 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 222 | fi 223 | 224 | # Provide a "standardized" way to retrieve the CLI args that will 225 | # work with both Windows and non-Windows executions. 226 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 227 | export MAVEN_CMD_LINE_ARGS 228 | 229 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 230 | 231 | # avoid using MAVEN_CMD_LINE_ARGS below since that would loose parameter escaping in $@ 232 | exec "$JAVACMD" \ 233 | $MAVEN_OPTS \ 234 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 235 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 236 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 237 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | set MAVEN_CMD_LINE_ARGS=%MAVEN_CONFIG% %* 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | 121 | set WRAPPER_JAR=""%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"" 122 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 123 | 124 | # avoid using MAVEN_CMD_LINE_ARGS below since that would loose parameter escaping in %* 125 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 126 | if ERRORLEVEL 1 goto error 127 | goto end 128 | 129 | :error 130 | set ERROR_CODE=1 131 | 132 | :end 133 | @endlocal & set ERROR_CODE=%ERROR_CODE% 134 | 135 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 136 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 137 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 138 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 139 | :skipRcPost 140 | 141 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 142 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 143 | 144 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 145 | 146 | exit /B %ERROR_CODE% 147 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | com.github.adminfaces 7 | admin-starter 8 | 0.1-SNAPSHOT 9 | war 10 | admin-starter 11 | 12 | 13 | org.joinfaces 14 | joinfaces-parent 15 | 3.2.6 16 | 17 | 18 | 19 | 20 | UTF-8 21 | 2.3.4 22 | 23 | 24 | 25 | 26 | 27 | com.github.adminfaces 28 | admin-template 29 | 1.0.2 30 | 31 | 32 | com.github.adminfaces 33 | admin-theme 34 | 1.0.2 35 | 36 | 37 | org.primefaces 38 | primefaces 39 | 7.0 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-starter 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-starter-test 52 | test 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-devtools 57 | 58 | 59 | org.joinfaces 60 | adminfaces-spring-boot-starter 61 | 62 | 63 | 64 | admin-starter 65 | 66 | 67 | true 68 | src/main/resources 69 | 70 | 71 | src/main/docs 72 | true 73 | 74 | 75 | 76 | 77 | true 78 | src/test/resources 79 | 80 | 81 | src/test/java/ 82 | 83 | 84 | 85 | 86 | org.springframework.boot 87 | spring-boot-maven-plugin 88 | 89 | 90 | 91 | 92 | 93 | prime-repo 94 | PrimeFaces Maven Repository 95 | http://repository.primefaces.org 96 | default 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /run.cmd: -------------------------------------------------------------------------------- 1 | mvnw.cmd spring-boot:run -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./mvnw spring-boot:run -------------------------------------------------------------------------------- /src/main/java/com/github/adminfaces/starter/AdminBootApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.adminfaces.starter; 18 | 19 | import com.github.adminfaces.starter.model.Car; 20 | import com.github.adminfaces.starter.util.Utils; 21 | import java.util.List; 22 | import javax.inject.Inject; 23 | import org.springframework.boot.autoconfigure.SpringBootApplication; 24 | import org.springframework.context.annotation.Bean; 25 | 26 | /** 27 | * @author rmpestano 28 | */ 29 | @SpringBootApplication 30 | public class AdminBootApplication { 31 | @Inject 32 | private Utils utils; 33 | 34 | @Bean 35 | public List getCars() { 36 | return utils.getCars(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/github/adminfaces/starter/AdminBootMain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.adminfaces.starter; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | 21 | /** 22 | * @author rmpestano 23 | */ 24 | public class AdminBootMain { 25 | 26 | protected AdminBootMain() { 27 | } 28 | 29 | public static void main(String[] args) { 30 | SpringApplication.run(AdminBootApplication.class, args); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/github/adminfaces/starter/bean/CarFormMB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package com.github.adminfaces.starter.bean; 6 | 7 | import com.github.adminfaces.starter.model.Car; 8 | import com.github.adminfaces.starter.service.CarService; 9 | import javax.faces.view.ViewScoped; 10 | import org.omnifaces.util.Faces; 11 | 12 | import javax.inject.Inject; 13 | import javax.inject.Named; 14 | import java.io.IOException; 15 | import java.io.Serializable; 16 | 17 | import static com.github.adminfaces.starter.util.Utils.addDetailMessage; 18 | import static com.github.adminfaces.template.util.Assert.has; 19 | 20 | /** 21 | * @author rmpestano 22 | */ 23 | @Named 24 | @ViewScoped 25 | public class CarFormMB implements Serializable { 26 | 27 | 28 | private Integer id; 29 | private Car car; 30 | 31 | 32 | @Inject 33 | CarService carService; 34 | 35 | public void init() { 36 | if(Faces.isAjaxRequest()){ 37 | return; 38 | } 39 | if (has(id)) { 40 | car = carService.findById(id); 41 | } else { 42 | car = new Car(); 43 | } 44 | } 45 | 46 | public Integer getId() { 47 | return id; 48 | } 49 | 50 | public void setId(Integer id) { 51 | this.id = id; 52 | } 53 | 54 | public Car getCar() { 55 | return car; 56 | } 57 | 58 | public void setCar(Car car) { 59 | this.car = car; 60 | } 61 | 62 | 63 | public void remove() throws IOException { 64 | if (has(car) && has(car.getId())) { 65 | carService.remove(car); 66 | addDetailMessage("Car " + car.getModel() 67 | + " removed successfully"); 68 | Faces.getFlash().setKeepMessages(true); 69 | Faces.redirect("car-list.jsf"); 70 | } 71 | } 72 | 73 | public void save() { 74 | String msg; 75 | if (car.getId() == null) { 76 | carService.insert(car); 77 | msg = "Car " + car.getModel() + " created successfully"; 78 | } else { 79 | carService.update(car); 80 | msg = "Car " + car.getModel() + " updated successfully"; 81 | } 82 | addDetailMessage(msg); 83 | } 84 | 85 | public void clear() { 86 | car = new Car(); 87 | id = null; 88 | } 89 | 90 | public boolean isNew() { 91 | return car == null || car.getId() == null; 92 | } 93 | 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/github/adminfaces/starter/bean/CarListMB.java: -------------------------------------------------------------------------------- 1 | package com.github.adminfaces.starter.bean; 2 | 3 | import com.github.adminfaces.starter.infra.model.Filter; 4 | import com.github.adminfaces.starter.model.Car; 5 | import com.github.adminfaces.starter.service.CarService; 6 | import com.github.adminfaces.template.exception.BusinessException; 7 | import javax.faces.view.ViewScoped; 8 | import org.primefaces.model.LazyDataModel; 9 | import org.primefaces.model.SortOrder; 10 | 11 | import javax.annotation.PostConstruct; 12 | import javax.inject.Inject; 13 | import javax.inject.Named; 14 | import java.io.Serializable; 15 | import java.util.List; 16 | import java.util.Map; 17 | 18 | import static com.github.adminfaces.starter.util.Utils.addDetailMessage; 19 | 20 | /** 21 | * Created by rmpestano on 12/02/17. 22 | */ 23 | @Named 24 | @ViewScoped 25 | public class CarListMB implements Serializable { 26 | 27 | @Inject 28 | CarService carService; 29 | 30 | Integer id; 31 | 32 | LazyDataModel cars; 33 | 34 | Filter filter = new Filter<>(new Car()); 35 | 36 | List selectedCars; //cars selected in checkbox column 37 | 38 | List filteredValue;// datatable filteredValue attribute (column filters) 39 | 40 | @PostConstruct 41 | public void initDataModel() { 42 | cars = new LazyDataModel() { 43 | @Override 44 | public List load(int first, int pageSize, 45 | String sortField, SortOrder sortOrder, 46 | Map filters) { 47 | com.github.adminfaces.starter.infra.model.SortOrder order = null; 48 | if (sortOrder != null) { 49 | order = sortOrder.equals(SortOrder.ASCENDING) ? com.github.adminfaces.starter.infra.model.SortOrder.ASCENDING 50 | : sortOrder.equals(SortOrder.DESCENDING) ? com.github.adminfaces.starter.infra.model.SortOrder.DESCENDING 51 | : com.github.adminfaces.starter.infra.model.SortOrder.UNSORTED; 52 | } 53 | filter.setFirst(first).setPageSize(pageSize) 54 | .setSortField(sortField).setSortOrder(order) 55 | .setParams(filters); 56 | List list = carService.paginate(filter); 57 | setRowCount((int) carService.count(filter)); 58 | return list; 59 | } 60 | 61 | @Override 62 | public int getRowCount() { 63 | return super.getRowCount(); 64 | } 65 | 66 | @Override 67 | public Car getRowData(String key) { 68 | return carService.findById(new Integer(key)); 69 | } 70 | }; 71 | } 72 | 73 | public void clear() { 74 | filter = new Filter(new Car()); 75 | } 76 | 77 | public List completeModel(String query) { 78 | List result = carService.getModels(query); 79 | return result; 80 | } 81 | 82 | public void findCarById(Integer id) { 83 | if (id == null) { 84 | throw new BusinessException("Provide Car ID to load"); 85 | } 86 | selectedCars.add(carService.findById(id)); 87 | } 88 | 89 | public void delete() { 90 | int numCars = 0; 91 | for (Car selectedCar : selectedCars) { 92 | numCars++; 93 | carService.remove(selectedCar); 94 | } 95 | selectedCars.clear(); 96 | addDetailMessage(numCars + " cars deleted successfully!"); 97 | } 98 | 99 | public List getSelectedCars() { 100 | return selectedCars; 101 | } 102 | 103 | public List getFilteredValue() { 104 | return filteredValue; 105 | } 106 | 107 | public void setFilteredValue(List filteredValue) { 108 | this.filteredValue = filteredValue; 109 | } 110 | 111 | public void setSelectedCars(List selectedCars) { 112 | this.selectedCars = selectedCars; 113 | } 114 | 115 | public LazyDataModel getCars() { 116 | return cars; 117 | } 118 | 119 | public void setCars(LazyDataModel cars) { 120 | this.cars = cars; 121 | } 122 | 123 | public Filter getFilter() { 124 | return filter; 125 | } 126 | 127 | public void setFilter(Filter filter) { 128 | this.filter = filter; 129 | } 130 | 131 | public Integer getId() { 132 | return id; 133 | } 134 | 135 | public void setId(Integer id) { 136 | this.id = id; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/main/java/com/github/adminfaces/starter/infra/converter/EntityConverter.java: -------------------------------------------------------------------------------- 1 | package com.github.adminfaces.starter.infra.converter; 2 | 3 | 4 | import javax.faces.component.UIComponent; 5 | import javax.faces.context.FacesContext; 6 | import javax.faces.convert.Converter; 7 | import javax.faces.convert.FacesConverter; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | import java.util.Map.Entry; 11 | import java.util.Set; 12 | import java.util.UUID; 13 | 14 | @FacesConverter(value = "entityConverter") 15 | public class EntityConverter implements Converter { 16 | 17 | @Override 18 | public String getAsString(FacesContext context, UIComponent component, Object entity) { 19 | if (entity == null || "".equals(entity)) { 20 | return null; 21 | } 22 | 23 | if (!getEntityMap(context).containsKey(entity)) { 24 | String uuid = UUID.randomUUID().toString(); 25 | getEntityMap(context).put(entity, uuid); 26 | return uuid; 27 | } else { 28 | return getEntityMap(context).get(entity); 29 | } 30 | } 31 | 32 | @Override 33 | public Object getAsObject(FacesContext context, UIComponent component, String uuid) { 34 | Set> entries = getEntityMap(context).entrySet(); 35 | for (Entry entry : entries) { 36 | if (entry.getValue().equals(uuid)) { 37 | return entry.getKey(); 38 | } 39 | } 40 | return null; 41 | } 42 | 43 | @SuppressWarnings("unchecked") 44 | private Map getEntityMap(FacesContext context) { 45 | Map viewMap = context.getViewRoot().getViewMap(); 46 | Map entities = (Map) viewMap.get("entities"); 47 | if (entities == null) { 48 | entities = new HashMap<>(); 49 | viewMap.put("entities", entities); 50 | } 51 | return entities; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/github/adminfaces/starter/infra/model/Filter.java: -------------------------------------------------------------------------------- 1 | package com.github.adminfaces.starter.infra.model; 2 | 3 | 4 | import java.io.Serializable; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | /** 9 | * Created by rmpestano on 9/7/14. 10 | * class which holds database pagination metadata 11 | */ 12 | public class Filter { 13 | private T entity; 14 | private int first; 15 | private int pageSize; 16 | private String sortField; 17 | private SortOrder sortOrder; 18 | private Map params = new HashMap(); 19 | 20 | 21 | public Filter() { 22 | } 23 | 24 | public Filter(T entity) { 25 | this.entity = entity; 26 | } 27 | 28 | public Filter setFirst(int first) { 29 | this.first = first; 30 | return this; 31 | } 32 | 33 | public int getFirst() { 34 | return first; 35 | } 36 | 37 | public Filter setPageSize(int pageSize) { 38 | this.pageSize = pageSize; 39 | return this; 40 | } 41 | 42 | public int getPageSize() { 43 | return pageSize; 44 | } 45 | 46 | public Filter setSortField(String sortField) { 47 | this.sortField = sortField; 48 | return this; 49 | } 50 | 51 | public String getSortField() { 52 | return sortField; 53 | } 54 | 55 | public Filter setSortOrder(SortOrder sortOrder) { 56 | this.sortOrder = sortOrder; 57 | return this; 58 | } 59 | 60 | public SortOrder getSortOrder() { 61 | return sortOrder; 62 | } 63 | 64 | public Filter setParams(Map params) { 65 | this.params = params; 66 | return this; 67 | } 68 | 69 | public Map getParams() { 70 | return params; 71 | } 72 | 73 | public T getEntity() { 74 | return entity; 75 | } 76 | 77 | public Filter setEntity(T entity) { 78 | this.entity = entity; 79 | return this; 80 | } 81 | 82 | public Filter addParam(String key, Object value) { 83 | getParams().put(key, value); 84 | return this; 85 | } 86 | 87 | public boolean hasParam(String key) { 88 | return getParams().containsKey(key) && getParam(key) != null; 89 | } 90 | 91 | public Object getParam(String key) { 92 | return getParams().get(key); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/github/adminfaces/starter/infra/model/SortOrder.java: -------------------------------------------------------------------------------- 1 | package com.github.adminfaces.starter.infra.model; 2 | 3 | /** 4 | * Created by rmpestano on 10/31/14. 5 | */ 6 | public enum SortOrder { 7 | 8 | ASCENDING, DESCENDING, UNSORTED; 9 | 10 | public boolean isAscending() { 11 | return ASCENDING.equals(this); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/github/adminfaces/starter/infra/security/LogonMB.java: -------------------------------------------------------------------------------- 1 | package com.github.adminfaces.starter.infra.security; 2 | 3 | import com.github.adminfaces.template.session.AdminSession; 4 | import org.omnifaces.util.Faces; 5 | 6 | import javax.enterprise.context.SessionScoped; 7 | import javax.enterprise.inject.Specializes; 8 | import javax.faces.context.FacesContext; 9 | import javax.inject.Named; 10 | import java.io.IOException; 11 | import java.io.Serializable; 12 | 13 | import static com.github.adminfaces.starter.util.Utils.addDetailMessage; 14 | import org.springframework.context.annotation.Primary; 15 | import org.springframework.context.annotation.Scope; 16 | import org.springframework.context.annotation.ScopedProxyMode; 17 | 18 | /** 19 | * Created by rmpestano on 12/20/14. 20 | * 21 | * This is just a login example. 22 | * 23 | * AdminSession uses isLoggedIn to determine if user must be redirect to login page or not. 24 | * By default AdminSession isLoggedIn always resolves to true so it will not try to redirect user. 25 | * 26 | * If you already have your authorization mechanism which controls when user must be redirect to initial page or logon 27 | * you can skip this class. 28 | */ 29 | @Named 30 | @SessionScoped 31 | @Specializes 32 | @Primary 33 | @Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS) 34 | public class LogonMB extends AdminSession implements Serializable { 35 | 36 | private String currentUser; 37 | private String email; 38 | private String password; 39 | private boolean remember; 40 | 41 | 42 | public void login() throws IOException { 43 | currentUser = email; 44 | addDetailMessage("Logged in successfully as " + email + ""); 45 | Faces.getExternalContext().getFlash().setKeepMessages(true); 46 | Faces.redirect("index.jsf"); 47 | } 48 | 49 | @Override 50 | public boolean isLoggedIn() { 51 | 52 | return currentUser != null; 53 | } 54 | 55 | public String getEmail() { 56 | return email; 57 | } 58 | 59 | public void setEmail(String email) { 60 | this.email = email; 61 | } 62 | 63 | public String getPassword() { 64 | return password; 65 | } 66 | 67 | public void setPassword(String password) { 68 | this.password = password; 69 | } 70 | 71 | public boolean isRemember() { 72 | return remember; 73 | } 74 | 75 | public void setRemember(boolean remember) { 76 | this.remember = remember; 77 | } 78 | 79 | public String getCurrentUser() { 80 | return currentUser; 81 | } 82 | 83 | public void setCurrentUser(String currentUser) { 84 | this.currentUser = currentUser; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/github/adminfaces/starter/model/Car.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package com.github.adminfaces.starter.model; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @author rmpestano 11 | */ 12 | public class Car implements Serializable, Comparable { 13 | 14 | private Integer id; 15 | private String model; 16 | private String name; 17 | private Double price; 18 | 19 | public Car() { 20 | } 21 | 22 | public Car(Integer id) { 23 | this.id = id; 24 | } 25 | 26 | public String getModel() { 27 | return model; 28 | } 29 | 30 | public Double getPrice() { 31 | return price; 32 | } 33 | 34 | public Integer getId() { 35 | return id; 36 | } 37 | 38 | public String getName() { 39 | return name; 40 | } 41 | 42 | public void setModel(String model) { 43 | this.model = model; 44 | } 45 | 46 | public void setName(String name) { 47 | this.name = name; 48 | } 49 | 50 | public void setPrice(Double price) { 51 | this.price = price; 52 | } 53 | 54 | public void setId(Integer id) { 55 | this.id = id; 56 | } 57 | 58 | public Car model(String model) { 59 | this.model = model; 60 | return this; 61 | } 62 | 63 | public Car price(Double price) { 64 | this.price = price; 65 | return this; 66 | } 67 | 68 | public Car name(String name) { 69 | this.name = name; 70 | return this; 71 | } 72 | 73 | @Override 74 | public int hashCode() { 75 | final int prime = 31; 76 | int result = 1; 77 | result = prime * result + ((id == null) ? 0 : id.hashCode()); 78 | return result; 79 | } 80 | 81 | @Override 82 | public boolean equals(Object obj) { 83 | if (this == obj) 84 | return true; 85 | if (obj == null) 86 | return false; 87 | if (getClass() != obj.getClass()) 88 | return false; 89 | Car other = (Car) obj; 90 | if (id == null) { 91 | if (other.id != null) 92 | return false; 93 | } else if (!id.equals(other.id)) 94 | return false; 95 | return true; 96 | } 97 | 98 | public boolean hasModel() { 99 | return model != null && !"".equals(model.trim()); 100 | } 101 | 102 | public boolean hasName() { 103 | return name != null && !"".equals(name.trim()); 104 | } 105 | 106 | @Override 107 | public int compareTo(Car o) { 108 | return this.id.compareTo(o.getId()); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/com/github/adminfaces/starter/service/CarService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package com.github.adminfaces.starter.service; 6 | 7 | import com.github.adminfaces.starter.infra.model.Filter; 8 | import com.github.adminfaces.starter.infra.model.SortOrder; 9 | import com.github.adminfaces.starter.model.Car; 10 | import com.github.adminfaces.template.exception.BusinessException; 11 | 12 | import javax.inject.Inject; 13 | import java.io.Serializable; 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | import java.util.function.Predicate; 17 | import java.util.stream.Collectors; 18 | 19 | import static com.github.adminfaces.template.util.Assert.has; 20 | import org.springframework.stereotype.Component; 21 | 22 | /** 23 | * @author rmpestano 24 | * Car Business logic 25 | */ 26 | @Component 27 | public class CarService implements Serializable { 28 | 29 | @Inject 30 | List allCars; 31 | 32 | public List listByModel(String model) { 33 | return allCars.stream() 34 | .filter(c -> c.getModel().equalsIgnoreCase(model)) 35 | .collect(Collectors.toList()); 36 | 37 | } 38 | 39 | public List paginate(Filter filter) { 40 | List pagedCars = new ArrayList<>(); 41 | if(has(filter.getSortOrder()) && !SortOrder.UNSORTED.equals(filter.getSortOrder())) { 42 | pagedCars = allCars.stream(). 43 | sorted((c1, c2) -> { 44 | if (filter.getSortOrder().isAscending()) { 45 | return c1.getId().compareTo(c2.getId()); 46 | } else { 47 | return c2.getId().compareTo(c1.getId()); 48 | } 49 | }) 50 | .collect(Collectors.toList()); 51 | } 52 | 53 | int page = filter.getFirst() + filter.getPageSize(); 54 | if (filter.getParams().isEmpty()) { 55 | pagedCars = pagedCars.subList(filter.getFirst(), page > allCars.size() ? allCars.size() : page); 56 | return pagedCars; 57 | } 58 | 59 | List> predicates = configFilter(filter); 60 | 61 | List pagedList = allCars.stream().filter(predicates 62 | .stream().reduce(Predicate::or).orElse(t -> true)) 63 | .collect(Collectors.toList()); 64 | 65 | if (page < pagedList.size()) { 66 | pagedList = pagedList.subList(filter.getFirst(), page); 67 | } 68 | 69 | if (has(filter.getSortField())) { 70 | pagedList = pagedList.stream(). 71 | sorted((c1, c2) -> { 72 | boolean asc = SortOrder.ASCENDING.equals(filter.getSortOrder()); 73 | if (asc) { 74 | return c1.getId().compareTo(c2.getId()); 75 | } else { 76 | return c2.getId().compareTo(c1.getId()); 77 | } 78 | }) 79 | .collect(Collectors.toList()); 80 | } 81 | return pagedList; 82 | } 83 | 84 | private List> configFilter(Filter filter) { 85 | List> predicates = new ArrayList<>(); 86 | if (filter.hasParam("id")) { 87 | Predicate idPredicate = (Car c) -> c.getId().equals(filter.getParam("id")); 88 | predicates.add(idPredicate); 89 | } 90 | 91 | if (filter.hasParam("minPrice") && filter.hasParam("maxPrice")) { 92 | Predicate minMaxPricePredicate = (Car c) -> c.getPrice() 93 | >= Double.valueOf((String) filter.getParam("minPrice")) && c.getPrice() 94 | <= Double.valueOf((String) filter.getParam("maxPrice")); 95 | predicates.add(minMaxPricePredicate); 96 | } else if (filter.hasParam("minPrice")) { 97 | Predicate minPricePredicate = (Car c) -> c.getPrice() 98 | >= Double.valueOf((String) filter.getParam("minPrice")); 99 | predicates.add(minPricePredicate); 100 | } else if (filter.hasParam("maxPrice")) { 101 | Predicate maxPricePredicate = (Car c) -> c.getPrice() 102 | <= Double.valueOf((String) filter.getParam("maxPrice")); 103 | predicates.add(maxPricePredicate); 104 | } 105 | 106 | if (has(filter.getEntity())) { 107 | Car filterEntity = filter.getEntity(); 108 | if (has(filterEntity.getModel())) { 109 | Predicate modelPredicate = (Car c) -> c.getModel().toLowerCase().contains(filterEntity.getModel().toLowerCase()); 110 | predicates.add(modelPredicate); 111 | } 112 | 113 | if (has(filterEntity.getPrice())) { 114 | Predicate pricePredicate = (Car c) -> c.getPrice().equals(filterEntity.getPrice()); 115 | predicates.add(pricePredicate); 116 | } 117 | 118 | if (has(filterEntity.getName())) { 119 | Predicate namePredicate = (Car c) -> c.getName().toLowerCase().contains(filterEntity.getName().toLowerCase()); 120 | predicates.add(namePredicate); 121 | } 122 | } 123 | return predicates; 124 | } 125 | 126 | public List getModels(String query) { 127 | return allCars.stream().filter(c -> c.getModel() 128 | .toLowerCase().contains(query.toLowerCase())) 129 | .map(Car::getModel) 130 | .collect(Collectors.toList()); 131 | } 132 | 133 | public void insert(Car car) { 134 | validate(car); 135 | car.setId(allCars.stream() 136 | .mapToInt(c -> c.getId()) 137 | .max() 138 | .getAsInt()+1); 139 | allCars.add(car); 140 | } 141 | 142 | public void validate(Car car) { 143 | BusinessException be = new BusinessException(); 144 | if (!car.hasModel()) { 145 | be.addException(new BusinessException("Car model cannot be empty")); 146 | } 147 | if (!car.hasName()) { 148 | be.addException(new BusinessException("Car name cannot be empty")); 149 | } 150 | 151 | if (!has(car.getPrice())) { 152 | be.addException(new BusinessException("Car price cannot be empty")); 153 | } 154 | 155 | if (allCars.stream().filter(c -> c.getName().equalsIgnoreCase(car.getName()) 156 | && c.getId() != c.getId()).count() > 0) { 157 | be.addException(new BusinessException("Car name must be unique")); 158 | } 159 | if(has(be.getExceptionList())) { 160 | throw be; 161 | } 162 | } 163 | 164 | 165 | public void remove(Car car) { 166 | allCars.remove(car); 167 | } 168 | 169 | public long count(Filter filter) { 170 | return allCars.stream() 171 | .filter(configFilter(filter).stream() 172 | .reduce(Predicate::or).orElse(t -> true)) 173 | .count(); 174 | } 175 | 176 | public Car findById(Integer id) { 177 | return allCars.stream() 178 | .filter(c -> c.getId().equals(id)) 179 | .findFirst() 180 | .orElseThrow(() -> new BusinessException("Car not found with id " + id)); 181 | } 182 | 183 | public void update(Car car) { 184 | validate(car); 185 | allCars.remove(allCars.indexOf(car)); 186 | allCars.add(car); 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /src/main/java/com/github/adminfaces/starter/util/Utils.java: -------------------------------------------------------------------------------- 1 | package com.github.adminfaces.starter.util; 2 | 3 | import com.github.adminfaces.starter.model.Car; 4 | import org.omnifaces.util.Messages; 5 | 6 | import javax.annotation.PostConstruct; 7 | import javax.enterprise.context.ApplicationScoped; 8 | import javax.enterprise.inject.Produces; 9 | import javax.faces.application.FacesMessage; 10 | import java.io.Serializable; 11 | import java.util.*; 12 | import java.util.stream.IntStream; 13 | import javax.inject.Named; 14 | 15 | /** 16 | * Created by rmpestano on 07/02/17. 17 | */ 18 | @Named 19 | @ApplicationScoped 20 | public class Utils implements Serializable { 21 | 22 | private List cars; 23 | 24 | 25 | @PostConstruct 26 | public void init() { 27 | cars = new ArrayList<>(); 28 | IntStream.rangeClosed(1, 50) 29 | .forEach(i -> cars.add(create(i))); 30 | } 31 | 32 | private static Car create(int i) { 33 | return new Car(i).model("model " + i).name("name" + i).price(Double.valueOf(i)); 34 | } 35 | 36 | public static void addDetailMessage(String message) { 37 | addDetailMessage(message, null); 38 | } 39 | 40 | public static void addDetailMessage(String message, FacesMessage.Severity severity) { 41 | 42 | FacesMessage facesMessage = Messages.create("").detail(message).get(); 43 | if (severity != null && severity != FacesMessage.SEVERITY_INFO) { 44 | facesMessage.setSeverity(severity); 45 | } 46 | Messages.add(null, facesMessage); 47 | } 48 | 49 | @Produces 50 | public List getCars() { 51 | return cars; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/resources/admin-config.properties: -------------------------------------------------------------------------------- 1 | admin.loginPage=login.jsf 2 | admin.indexPage=index.jsf 3 | admin.renderControlSidebar=true 4 | admin.controlSidebar.showOnMobile=true 5 | -------------------------------------------------------------------------------- /src/main/resources/starter.properties: -------------------------------------------------------------------------------- 1 | starter.version=${project.version} -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | org.omnifaces.resourcehandler.CombinedResourceHandler 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/glassfish-web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /admin-starter 5 | 6 | 7 | 8 | Keep a copy of the generated servlet class' java code. 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/jboss-web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | /admin-starter 4 | 5 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/templates/template-top.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Admin Starter 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Admin Starter 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
  • 35 |
  • 36 |
    37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 47 | Copyright (C) 2017 - AdminFaces 48 | 49 | 50 | 53 | 54 | 55 | 56 | 57 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/templates/template.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Admin Starter 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Admin Starter 22 | 23 | 24 | 25 | Admin 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
  • 39 |
  • 40 |
    41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 51 | AdminFaces - © 2017-2018 52 | 53 | 54 | 57 | 58 | 59 | 60 | 61 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 30 7 | 8 | 9 | 10 | javax.faces.PROJECT_STAGE 11 | Production 12 | 13 | 14 | primefaces.THEME 15 | admin 16 | 17 | 18 | primefaces.FONT_AWESOME 19 | true 20 | 21 | 22 | primefaces.MOVE_SCRIPTS_TO_BOTTOM 23 | true 24 | 25 | 26 | com.sun.faces.numberOfLogicalViews 27 | 6 28 | 29 | 30 | com.sun.faces.numberOfViewsInSession 31 | 6 32 | 33 | 34 | org.omnifaces.VIEW_SCOPE_MANAGER_MAX_ACTIVE_VIEW_SCOPES 35 | 6 36 | 37 | 38 | javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL 39 | true 40 | 41 | 42 | index.html 43 | 44 | 45 | Faces Servlet 46 | javax.faces.webapp.FacesServlet 47 | 1 48 | 49 | 50 | 51 | gzipResponseFilter 52 | org.omnifaces.filter.GzipResponseFilter 53 | 54 | The threshold size in bytes. Must be a number between 0 and 9999. Defaults to 150. 55 | 56 | threshold 57 | 200 58 | 59 | 60 | 61 | gzipResponseFilter 62 | Faces Servlet 63 | REQUEST 64 | ERROR 65 | 66 | 67 | 68 | Faces Servlet 69 | *.jsf 70 | 71 | 72 | 403 73 | /403.jsf 74 | 75 | 76 | com.github.adminfaces.template.exception.AccessDeniedException 77 | /403.jsf 78 | 79 | 80 | 404 81 | /404.jsf 82 | 83 | 84 | 500 85 | /500.jsf 86 | 87 | 88 | java.lang.Throwable 89 | /500.jsf 90 | 91 | 92 | javax.faces.application.ViewExpiredException 93 | /expired.jsf 94 | 95 | 96 | javax.persistence.OptimisticLockException 97 | /optimistic.jsf 98 | 99 | 100 | ico 101 | image/x-icon 102 | 103 | 104 | woff 105 | application/font-woff 106 | 107 | 108 | woff2 109 | application/font-woff2 110 | 111 | 112 | ttf 113 | application/font-sfnt 114 | 115 | 116 | eot 117 | application/vnd.ms-fontobject 118 | 119 | 120 | otf 121 | font/opentype 122 | 123 | 124 | 125 | svg 126 | image/svg+xml 127 | 128 | 129 | -------------------------------------------------------------------------------- /src/main/webapp/car-form.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Car form 17 | 18 | 19 | 20 | 21 | 22 | 23 | 45 | 48 | 51 | 53 | 55 | 56 | 57 | 58 | 61 | 62 | 63 |
    64 | 65 |
    66 |
    67 |
    68 | 69 |
    70 |
    71 | 73 | 74 | 75 | 76 |
    77 |
    78 |
    79 |
    80 | 81 |
    82 |
    83 | 84 | 85 | 86 | 87 |
    88 |
    89 |
    90 |
    91 | 92 |
    93 |
    94 | 95 | 96 | 97 | 98 |
    99 |
    100 |
    101 |
    102 | 103 |
    104 |
    105 | 106 | 107 | 108 | 109 |
    110 |
    111 |
    112 | 113 |
    114 | 117 | 120 | 122 | 124 | 125 | 126 | 127 | 130 | 131 |
    132 |
    133 | 134 | 135 | 137 | 139 | 140 |
    141 | 142 | 143 |
    144 | 145 |
    146 | -------------------------------------------------------------------------------- /src/main/webapp/car-list.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 16 | 17 | 18 | 19 | Find cars by name, price and model 20 | 21 | 22 | 23 | 24 |
    25 |
    26 | 42 | 43 | 46 | 50 | 51 | 52 | 57 | 58 | 59 | 60 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Find Car by id: 77 | 78 | 85 | 86 | 87 | 88 | 90 | 91 | 94 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | #{c.name} 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | #{c.price} 119 | 120 | 121 |
    122 |
    123 | 124 | 126 | 128 | 129 |
    130 | 131 | 132 | 133 | 135 | 137 | ID: #{car.id} - Name: #{car.name} - Model: #{car.model} 138 | 139 | 140 | 141 |
    142 | 143 |
    144 | -------------------------------------------------------------------------------- /src/main/webapp/includes/controlsidebar-tabs-content.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 110 | 111 |
    112 |
    113 |

    General Settings

    114 | 115 |
    116 | 120 | 121 |

    122 | Some information about this general settings option 123 |

    124 |
    125 | 126 |
    127 | 131 | 132 |

    133 | Other sets of options are available 134 |

    135 |
    136 | 137 |
    138 | 142 | 143 |

    144 | Allow the user to show his name in blog posts 145 |

    146 |
    147 | 148 |

    Chat Settings

    149 | 150 |
    151 | 155 |
    156 | 157 |
    158 | 162 |
    163 | 164 |
    165 | 170 |
    171 |
    172 |
    173 | 174 |
    -------------------------------------------------------------------------------- /src/main/webapp/includes/menu.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 24 | 25 | -------------------------------------------------------------------------------- /src/main/webapp/includes/menubar.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 38 | 39 | -------------------------------------------------------------------------------- /src/main/webapp/includes/top-bar.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/main/webapp/index.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

    13 | Welcome to the AdminFaces SpringBoot Starter Project! 16 |
    17 | Integrating , and 19 | into your 20 | application. 21 | 22 |

    23 | 24 |
    25 | 26 | 27 |
    28 | -------------------------------------------------------------------------------- /src/main/webapp/login.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | Admin Starter 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 77 | 78 | 80 | 81 | 82 | 83 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /src/main/webapp/resources/css/starter.css: -------------------------------------------------------------------------------- 1 | li.header { 2 | text-transform: uppercase; 3 | } 4 | 5 | .sidebar-form { 6 | border-radius: 3px; 7 | border: 1px solid #374850; 8 | margin: 10px 10px; 9 | } 10 | .sidebar-form, .sidebar-menu>li.header { 11 | overflow: hidden; 12 | text-overflow: clip; 13 | } 14 | 15 | #userImage { 16 | float: left; 17 | width: 25px; 18 | height: 25px; 19 | border-radius: 50%; 20 | margin-right: 10px; 21 | margin-top: -2px; 22 | } 23 | 24 | ul.dropdown-menu > li.user-header { 25 | height: auto!important; 26 | } 27 | 28 | a.dropdown-toggle { 29 | background-color: #3c8dbc!important; 30 | } 31 | 32 | a#logout { 33 | color: #3c8dbc!important; 34 | background: transparent; 35 | } 36 | 37 | @media (max-width: 768px) { 38 | body .control-sidebar { 39 | padding-top:100px; 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/webapp/resources/favicon/favicon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adminfaces/admin-starter-springboot/a3b41535e1490e5397b328340f12e852bfeacd76/src/main/webapp/resources/favicon/favicon-144x144.png -------------------------------------------------------------------------------- /src/main/webapp/resources/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adminfaces/admin-starter-springboot/a3b41535e1490e5397b328340f12e852bfeacd76/src/main/webapp/resources/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /src/main/webapp/resources/favicon/favicon-196x196.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adminfaces/admin-starter-springboot/a3b41535e1490e5397b328340f12e852bfeacd76/src/main/webapp/resources/favicon/favicon-196x196.png -------------------------------------------------------------------------------- /src/main/webapp/resources/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adminfaces/admin-starter-springboot/a3b41535e1490e5397b328340f12e852bfeacd76/src/main/webapp/resources/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /src/main/webapp/resources/favicon/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adminfaces/admin-starter-springboot/a3b41535e1490e5397b328340f12e852bfeacd76/src/main/webapp/resources/favicon/favicon-96x96.png -------------------------------------------------------------------------------- /src/main/webapp/resources/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adminfaces/admin-starter-springboot/a3b41535e1490e5397b328340f12e852bfeacd76/src/main/webapp/resources/favicon/favicon.ico -------------------------------------------------------------------------------- /src/main/webapp/resources/images/login-bg-mobile.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adminfaces/admin-starter-springboot/a3b41535e1490e5397b328340f12e852bfeacd76/src/main/webapp/resources/images/login-bg-mobile.jpeg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/login-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adminfaces/admin-starter-springboot/a3b41535e1490e5397b328340f12e852bfeacd76/src/main/webapp/resources/images/login-bg.jpg -------------------------------------------------------------------------------- /starter1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adminfaces/admin-starter-springboot/a3b41535e1490e5397b328340f12e852bfeacd76/starter1.png -------------------------------------------------------------------------------- /starter2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adminfaces/admin-starter-springboot/a3b41535e1490e5397b328340f12e852bfeacd76/starter2.png -------------------------------------------------------------------------------- /starter3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adminfaces/admin-starter-springboot/a3b41535e1490e5397b328340f12e852bfeacd76/starter3.png -------------------------------------------------------------------------------- /starter4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adminfaces/admin-starter-springboot/a3b41535e1490e5397b328340f12e852bfeacd76/starter4.png --------------------------------------------------------------------------------