From 41d2104b81eed192eaa88fc5c365050e1dbb2472 Mon Sep 17 00:00:00 2001 From: Marcelo Romulo Fernandes Date: Mon, 13 Aug 2018 11:42:30 -0300 Subject: [PATCH 1/4] adding adminfaces properties configuration. waiting 1.0.0-RC19 release to final tests. --- .../AdminfacesAutoConfiguration.java | 128 +++++++++- .../adminfaces/AdminfacesProperties.java | 207 +++++++++++++++++ .../adminfaces/AdminfacesPropertiesIT.java | 218 ++++++++++++++++++ .../resources/application-propertyTest.yml | 36 +++ 4 files changed, 586 insertions(+), 3 deletions(-) create mode 100644 joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesProperties.java create mode 100644 joinfaces-autoconfigure/src/test/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesPropertiesIT.java diff --git a/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesAutoConfiguration.java b/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesAutoConfiguration.java index 372ed8134..1ef64033c 100644 --- a/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesAutoConfiguration.java +++ b/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesAutoConfiguration.java @@ -19,19 +19,24 @@ import javax.faces.application.ViewExpiredException; import javax.persistence.OptimisticLockException; +import com.github.adminfaces.template.config.AdminConfig; +import com.github.adminfaces.template.config.ControlSidebarConfig; import com.github.adminfaces.template.exception.AccessDeniedException; import com.github.adminfaces.template.session.AdminServletContextListener; import com.github.adminfaces.template.session.AdminSession; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.joinfaces.autoconfigure.primefaces.Primefaces4_0Properties; import org.joinfaces.autoconfigure.primefaces.Primefaces5_2Properties; import org.joinfaces.autoconfigure.primefaces.PrimefacesAutoConfiguration; import org.springframework.beans.BeansException; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.web.server.ErrorPage; import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.boot.web.servlet.ServletComponentScan; @@ -52,8 +57,7 @@ */ @Slf4j @Configuration -// will adminfaces autoconfigure via application.yml ? -//@EnableConfigurationProperties(AdminfacesProperties.class) +@EnableConfigurationProperties(AdminfacesProperties.class) @ComponentScan({"com.github.adminfaces.template.bean", "com.github.adminfaces.template.config", "com.github.adminfaces.template.security"}) @@ -64,9 +68,14 @@ @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET) public class AdminfacesAutoConfiguration { + @Autowired + private AdminfacesProperties adminfacesProperties; + @Bean public BeanPostProcessor adminfacesPrimeFacesPropertiesPostProcessor() { - return new PrimeFacesPropertiesPostProcessor(); + PrimeFacesPropertiesPostProcessor result = new PrimeFacesPropertiesPostProcessor(); + result.setAdminfacesProperties(this.adminfacesProperties); + return result; } // AdminSession does not contain @Named. @@ -100,10 +109,14 @@ public WebServerFactoryCustomizer adminface /** * Configures Primefaces to use admin theme. + * Apply adminfaces configuration from adminfaces properties. * * @author Marcelo Fernandes */ static class PrimeFacesPropertiesPostProcessor implements BeanPostProcessor { + @Setter + private AdminfacesProperties adminfacesProperties; + @Override public Object postProcessBeforeInitialization(@Nullable Object bean, @Nullable String beanName) throws BeansException { if (bean instanceof Primefaces4_0Properties) { @@ -116,8 +129,117 @@ public Object postProcessBeforeInitialization(@Nullable Object bean, @Nullable S log.warn("Changing primefaces fontAwesome from 'false' to 'true'."); properties.setFontAwesome(true); } + /* Waiting 1.0.0-RC19 release + if (bean instanceof AdminConfig) { + configureAdminConfig((AdminConfig) bean); + } + */ return bean; } + + private void configureAdminConfig(AdminConfig adminConfig) { + if (this.adminfacesProperties.getLoginPage() != null) { + adminConfig.setLoginPage(this.adminfacesProperties.getLoginPage()); + } + if (this.adminfacesProperties.getIndexPage() != null) { + adminConfig.setIndexPage(this.adminfacesProperties.getIndexPage()); + } + if (this.adminfacesProperties.getDateFormat() != null) { + adminConfig.setDateFormat(this.adminfacesProperties.getDateFormat()); + } + if (this.adminfacesProperties.getTemplatePath() != null) { + adminConfig.setTemplatePath(this.adminfacesProperties.getTemplatePath()); + } + if (this.adminfacesProperties.getBreadcrumbSize() != null) { + adminConfig.setBreadCrumbMaxSize(this.adminfacesProperties.getBreadcrumbSize()); + } + if (this.adminfacesProperties.getRenderMessages() != null) { + adminConfig.setRenderMessages(this.adminfacesProperties.getRenderMessages()); + } + if (this.adminfacesProperties.getRenderAjaxStatus() != null) { + adminConfig.setRenderAjaxStatus(this.adminfacesProperties.getRenderAjaxStatus()); + } + if (this.adminfacesProperties.getDisableFilter() != null) { + adminConfig.setDisableFilter(this.adminfacesProperties.getDisableFilter()); + } + if (this.adminfacesProperties.getRenderBreadCrumb() != null) { + adminConfig.setRenderBreadCrumb(this.adminfacesProperties.getRenderBreadCrumb()); + } + if (this.adminfacesProperties.getEnableSlideMenu() != null) { + adminConfig.setEnableSlideMenu(this.adminfacesProperties.getEnableSlideMenu()); + } + if (this.adminfacesProperties.getEnableRipple() != null) { + adminConfig.setEnableRipple(this.adminfacesProperties.getEnableRipple()); + } + if (this.adminfacesProperties.getRippleElements() != null) { + adminConfig.setRippleElements(this.adminfacesProperties.getRippleElements()); + } + if (this.adminfacesProperties.getSkin() != null) { + adminConfig.setSkin(this.adminfacesProperties.getSkin()); + } + if (this.adminfacesProperties.getAutoShowNavbar() != null) { + adminConfig.setAutoShowNavbar(this.adminfacesProperties.getAutoShowNavbar()); + } + if (this.adminfacesProperties.getIgnoredResources() != null) { + adminConfig.setIgnoredResources(this.adminfacesProperties.getIgnoredResources()); + } + if (this.adminfacesProperties.getLoadingImage() != null) { + adminConfig.setLoadingImage(this.adminfacesProperties.getLoadingImage()); + } + if (this.adminfacesProperties.getExtensionLessUrls() != null) { + adminConfig.setExtensionLessUrls(this.adminfacesProperties.getExtensionLessUrls()); + } + if (this.adminfacesProperties.getRenderControlSidebar() != null) { + adminConfig.setRenderControlSidebar(this.adminfacesProperties.getRenderControlSidebar()); + } + + Boolean showOnMobile = adminConfig.getControlSidebar().getShowOnMobile(); + if (this.adminfacesProperties.getControlSidebar().getShowOnMobile() != null) { + showOnMobile = this.adminfacesProperties.getControlSidebar().getShowOnMobile(); + } + Boolean fixedLayout = adminConfig.getControlSidebar().getFixedLayout(); + if (this.adminfacesProperties.getControlSidebar().getFixedLayout() != null) { + fixedLayout = this.adminfacesProperties.getControlSidebar().getFixedLayout(); + } + Boolean boxedLayout = adminConfig.getControlSidebar().getBoxedLayout(); + if (this.adminfacesProperties.getControlSidebar().getBoxedLayout() != null) { + boxedLayout = this.adminfacesProperties.getControlSidebar().getBoxedLayout(); + } + Boolean expandOnHover = adminConfig.getControlSidebar().getExpandOnHover(); + if (this.adminfacesProperties.getControlSidebar().getExpandOnHover() != null) { + expandOnHover = this.adminfacesProperties.getControlSidebar().getExpandOnHover(); + } + Boolean sidebarCollapsed = adminConfig.getControlSidebar().getSidebarCollapsed(); + if (this.adminfacesProperties.getControlSidebar().getSidebarCollapsed() != null) { + sidebarCollapsed = this.adminfacesProperties.getControlSidebar().getSidebarCollapsed(); + } + Boolean fixed = adminConfig.getControlSidebar().getFixed(); + if (this.adminfacesProperties.getControlSidebar().getFixed() != null) { + fixed = this.adminfacesProperties.getControlSidebar().getFixed(); + } + Boolean darkSkin = adminConfig.getControlSidebar().getDarkSkin(); + if (this.adminfacesProperties.getControlSidebar().getDarkSkin() != null) { + darkSkin = this.adminfacesProperties.getControlSidebar().getDarkSkin(); + } + adminConfig.setControlSidebar(new ControlSidebarConfig(showOnMobile, fixedLayout, boxedLayout, expandOnHover, sidebarCollapsed, fixed, darkSkin)); + + if (this.adminfacesProperties.getControlSidebar().getLeftMenuTemplate() != null) { + adminConfig.setLeftMenuTemplate(this.adminfacesProperties.getControlSidebar().getLeftMenuTemplate()); + } + + if (this.adminfacesProperties.getRippleMobileOnly() != null) { + adminConfig.setRippleMobileOnly(this.adminfacesProperties.getRippleMobileOnly()); + } + if (this.adminfacesProperties.getRenderMenuSearch() != null) { + adminConfig.setRenderMenuSearch(this.adminfacesProperties.getRenderMenuSearch()); + } + if (this.adminfacesProperties.getAutoHideMessages() != null) { + adminConfig.setAutoHideMessages(this.adminfacesProperties.getAutoHideMessages()); + } + if (this.adminfacesProperties.getMessagesHideTimeout() != null) { + adminConfig.setMessagesHideTimeout(this.adminfacesProperties.getMessagesHideTimeout()); + } + } } } diff --git a/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesProperties.java b/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesProperties.java new file mode 100644 index 000000000..ba70d90f0 --- /dev/null +++ b/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesProperties.java @@ -0,0 +1,207 @@ +/* + * Copyright 2016-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.joinfaces.autoconfigure.adminfaces; + +import lombok.Data; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Configuration properties of BootsFaces. + *

+ * Taken from + *

+ * + * @author Marcelo Fernandes + */ +@Data +@ConfigurationProperties(prefix = "jsf.adminfaces") +public class AdminfacesProperties { + + /** + * login page location (relative to webapp). It you only be used if you configure Admin Session. + */ + private String loginPage; + + /** + * index page location. User will be redirected to it when it access app root (contextPath/). + */ + private String indexPage; + + /** + * Date format used in error page (500.xhtml), by default it is JVM default format. + */ + private String dateFormat; + + /** + * Template path. + */ + private String templatePath; + + /** + * Number of breadcrumbs to queue before removing the older ones. + */ + private Integer breadcrumbSize; + + /** + * When false, p:messages defined in admin template will not be rendered. + */ + private Boolean renderMessages; + + /** + * When false ajaxStatus, which triggers the loading bar on every ajax request, + * will not be rendered. + */ + private Boolean renderAjaxStatus; + + /** + * Disables AdminFilter, responsible for redirecting user after session timeout, + * sending user to logon page when it is not logged in among other things. + */ + private Boolean disableFilter; + + /** + * When false, the breadCrumb component, declared in admin template, will not be rendered. + */ + private Boolean renderBreadCrumb; + + /** + * If true will make left menu touch enable (can be closed or opened via touch). + * Can be enable/disabled per page with . + */ + private Boolean enableSlideMenu; + + /** + * When true it will create a wave/ripple effect on elements specified by rippleElements. + */ + private Boolean enableRipple; + + /** + * A list of comma separated list of (jquery) selector which elements will be + * affected by ripple effect. + */ + private String rippleElements; + + /** + * Default template skin. + */ + private String skin; + + /** + * Automatic shows navbar when users scrolls page up (on small screens). + * Can be enable/disabled per page with . + */ + private Boolean autoShowNavbar; + + /** + * Comma separated resources (pages or urls) to be skiped by AdminFilter. + * Ex: /rest, /pages/car-list. Note that by default the filter skips pages + * under CONTEXT/public/ folder. + */ + private String ignoredResources; + + /** + * image used for the loading popup. It must be under webapp/resources/images folder. + */ + private String loadingImage; + + /** + * Removes extension suffix from breadCrumb links. + */ + private Boolean extensionLessUrls; + + /** + * When true it will activate control sidebar component. + */ + private Boolean renderControlSidebar; + + /** + * When true the ripple effect will be enabled only on mobile (small) screens. + */ + private Boolean rippleMobileOnly; + + /** + * Enables or disables menu search. + */ + private Boolean renderMenuSearch; + + /** + * If true PrimeFaces info messages will be hidden after a certain timeout. + */ + private Boolean autoHideMessages; + + /** + * Timeout to hide info messages. Note that the timeout is also composed by + * configured timeout + number of words in message. + */ + private String messagesHideTimeout; + + /** + * When true it will activate control sidebar component. + */ + private ControlSidebar controlSidebar = new ControlSidebar(); + + /** + * ControlSidebar properties. + */ + @Data + public static class ControlSidebar { + + /** + * When true control sidebar will be also rendered on mobile devices. + */ + private Boolean showOnMobile; + + /** + * Switches layout between left (default) and top menu. + */ + private Boolean leftMenuTemplate; + + /** + * Toggles fixed layout where navbar is fixed on the page. + */ + private Boolean fixedLayout; + + /** + * Boxed layout. + */ + private Boolean boxedLayout; + + /** + * When true left sidebar will be collapsed. + */ + private Boolean sidebarCollapsed; + + /** + * When true left sidebar will expand on mouse hover. + */ + private Boolean expandOnHover; + + /** + * When true control sidebar will be fixed on the page. + */ + private Boolean fixed; + + /** + * Changes control sidebar skin between dark and light. + */ + private Boolean darkSkin; + } +} diff --git a/joinfaces-autoconfigure/src/test/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesPropertiesIT.java b/joinfaces-autoconfigure/src/test/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesPropertiesIT.java new file mode 100644 index 000000000..d7a07b534 --- /dev/null +++ b/joinfaces-autoconfigure/src/test/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesPropertiesIT.java @@ -0,0 +1,218 @@ +/* + * Copyright 2016-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.joinfaces.autoconfigure.adminfaces; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@SpringBootTest( + properties = "spring.profiles.active=propertyTest", + webEnvironment = SpringBootTest.WebEnvironment.MOCK +) +public class AdminfacesPropertiesIT { + + @Autowired + private AdminfacesProperties adminfacesProperties; + + @Test + public void testLoginPage() { + assertThat(this.adminfacesProperties.getLoginPage()) + .isEqualTo("login"); + } + + @Test + public void testIndexPage() { + assertThat(this.adminfacesProperties.getIndexPage()) + .isEqualTo("index"); + } + + @Test + public void testDateFormat() { + assertThat(this.adminfacesProperties.getDateFormat()) + .isEqualTo("dd-mm-yyyy"); + } + + @Test + public void testTemplatePath() { + assertThat(this.adminfacesProperties.getTemplatePath()) + .isEqualTo("my-template-path"); + } + + @Test + public void testBraedCrumbSize() { + assertThat(this.adminfacesProperties.getBreadcrumbSize()) + .isEqualTo(50); + } + + @Test + public void testRenderMessages() { + assertThat(this.adminfacesProperties.getRenderMessages()) + .isTrue(); + } + + @Test + public void testRenderAjaxStatus() { + assertThat(this.adminfacesProperties.getRenderAjaxStatus()) + .isTrue(); + } + + @Test + public void testDisableFilter() { + assertThat(this.adminfacesProperties.getDisableFilter()) + .isTrue(); + } + + @Test + public void testRenderBreadCrumb() { + assertThat(this.adminfacesProperties.getRenderBreadCrumb()) + .isTrue(); + } + + @Test + public void testEnableSlideMenu() { + assertThat(this.adminfacesProperties.getEnableSlideMenu()) + .isTrue(); + } + + @Test + public void testEnableRipple() { + assertThat(this.adminfacesProperties.getEnableRipple()) + .isTrue(); + } + + @Test + public void testRippleElements() { + assertThat(this.adminfacesProperties.getRippleElements()) + .isEqualTo(".ripplelink,button.ui-button"); + } + + @Test + public void testSkin() { + assertThat(this.adminfacesProperties.getSkin()) + .isEqualTo("skin-blue"); + } + + @Test + public void testAutoShowNavbar() { + assertThat(this.adminfacesProperties.getAutoShowNavbar()) + .isTrue(); + } + + @Test + public void testIgnoredResources() { + assertThat(this.adminfacesProperties.getIgnoredResources()) + .isEqualTo("/rest, /pages/car-list"); + } + + @Test + public void testLoadingImage() { + assertThat(this.adminfacesProperties.getLoadingImage()) + .isEqualTo("ajaxloadingbar.png"); + } + + @Test + public void testExtensionLessUrls() { + assertThat(this.adminfacesProperties.getExtensionLessUrls()) + .isTrue(); + } + + @Test + public void testRenderControlSidebar() { + assertThat(this.adminfacesProperties.getRenderControlSidebar()) + .isTrue(); + } + + @Test + public void testRippleMobileOnly() { + assertThat(this.adminfacesProperties.getRippleMobileOnly()) + .isTrue(); + } + + @Test + public void testRenderMenuSearch() { + assertThat(this.adminfacesProperties.getRenderMenuSearch()) + .isTrue(); + } + + @Test + public void testAutoHideMessages() { + assertThat(this.adminfacesProperties.getAutoHideMessages()) + .isTrue(); + } + + @Test + public void testMessagesHideTimeout() { + assertThat(this.adminfacesProperties.getMessagesHideTimeout()) + .isEqualTo("2200"); + } + + @Test + public void testShowOnMobile() { + assertThat(this.adminfacesProperties.getControlSidebar().getShowOnMobile()) + .isTrue(); + } + + @Test + public void testLeftMenuTemplate() { + assertThat(this.adminfacesProperties.getControlSidebar().getLeftMenuTemplate()) + .isTrue(); + } + + @Test + public void testFixedLayout() { + assertThat(this.adminfacesProperties.getControlSidebar().getFixedLayout()) + .isTrue(); + } + + @Test + public void testBoxedLayout() { + assertThat(this.adminfacesProperties.getControlSidebar().getBoxedLayout()) + .isTrue(); + } + + @Test + public void testSidebarCollapsed() { + assertThat(this.adminfacesProperties.getControlSidebar().getSidebarCollapsed()) + .isTrue(); + } + + @Test + public void testExpandOnHover() { + assertThat(this.adminfacesProperties.getControlSidebar().getExpandOnHover()) + .isTrue(); + } + + @Test + public void testFixed() { + assertThat(this.adminfacesProperties.getControlSidebar().getFixed()) + .isTrue(); + } + + @Test + public void testDarkSkin() { + assertThat(this.adminfacesProperties.getControlSidebar().getDarkSkin()) + .isTrue(); + } + +} diff --git a/joinfaces-autoconfigure/src/test/resources/application-propertyTest.yml b/joinfaces-autoconfigure/src/test/resources/application-propertyTest.yml index 6d975c0d7..6f677d2ee 100644 --- a/joinfaces-autoconfigure/src/test/resources/application-propertyTest.yml +++ b/joinfaces-autoconfigure/src/test/resources/application-propertyTest.yml @@ -325,6 +325,42 @@ jsf: ascending: glyphicon glyphicon-chevron-down descending: glyphicon glyphicon-chevron-up none: glyphicon glyphicon-chevron-right + + # adminfaces namespace + adminfaces: + loginPage: login + indexPage: index + dateFormat: dd-mm-yyyy + templatePath: my-template-path + breadcrumbSize: 50 + renderMessages: true + renderAjaxStatus: true + disableFilter: true + renderBreadCrumb: true + enableSlideMenu: true + enableRipple: true + rippleElements: .ripplelink,button.ui-button + skin: skin-blue + autoShowNavbar: true + ignoredResources: /rest, /pages/car-list + loadingImage: ajaxloadingbar.png + extensionLessUrls: true + renderControlSidebar: true + rippleMobileOnly: true + renderMenuSearch: true + autoHideMessages: true + messagesHideTimeout: 2200 + controlSidebar: + showOnMobile: true + leftMenuTemplate: true + fixedLayout: true + boxedLayout: true + sidebarCollapsed: true + expandOnHover: true + fixed: true + darkSkin: true + + # richafaces namespace richfaces: longValueWithDefault: -100 intValue: -1 From 876aae409ab2c9a31429bcfc5ee8deaad651c435 Mon Sep 17 00:00:00 2001 From: Marcelo Romulo Fernandes Date: Mon, 13 Aug 2018 11:46:59 -0300 Subject: [PATCH 2/4] adding adminfaces namespace to README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index efa1dffe3..2dd2644b0 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ standard (javax.faces) | jsf | `jsf.project-stage=development` [primefaces](http://primefaces.org/) | jsf.primefaces | `jsf.primefaces.theme=overcast` [bootsfaces](http://bootsfaces.net/) | jsf.bootsfaces | `jsf.bootsfaces.usetheme=true` [butterfaces](http://butterfaces.org/) | jsf.butterfaces | `jsf.butterfaces.provide-j-query=true` +[adminfaces](http://adminfaces.github.io/site/) | jsf.adminfaces | `jsf.adminfaces.skin=skin-blue` [richfaces](https://github.com/richfaces/richfaces) | jsf.richfaces | `jsf.richfaces.resource-default-ttl=86400` [omnifaces](http://omnifaces.org/) | jsf.omnifaces | `jsf.omnifaces.faces-views-enabled=true` [angularfaces](http://angularfaces.net/) | jsf.angularfaces | `jsf.angularfaces.add-labels=true` From e7bd88d90fee7239df63dcf139da7d1a08ee6ec5 Mon Sep 17 00:00:00 2001 From: Marcelo Romulo Fernandes Date: Tue, 16 Oct 2018 12:12:43 -0300 Subject: [PATCH 3/4] configure AdminFaces using Spring Boot application.yml or application.properties AdminfacesProperties should be Serializable because AdminConfigWrapper is too. AdminConfigWrapper wraps AdminConfig and overrides loadDefaults methods using AdminfacesProperties. --- .../adminfaces/AdminConfigWrapper.java | 105 +++++ .../AdminfacesAutoConfiguration.java | 111 +---- .../adminfaces/AdminfacesProperties.java | 17 +- .../adminfaces/AdminfacesPropertiesIT.java | 218 --------- .../test/resources/admin-config.properties | 1 - .../resources/application-propertyTest.yml | 437 ------------------ 6 files changed, 122 insertions(+), 767 deletions(-) create mode 100644 joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminConfigWrapper.java delete mode 100644 joinfaces-autoconfigure/src/test/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesPropertiesIT.java delete mode 100644 joinfaces-autoconfigure/src/test/resources/admin-config.properties delete mode 100644 joinfaces-autoconfigure/src/test/resources/application-propertyTest.yml diff --git a/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminConfigWrapper.java b/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminConfigWrapper.java new file mode 100644 index 000000000..f200d8cc9 --- /dev/null +++ b/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminConfigWrapper.java @@ -0,0 +1,105 @@ +/* + * Copyright 2016-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.joinfaces.autoconfigure.adminfaces; + +import com.github.adminfaces.template.config.AdminConfig; +import com.github.adminfaces.template.config.ControlSidebarConfig; +import lombok.Setter; + +/** + * AdminConfig Wrapper to use AdminFacesProperties. + * This class is not simpler because AdminConfig.getProperty is private. + * + * @author Marcelo Fernandes + */ +public class AdminConfigWrapper extends AdminConfig { + @Setter + private AdminfacesProperties adminfacesProperties; + + @Override + protected void loadDefaults() { + super.loadDefaults(); + configureAdminFacesProperties(); + } + + private String getAdminFacesStringProperty(String current, String fromAdminFacesProperties) { + String result = current; + if (fromAdminFacesProperties != null) { + result = fromAdminFacesProperties; + } + return result; + } + + private Boolean getAdminFacesBooleanProperty(Boolean current, Boolean fromAdminFacesProperties) { + Boolean result = current; + if (fromAdminFacesProperties != null) { + result = fromAdminFacesProperties; + } + return result; + } + + private Integer getAdminFacesIntegerProperty(Integer current, Integer fromAdminFacesProperties) { + Integer result = current; + if (fromAdminFacesProperties != null) { + result = fromAdminFacesProperties; + } + return result; + } + + private void configureAdminFacesProperties() { + setLoginPage(getAdminFacesStringProperty(getLoginPage(), this.adminfacesProperties.getLoginPage())); + setIndexPage(getAdminFacesStringProperty(getIndexPage(), this.adminfacesProperties.getIndexPage())); + setDateFormat(getAdminFacesStringProperty(getDateFormat(), this.adminfacesProperties.getDateFormat())); + setTemplatePath(getAdminFacesStringProperty(getTemplatePath(), this.adminfacesProperties.getTemplatePath())); + setBreadCrumbMaxSize(getAdminFacesIntegerProperty(getBreadCrumbMaxSize(), this.adminfacesProperties.getBreadcrumbSize())); + setRenderMessages(getAdminFacesBooleanProperty(isRenderMessages(), this.adminfacesProperties.getRenderMessages())); + setRenderAjaxStatus(getAdminFacesBooleanProperty(isRenderAjaxStatus(), this.adminfacesProperties.getRenderAjaxStatus())); + setDisableFilter(getAdminFacesBooleanProperty(isDisableFilter(), this.adminfacesProperties.getDisableFilter())); + setRenderBreadCrumb(getAdminFacesBooleanProperty(isRenderBreadCrumb(), this.adminfacesProperties.getRenderBreadCrumb())); + setEnableSlideMenu(getAdminFacesBooleanProperty(isEnableSlideMenu(), this.adminfacesProperties.getEnableSlideMenu())); + setEnableRipple(getAdminFacesBooleanProperty(isEnableRipple(), this.adminfacesProperties.getEnableRipple())); + setRippleElements(getAdminFacesStringProperty(getRippleElements(), this.adminfacesProperties.getRippleElements())); + setSkin(getAdminFacesStringProperty(getSkin(), this.adminfacesProperties.getSkin())); + setAutoShowNavbar(getAdminFacesBooleanProperty(isAutoShowNavbar(), this.adminfacesProperties.getAutoShowNavbar())); + setIgnoredResources(getAdminFacesStringProperty(getIgnoredResources(), this.adminfacesProperties.getIgnoredResources())); + setLoadingImage(getAdminFacesStringProperty(getLoadingImage(), this.adminfacesProperties.getLoadingImage())); + setExtensionLessUrls(getAdminFacesBooleanProperty(isExtensionLessUrls(), this.adminfacesProperties.getExtensionLessUrls())); + setRenderControlSidebar(getAdminFacesBooleanProperty(isRenderControlSidebar(), this.adminfacesProperties.getRenderControlSidebar())); + + setRippleMobileOnly(getAdminFacesBooleanProperty(isRippleMobileOnly(), this.adminfacesProperties.getRippleMobileOnly())); + setRenderMenuSearch(getAdminFacesBooleanProperty(isRenderMenuSearch(), this.adminfacesProperties.getRenderMenuSearch())); + setAutoHideMessages(getAdminFacesBooleanProperty(isAutoHideMessages(), this.adminfacesProperties.getAutoHideMessages())); + setMessagesHideTimeout(getAdminFacesStringProperty(getMessagesHideTimeout(), this.adminfacesProperties.getMessagesHideTimeout())); + setIconsEffect(getAdminFacesBooleanProperty(isIconsEffect(), this.adminfacesProperties.getIconsEffect())); + + configControlSideBar(); + } + + private void configControlSideBar() { + setLeftMenuTemplate(getAdminFacesBooleanProperty(isLeftMenuTemplate(), this.adminfacesProperties.getControlSidebar().getLeftMenuTemplate())); + + Boolean showOnMobile = getAdminFacesBooleanProperty(getControlSidebar().getShowOnMobile(), this.adminfacesProperties.getControlSidebar().getShowOnMobile()); + Boolean fixedLayout = getAdminFacesBooleanProperty(getControlSidebar().getFixedLayout(), this.adminfacesProperties.getControlSidebar().getFixedLayout()); + Boolean boxedLayout = getAdminFacesBooleanProperty(getControlSidebar().getBoxedLayout(), this.adminfacesProperties.getControlSidebar().getBoxedLayout()); + Boolean expandOnHover = getAdminFacesBooleanProperty(getControlSidebar().getExpandOnHover(), this.adminfacesProperties.getControlSidebar().getExpandOnHover()); + Boolean sidebarCollapsed = getAdminFacesBooleanProperty(getControlSidebar().getSidebarCollapsed(), this.adminfacesProperties.getControlSidebar().getSidebarCollapsed()); + Boolean fixed = getAdminFacesBooleanProperty(getControlSidebar().getFixed(), this.adminfacesProperties.getControlSidebar().getFixed()); + Boolean darkSkin = getAdminFacesBooleanProperty(getControlSidebar().getDarkSkin(), this.adminfacesProperties.getControlSidebar().getDarkSkin()); + + setControlSidebar(new ControlSidebarConfig(showOnMobile, fixedLayout, boxedLayout, expandOnHover, sidebarCollapsed, fixed, darkSkin)); + } +} diff --git a/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesAutoConfiguration.java b/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesAutoConfiguration.java index 1ef64033c..63fccae57 100644 --- a/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesAutoConfiguration.java +++ b/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesAutoConfiguration.java @@ -20,7 +20,6 @@ import javax.persistence.OptimisticLockException; import com.github.adminfaces.template.config.AdminConfig; -import com.github.adminfaces.template.config.ControlSidebarConfig; import com.github.adminfaces.template.exception.AccessDeniedException; import com.github.adminfaces.template.session.AdminServletContextListener; import com.github.adminfaces.template.session.AdminSession; @@ -129,117 +128,13 @@ public Object postProcessBeforeInitialization(@Nullable Object bean, @Nullable S log.warn("Changing primefaces fontAwesome from 'false' to 'true'."); properties.setFontAwesome(true); } - /* Waiting 1.0.0-RC19 release if (bean instanceof AdminConfig) { - configureAdminConfig((AdminConfig) bean); + AdminConfigWrapper adminConfigWrapper = new AdminConfigWrapper(); + adminConfigWrapper.setAdminfacesProperties(this.adminfacesProperties); + bean = adminConfigWrapper; } - */ return bean; } - - private void configureAdminConfig(AdminConfig adminConfig) { - if (this.adminfacesProperties.getLoginPage() != null) { - adminConfig.setLoginPage(this.adminfacesProperties.getLoginPage()); - } - if (this.adminfacesProperties.getIndexPage() != null) { - adminConfig.setIndexPage(this.adminfacesProperties.getIndexPage()); - } - if (this.adminfacesProperties.getDateFormat() != null) { - adminConfig.setDateFormat(this.adminfacesProperties.getDateFormat()); - } - if (this.adminfacesProperties.getTemplatePath() != null) { - adminConfig.setTemplatePath(this.adminfacesProperties.getTemplatePath()); - } - if (this.adminfacesProperties.getBreadcrumbSize() != null) { - adminConfig.setBreadCrumbMaxSize(this.adminfacesProperties.getBreadcrumbSize()); - } - if (this.adminfacesProperties.getRenderMessages() != null) { - adminConfig.setRenderMessages(this.adminfacesProperties.getRenderMessages()); - } - if (this.adminfacesProperties.getRenderAjaxStatus() != null) { - adminConfig.setRenderAjaxStatus(this.adminfacesProperties.getRenderAjaxStatus()); - } - if (this.adminfacesProperties.getDisableFilter() != null) { - adminConfig.setDisableFilter(this.adminfacesProperties.getDisableFilter()); - } - if (this.adminfacesProperties.getRenderBreadCrumb() != null) { - adminConfig.setRenderBreadCrumb(this.adminfacesProperties.getRenderBreadCrumb()); - } - if (this.adminfacesProperties.getEnableSlideMenu() != null) { - adminConfig.setEnableSlideMenu(this.adminfacesProperties.getEnableSlideMenu()); - } - if (this.adminfacesProperties.getEnableRipple() != null) { - adminConfig.setEnableRipple(this.adminfacesProperties.getEnableRipple()); - } - if (this.adminfacesProperties.getRippleElements() != null) { - adminConfig.setRippleElements(this.adminfacesProperties.getRippleElements()); - } - if (this.adminfacesProperties.getSkin() != null) { - adminConfig.setSkin(this.adminfacesProperties.getSkin()); - } - if (this.adminfacesProperties.getAutoShowNavbar() != null) { - adminConfig.setAutoShowNavbar(this.adminfacesProperties.getAutoShowNavbar()); - } - if (this.adminfacesProperties.getIgnoredResources() != null) { - adminConfig.setIgnoredResources(this.adminfacesProperties.getIgnoredResources()); - } - if (this.adminfacesProperties.getLoadingImage() != null) { - adminConfig.setLoadingImage(this.adminfacesProperties.getLoadingImage()); - } - if (this.adminfacesProperties.getExtensionLessUrls() != null) { - adminConfig.setExtensionLessUrls(this.adminfacesProperties.getExtensionLessUrls()); - } - if (this.adminfacesProperties.getRenderControlSidebar() != null) { - adminConfig.setRenderControlSidebar(this.adminfacesProperties.getRenderControlSidebar()); - } - - Boolean showOnMobile = adminConfig.getControlSidebar().getShowOnMobile(); - if (this.adminfacesProperties.getControlSidebar().getShowOnMobile() != null) { - showOnMobile = this.adminfacesProperties.getControlSidebar().getShowOnMobile(); - } - Boolean fixedLayout = adminConfig.getControlSidebar().getFixedLayout(); - if (this.adminfacesProperties.getControlSidebar().getFixedLayout() != null) { - fixedLayout = this.adminfacesProperties.getControlSidebar().getFixedLayout(); - } - Boolean boxedLayout = adminConfig.getControlSidebar().getBoxedLayout(); - if (this.adminfacesProperties.getControlSidebar().getBoxedLayout() != null) { - boxedLayout = this.adminfacesProperties.getControlSidebar().getBoxedLayout(); - } - Boolean expandOnHover = adminConfig.getControlSidebar().getExpandOnHover(); - if (this.adminfacesProperties.getControlSidebar().getExpandOnHover() != null) { - expandOnHover = this.adminfacesProperties.getControlSidebar().getExpandOnHover(); - } - Boolean sidebarCollapsed = adminConfig.getControlSidebar().getSidebarCollapsed(); - if (this.adminfacesProperties.getControlSidebar().getSidebarCollapsed() != null) { - sidebarCollapsed = this.adminfacesProperties.getControlSidebar().getSidebarCollapsed(); - } - Boolean fixed = adminConfig.getControlSidebar().getFixed(); - if (this.adminfacesProperties.getControlSidebar().getFixed() != null) { - fixed = this.adminfacesProperties.getControlSidebar().getFixed(); - } - Boolean darkSkin = adminConfig.getControlSidebar().getDarkSkin(); - if (this.adminfacesProperties.getControlSidebar().getDarkSkin() != null) { - darkSkin = this.adminfacesProperties.getControlSidebar().getDarkSkin(); - } - adminConfig.setControlSidebar(new ControlSidebarConfig(showOnMobile, fixedLayout, boxedLayout, expandOnHover, sidebarCollapsed, fixed, darkSkin)); - - if (this.adminfacesProperties.getControlSidebar().getLeftMenuTemplate() != null) { - adminConfig.setLeftMenuTemplate(this.adminfacesProperties.getControlSidebar().getLeftMenuTemplate()); - } - - if (this.adminfacesProperties.getRippleMobileOnly() != null) { - adminConfig.setRippleMobileOnly(this.adminfacesProperties.getRippleMobileOnly()); - } - if (this.adminfacesProperties.getRenderMenuSearch() != null) { - adminConfig.setRenderMenuSearch(this.adminfacesProperties.getRenderMenuSearch()); - } - if (this.adminfacesProperties.getAutoHideMessages() != null) { - adminConfig.setAutoHideMessages(this.adminfacesProperties.getAutoHideMessages()); - } - if (this.adminfacesProperties.getMessagesHideTimeout() != null) { - adminConfig.setMessagesHideTimeout(this.adminfacesProperties.getMessagesHideTimeout()); - } - } } } diff --git a/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesProperties.java b/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesProperties.java index ba70d90f0..e7efb3bbe 100644 --- a/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesProperties.java +++ b/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesProperties.java @@ -16,12 +16,14 @@ package org.joinfaces.autoconfigure.adminfaces; +import java.io.Serializable; + import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; /** - * Configuration properties of BootsFaces. + * Configuration properties of AdminFaces. *

* Taken from *

    @@ -33,7 +35,9 @@ */ @Data @ConfigurationProperties(prefix = "jsf.adminfaces") -public class AdminfacesProperties { +public class AdminfacesProperties implements Serializable { + + private static final long serialVersionUID = 1L; /** * login page location (relative to webapp). It you only be used if you configure Admin Session. @@ -153,6 +157,11 @@ public class AdminfacesProperties { */ private String messagesHideTimeout; + /** + * Enables material effect when icons (e.g modal close, calendar) are clicked. + */ + private Boolean iconsEffect; + /** * When true it will activate control sidebar component. */ @@ -162,7 +171,9 @@ public class AdminfacesProperties { * ControlSidebar properties. */ @Data - public static class ControlSidebar { + public static class ControlSidebar implements Serializable { + + private static final long serialVersionUID = 1L; /** * When true control sidebar will be also rendered on mobile devices. diff --git a/joinfaces-autoconfigure/src/test/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesPropertiesIT.java b/joinfaces-autoconfigure/src/test/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesPropertiesIT.java deleted file mode 100644 index d7a07b534..000000000 --- a/joinfaces-autoconfigure/src/test/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesPropertiesIT.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright 2016-2016 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.joinfaces.autoconfigure.adminfaces; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SpringRunner.class) -@SpringBootTest( - properties = "spring.profiles.active=propertyTest", - webEnvironment = SpringBootTest.WebEnvironment.MOCK -) -public class AdminfacesPropertiesIT { - - @Autowired - private AdminfacesProperties adminfacesProperties; - - @Test - public void testLoginPage() { - assertThat(this.adminfacesProperties.getLoginPage()) - .isEqualTo("login"); - } - - @Test - public void testIndexPage() { - assertThat(this.adminfacesProperties.getIndexPage()) - .isEqualTo("index"); - } - - @Test - public void testDateFormat() { - assertThat(this.adminfacesProperties.getDateFormat()) - .isEqualTo("dd-mm-yyyy"); - } - - @Test - public void testTemplatePath() { - assertThat(this.adminfacesProperties.getTemplatePath()) - .isEqualTo("my-template-path"); - } - - @Test - public void testBraedCrumbSize() { - assertThat(this.adminfacesProperties.getBreadcrumbSize()) - .isEqualTo(50); - } - - @Test - public void testRenderMessages() { - assertThat(this.adminfacesProperties.getRenderMessages()) - .isTrue(); - } - - @Test - public void testRenderAjaxStatus() { - assertThat(this.adminfacesProperties.getRenderAjaxStatus()) - .isTrue(); - } - - @Test - public void testDisableFilter() { - assertThat(this.adminfacesProperties.getDisableFilter()) - .isTrue(); - } - - @Test - public void testRenderBreadCrumb() { - assertThat(this.adminfacesProperties.getRenderBreadCrumb()) - .isTrue(); - } - - @Test - public void testEnableSlideMenu() { - assertThat(this.adminfacesProperties.getEnableSlideMenu()) - .isTrue(); - } - - @Test - public void testEnableRipple() { - assertThat(this.adminfacesProperties.getEnableRipple()) - .isTrue(); - } - - @Test - public void testRippleElements() { - assertThat(this.adminfacesProperties.getRippleElements()) - .isEqualTo(".ripplelink,button.ui-button"); - } - - @Test - public void testSkin() { - assertThat(this.adminfacesProperties.getSkin()) - .isEqualTo("skin-blue"); - } - - @Test - public void testAutoShowNavbar() { - assertThat(this.adminfacesProperties.getAutoShowNavbar()) - .isTrue(); - } - - @Test - public void testIgnoredResources() { - assertThat(this.adminfacesProperties.getIgnoredResources()) - .isEqualTo("/rest, /pages/car-list"); - } - - @Test - public void testLoadingImage() { - assertThat(this.adminfacesProperties.getLoadingImage()) - .isEqualTo("ajaxloadingbar.png"); - } - - @Test - public void testExtensionLessUrls() { - assertThat(this.adminfacesProperties.getExtensionLessUrls()) - .isTrue(); - } - - @Test - public void testRenderControlSidebar() { - assertThat(this.adminfacesProperties.getRenderControlSidebar()) - .isTrue(); - } - - @Test - public void testRippleMobileOnly() { - assertThat(this.adminfacesProperties.getRippleMobileOnly()) - .isTrue(); - } - - @Test - public void testRenderMenuSearch() { - assertThat(this.adminfacesProperties.getRenderMenuSearch()) - .isTrue(); - } - - @Test - public void testAutoHideMessages() { - assertThat(this.adminfacesProperties.getAutoHideMessages()) - .isTrue(); - } - - @Test - public void testMessagesHideTimeout() { - assertThat(this.adminfacesProperties.getMessagesHideTimeout()) - .isEqualTo("2200"); - } - - @Test - public void testShowOnMobile() { - assertThat(this.adminfacesProperties.getControlSidebar().getShowOnMobile()) - .isTrue(); - } - - @Test - public void testLeftMenuTemplate() { - assertThat(this.adminfacesProperties.getControlSidebar().getLeftMenuTemplate()) - .isTrue(); - } - - @Test - public void testFixedLayout() { - assertThat(this.adminfacesProperties.getControlSidebar().getFixedLayout()) - .isTrue(); - } - - @Test - public void testBoxedLayout() { - assertThat(this.adminfacesProperties.getControlSidebar().getBoxedLayout()) - .isTrue(); - } - - @Test - public void testSidebarCollapsed() { - assertThat(this.adminfacesProperties.getControlSidebar().getSidebarCollapsed()) - .isTrue(); - } - - @Test - public void testExpandOnHover() { - assertThat(this.adminfacesProperties.getControlSidebar().getExpandOnHover()) - .isTrue(); - } - - @Test - public void testFixed() { - assertThat(this.adminfacesProperties.getControlSidebar().getFixed()) - .isTrue(); - } - - @Test - public void testDarkSkin() { - assertThat(this.adminfacesProperties.getControlSidebar().getDarkSkin()) - .isTrue(); - } - -} diff --git a/joinfaces-autoconfigure/src/test/resources/admin-config.properties b/joinfaces-autoconfigure/src/test/resources/admin-config.properties deleted file mode 100644 index 8b1378917..000000000 --- a/joinfaces-autoconfigure/src/test/resources/admin-config.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/joinfaces-autoconfigure/src/test/resources/application-propertyTest.yml b/joinfaces-autoconfigure/src/test/resources/application-propertyTest.yml deleted file mode 100644 index 6f677d2ee..000000000 --- a/joinfaces-autoconfigure/src/test/resources/application-propertyTest.yml +++ /dev/null @@ -1,437 +0,0 @@ -jsf: - - # javax.faces namespace - projectStage: Development - resourceExcludes: myExcludes - webappContractsDirectory: myContractsDirectory - webappResourcesDirectory: myResourcesDirectory - fullStateSavingViewIds: myIds - partialStateSaving: true - serializeServerState: true - stateSavingMethod: server - defaultSuffix: .xhtml - disableFaceletJsfViewhandler: true - faceletsBufferSize: 33 - faceletsLibraries: myLibrary - faceletsRefreshPeriod: 35 - faceletsSkipComments: true - faceletsSuffix: .html - faceletsViewMappings: newMapping - honorCurrentComponentAttributes: true - validateEmptyFields: auto - separatorChar: ; - configFiles: myConfig - lifecycleId: myId - clientWindowMode: url - interpretEmptyStringSubmittedValuesAsNull: true - datetimeconverterDefaultTimezoneIsSystemTimezone: true - partial: - execute: true - render: true - resetValues: true - flow: - nullFlow: true - validator: - disableDefaultBeanValidator: true - alwaysPerformValidationWhenRequiredIsTrue: true - enableWebsocketEndpoint: true - websocketEndpointPort: 8888 - disableFacesservletToXhtml: true - viewrootPhaseListenerQueuesExceptions: true - enableValidateWholeBean: true - - # mojarra namespace - mojarra: - clientStateTimeout: 10 - clientStateWriteBufferSize: 11 - compressViewState: true - disableClientStateEncryption: true - enableClientStateDebugging: true - generateUniqueServerStateIds: true - numberOfLogicalViews: 15 - numberOfViewsInSession: 16 - serializeServerState: true - writeStateAtFormEnd: true - allowTextChildren: true - autoCompleteOffOnViewState: true - compressJavaScript: true - disableUnicodeEscaping: true - disableIdUniquenessCheck: true - enabled-js-style-hiding: true - enableScriptsInAttributeValues: true - enableViewStateIdRendering: true - prefer-xhtml: true - responseBufferSize: 20 - cacheResourceModificationTimestamp: true - compressableMimeTypes: txt - defaultResourceMaxAge: 30 - enableFaceletsResourceResolverCompositeComponents: true - enableMissingResourceLibraryDetection: true - resourceUpdateCheckPeriod: 50 - enableAgressiveSessionDirtying: true - enableDistributable: true - annotationScanPackages: mypackage - displayConfiguration: true - enableCoreTagLibValidator: true - enableHtmlTagLibValidator: true - enableLazyBeanValidation: true - enableThreading: true - forceLoadConfiguration: true - validateXml: true - verifyObjects: true - enableTransitionTimeNoOpFlash: true - forceAlwaysWriteFlashCookie: true - namespaceParameters: true - registerConverterPropertyEditors: true - sendPoweredByHeader: true - disallowDoctypeDecl: true - managedBeanFactoryDecorator: - numberOfConcurrentFlashUsers: 5000 - numberOfFlashesBetweenFlashReapings: 5000 - duplicateJARPattern: - faceletCache: - faceletsProcessingFileExtensionProcessAs: - disableVersionTracking: true - enableJSStyleHiding: true - enabledLoadBundle11Compatibility: true - enableRestoreView11Compatibility: true - enableGroovyScripting: true - enableHttpMethodRestrictionPhaseListener: true - allowedHttpMethods: '*' - - # myfaces namespace - myfaces: - - # view handling - checkedViewidCacheSize: 500 - checkedViewidCacheEnabled: true - viewUniqueIdsCacheEnabled: true - componentUniqueIdsCacheSize: 100 - strictJsf2ViewNotFound: true - strictJsf2FaceletsCompatibility: true - - # state saving - renderViewstateId: true - refreshTransientBuildOnPss: auto - refreshTransientBuildOnPssPreserveState: true - numberOfViewsInSession: 20 - numberOfSequentialViewsInSession: 4 - numberOfFlashTokensInSession: 5 - facesFlowClientWindowIdsInSession: 6 - useEncryption: true - secret: mySecret - algorithm: DES - secretCache: true - algorithmIv: iv - algorithmParameters: ECB/PKCS5Padding - serialFactory: org.apache.myfaces.shared.util.serial.DefaultSerialFactory - compressStateInClient: true - macAlgorithm: HmacSHA1 - macSecret: myMacSecret - macSecretCache: true - randomKeyInCsrfSessionToken: none - randomKeyInCsrfSessionTokenLength: 16 - randomKeyInCsrfSessionTokenSecureRandomClass: mySecureRamdomClass - randomKeyInCsrfSessionTokenSecureRandomProvider: mySecureRamdomProvider - randomKeyInCsrfSessionTokenSecureRandomAlgoritm: SHA1PRNG - clientViewStateTimeout: 0 - compressStateInSession: true - useFlashScopePurgeViewsInSession: true - randomKeyInViewStateSessionToken: myStateSessionToken - randomKeyInViewStateSessionTokenLength: 8 - randomKeyInViewStateSessionTokenSecureRandomClass: mySecureRandomClass - randomKeyInViewStateSessionTokenSecureRandomProvider: mySecureRandomProvider - randomKeyInViewStateSessionTokenSecureRandomAlgorithm: SHA1PRNG - autocompleteOffViewState: true - checkIdProductionMode: auto - - # resources - resourceMaxTimeExpires: 604800000 - resourceHandlerCacheSize: 500 - resourceHandlerCacheEnabled: true - strictJsf2AllowSlashLibraryName: true - resourceBufferSize: 2048 - - # rendering - prettyHtml: true - allowJavascript: true - strictXhtmlLinks: true - renderClearJavascriptForButton: true - renderHiddenFieldsForLinkParams: true - saveFormSubmitLinkIe: true - wrapScriptContentWithXmlCommentTag: true - renderFormSubmitScriptInline: true - defaultResponseWriterContentTypeMode: text/html - useMultipleJsFilesForJsfUncompressedJs: true - jsfJsMode: normal - earlyFlushEnabled: true - renderFormViewStateAtBegin: true - - # CDI - cdiManagedConvertersEnabled: true - cdiManagedValidatorsEnabled: true - - # conversion and validation - enumConverterAllowStringPasstrough: true - validator: - beanBeforeJsfValidation: true - - # expression language - strictJsf2CcElResolver: myElResolver - supportJspAndFacesEl: true - supportEl3ImportHandler: true - cacheElExpressions: true - expressionFactory: org.apache.el.ExpressionFactoryImpl - - # other - configRefreshPeriod: 2 - validateXml: true - debugPhaseListener: true - strictJsf2RefreshTargetAjax: true - gaeJsfJarFiles: myjar.jar - gaeJsfAnnotationsJarFiles: myAnnotationJar.jar - flashScopeDisabled: true - lazyLoadConfigObjects: true - validate: true - initializeSkipJarFacesConfigScan: true - defaultWindowMode: url - errorTemplateResource: META-INF/rsc/myfaces-dev-error.xml - debugTemplateResource: META-INF/rsc/myfaces-dev-debug.xml - errorHandling: true - temporalResourcehandlerCacheEnabled: true - serviceProviderFinder: org.apache.myfaces.spi.impl.DefaultServiceProviderFinder - markInitialStateWhenApplyBuildView: true - wrapTagExceptionsAsContextAware: true - viewPoolMaxPoolSize: 5 - viewPoolMaxDynamicPartialLimit: 2 - viewPoolEntryMode: soft - viewPoolDeferredNavigation: true - logWebContextParams: auto - initializeAlwaysStandalone: false - annotation: - useCdiForAnnotationScanning: true - scanPackages: myScanPackages - spi: - injectionProvider: myInjectionProvider - - # deprecated - errorHandler: myHandler - viewstateJavascript: true - serializeStateInSession: true - cacheOldViewsInSessionMode: false - - # omnifaces namespace - omnifaces: - cacheProvider: org.omnifaces.component.output.cache.DefaultCacheProvider - defaultcache: myCache - exceptionTypesToUnwrap: java.lang.IllegalStateException - facesViewsDispatchMethod: myFacesMethod - facesViewsEnabled: true - facesViewsExtensionAction: extensionAction - facesViewsFilterAfterDeclaredFilters: myView - facesViewsPathAction: pathAction - facesViewsScanPaths: scanPath - facesViewsScannedViewsAlwaysExtensionless: true - facesViewsViewHandlerMode: myMode - html5RenderKitPassthroughAttributes: myAttribute - cdnResourceHandlerDisabled: true - cdnResourceHandlerUrls: myurl - combinedResourceHandlerCacheTtl: 15 - combinedResourceHandlerDisabled: true - combinedResourceHandlerExcludedResources: excludedResource - combinedResourceHandlerInlineCss: true - combinedResourceHandlerInlineJs: true - combinedResourceHandlerSuppressedResources: suppressedResource - cacheSettingApplicationMaxCapacity: 10 - cacheSettingApplicationTtl: 11 - cacheSettingSessionMaxCapacity: 12 - cacheSettingSessionTtl: 13 - - # primefaces namespace - primefaces: - privateCaptchaKey: myPrivateCaptchaKey - publicCaptchaKey: myKey - autoUpdate: auto - cacheProvider: org.primefaces.cache.DefaultCacheProvider - dir: ltr - earlyPostParamEvaluation: true - fontAwesome: true - interpolateClientSideValidationMessages: true - legacyWidgetNamespace: true - clientSideValidation: true - pushServerUrl: http://myhost.org - resetValues: true - secret: mySecret - submit: partial - theme: admin - transformMetadata: true - uploader: auto - mobile: - theme: cupertino - moveScriptsToBottom: true - - # bootsfaces namespace - bootsfaces: - theme: bootstrap - usetheme: true - useViewport: true - getFontawesomeFromCdn: true - getJqueryFromCdn: true - getJqueryuiFromCdn: true - getBootstrapFromCdn: true - block-ui: false - defaults: - renderLabel: myRenderLabel - decorator: false - - # angularfaces namespace - angularfaces: - addLabels: true - addMessages: true - translation: true - include-angular-js: true - include-j-query: true - include-j-query-ui: true - includeAngularMessages: true - clientSideMessages: true - include-main-js: true - - # butterfaces namespace - butterfaces: - ajaxDisableRenderRegionsOnRequest: true - ajaxProcessingGlyphiconOnRequest: Processing - ajaxProcessingTextOnRequest: Processing - autoTrimInputFields: true - provideBootstrap: true - provideJQuery: true - maxLengthText: '{0} of {1} characters' - noEntriesText: No matching entries... - spinnerText: Fetching data... - useCompressedResources: true - integration: - primefaces: - disableJQuery: true - treebox: - showClearButton: true - glyphicon: - collapsing: o_collape - expansion: o_expand - options: glyphicon glyphicon-th - refresh: glyphicon glyphicon-refresh - order: - left: glyphicon glyphicon-chevron-left - right: glyphicon glyphicon-chevron-right - sort: - ascending: glyphicon glyphicon-chevron-down - descending: glyphicon glyphicon-chevron-up - none: glyphicon glyphicon-chevron-right - - # adminfaces namespace - adminfaces: - loginPage: login - indexPage: index - dateFormat: dd-mm-yyyy - templatePath: my-template-path - breadcrumbSize: 50 - renderMessages: true - renderAjaxStatus: true - disableFilter: true - renderBreadCrumb: true - enableSlideMenu: true - enableRipple: true - rippleElements: .ripplelink,button.ui-button - skin: skin-blue - autoShowNavbar: true - ignoredResources: /rest, /pages/car-list - loadingImage: ajaxloadingbar.png - extensionLessUrls: true - renderControlSidebar: true - rippleMobileOnly: true - renderMenuSearch: true - autoHideMessages: true - messagesHideTimeout: 2200 - controlSidebar: - showOnMobile: true - leftMenuTemplate: true - fixedLayout: true - boxedLayout: true - sidebarCollapsed: true - expandOnHover: true - fixed: true - darkSkin: true - - # richafaces namespace - richfaces: - longValueWithDefault: -100 - intValue: -1 - intValueWithDefault: -1 - stringValue: "default name" - stringValueWithDefault: "default name 2" - enumValue: "Enum value" - enumValueWithDefault: "Enum value with default" - booleanValue: true - booleanValueWithDefault: true - multiValue1: "Multi1" - multiValue2: "Multi2" - facesContextReference: "Context reference" - dynamicValueWithDefault: "Dynamic value" - literalOnlyValue: "Literal only" - literalOnlyWithEl: "Literal only with el" - enableControlSkinning: true - enableControlSkinningClasses: true - skin: "This is a skin" - baseSkin: "This is a base skin" - resource-default-ttl: 86400 - resourceCacheSize: 111 - resourceDefaultVersion: "Resource default version" - cache: - lruMapCacheSize: 222 - resourceMapping: - enabled: true - location: "Location" - mappingFile: "Mapping file" - compressedStages: "Compressed stages" - packedStages: "Packed stages" - resourceOptimization: - enabled: true - compressionStages: "Compression stages" - packedStages: "Packed stages" - execute-awt-initializer: true - push: - handlerMapping: "Handler mapping" - jms: - connectionFactory: "Connection factory" - enabled: true - topicsNamespace: "Topics namespace" - connectionUsername: "Connection username" - connectionPassword: "Connection password" - initializeOnStartup: true - session: - maxInactiveInterval: 3000 - builtin: - sort: - enabled: true - filter: - enabled: true - queue: - enabled: true - datatableUsesViewLocale: "Data table uses view locale" - -joinfaces.test.list-c: foo, bar -joinfaces.test.list-d: - - foo - - bar -joinfaces.test: - charSequenceClass: java.lang.String - randomClass: java.lang.Void - classList: - - java.lang.String - - java.lang.Void - - java.util.List - -rewrite: - configReloading: false - scanLibDirectory: false - basePackages: - - my.package1 - - my.package2 From 48079874ae6afc23dc43465a777c27448b3fc1e3 Mon Sep 17 00:00:00 2001 From: Marcelo Romulo Fernandes Date: Tue, 16 Oct 2018 17:13:01 -0300 Subject: [PATCH 4/4] testing creation of AdminConfigWrapper instead of AdminConfig --- .../adminfaces/AdminfacesAutoConfigurationTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/joinfaces-autoconfigure/src/test/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesAutoConfigurationTest.java b/joinfaces-autoconfigure/src/test/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesAutoConfigurationTest.java index 0eb6afd15..dce9b566b 100644 --- a/joinfaces-autoconfigure/src/test/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesAutoConfigurationTest.java +++ b/joinfaces-autoconfigure/src/test/java/org/joinfaces/autoconfigure/adminfaces/AdminfacesAutoConfigurationTest.java @@ -54,6 +54,9 @@ public void testConfigurationProvider() { assertThat(context.getBean("adminSession", AdminSession.class)) .isNotNull(); + + assertThat(context.getBean(AdminConfigWrapper.class)) + .isNotNull(); }); } }