This is an automated email from the ASF dual-hosted git repository. danhaywood pushed a commit to branch CAUSEWAY-2485 in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 85acfa42eecd521017ba370f262558be976c2185 Author: danhaywood <[email protected]> AuthorDate: Fri May 19 08:54:04 2023 +0100 CAUSEWAY-2485: tidies up message demo --- .../demoapp/dom/services/core/ServicesMenu.java | 6 ++-- .../MessageServiceDemoPage-description.adoc | 35 +++++++++++++++++++ ...viceDemoVm.java => MessageServiceDemoPage.java} | 40 +++++++++++++--------- ...ayout.xml => MessageServiceDemoPage.layout.xml} | 6 ++-- .../MessageServiceDemoVm-description.adoc | 32 ----------------- 5 files changed, 65 insertions(+), 54 deletions(-) diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/ServicesMenu.java b/examples/demo/domain/src/main/java/demoapp/dom/services/core/ServicesMenu.java index 78c6ef3fdb..2f26b5272c 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/services/core/ServicesMenu.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/ServicesMenu.java @@ -34,7 +34,7 @@ import lombok.RequiredArgsConstructor; import demoapp.dom._infra.values.ValueHolderRepository; import demoapp.dom.services.core.errorreportingservice.ErrorReportingServiceDemoVm; import demoapp.dom.services.core.eventbusservice.EventBusServiceDemoPage; -import demoapp.dom.services.core.messageservice.MessageServiceDemoVm; +import demoapp.dom.services.core.messageservice.MessageServiceDemoPage; import demoapp.dom.services.core.wrapperFactory.WrapperFactoryEntity; @Named("demo.ServicesMenu") @@ -57,8 +57,8 @@ public class ServicesMenu { @Action @ActionLayout(cssClassFa="fa-sticky-note") - public MessageServiceDemoVm messageService(){ - return factoryService.viewModel(new MessageServiceDemoVm()); + public MessageServiceDemoPage messageService(){ + return factoryService.viewModel(new MessageServiceDemoPage()); } @Action diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoPage-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoPage-description.adoc new file mode 100644 index 0000000000..1717db3755 --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoPage-description.adoc @@ -0,0 +1,35 @@ +:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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 ag [...] + +Sometimes it's worth bringing something to the attention of the end-user. +The framework provides the link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/services/message/MessageService.html[MessageService] which allows a message to be raised, at three levels of severity. +The Wicket viewer shows these messages as "toast" popups. + +== How this demo works + +Use the actions on the left hand side to raise a message at each of the three different levels of severity supported. + +In terms of code: + +* to raise an informational message: ++ +[source,java,indent=0] +.MessageServiceDemoPage.java +---- +include::MessageServiceDemoPage.java[tags=informUser] +---- + +* to raise an warning: ++ +[source,java,indent=0] +.MessageServiceDemoPage.java +---- +include::MessageServiceDemoPage.java[tags=warnUser] +---- + +* to raise an error message ++ +[source,java,indent=0] +.MessageServiceDemoPage.java +---- +include::MessageServiceDemoPage.java[tags=raiseError] +---- diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm.java b/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoPage.java similarity index 71% rename from examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm.java rename to examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoPage.java index 5786f87bb9..c9d9fd986c 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoPage.java @@ -27,13 +27,14 @@ import org.apache.causeway.applib.annotation.ActionLayout.Position; import org.apache.causeway.applib.annotation.DomainObject; import org.apache.causeway.applib.annotation.Nature; import org.apache.causeway.applib.annotation.ObjectSupport; +import org.apache.causeway.applib.annotation.SemanticsOf; import org.apache.causeway.applib.services.message.MessageService; import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription; -@Named("demo.MessageServiceDemoVm") +@Named("demo.MessageServiceDemoPage") @DomainObject(nature=Nature.VIEW_MODEL) -public class MessageServiceDemoVm implements HasAsciiDocDescription { +public class MessageServiceDemoPage implements HasAsciiDocDescription { @Inject private MessageService messageService; @@ -41,36 +42,43 @@ public class MessageServiceDemoVm implements HasAsciiDocDescription { return "Message Demo"; } +//tag::informUser[] + @Action(semantics = SemanticsOf.SAFE) @ActionLayout( - describedAs = "Presents an info style message.", + cssClass = "btn-info", cssClassFa="fa-sticky-note", - position = Position.PANEL) - @Action - public MessageServiceDemoVm infoMessage(){ - System.err.println("EXEC"); + position = Position.PANEL + ) + public MessageServiceDemoPage informUser(){ messageService.informUser("Demo Info Message."); return this; } +//end::informUser[] +//tag::warnUser[] + @Action(semantics = SemanticsOf.SAFE) @ActionLayout( - describedAs = "Presents an warning style message.", + cssClass = "btn-warning", cssClassFa="fa-sticky-note", - position = Position.PANEL) - @Action - public MessageServiceDemoVm warnMessage(){ + position = Position.PANEL + ) + public MessageServiceDemoPage warnUser(){ messageService.warnUser("Demo Warning Message."); return this; } +//end::warnUser[] +//tag::raiseError[] + @Action(semantics = SemanticsOf.SAFE) @ActionLayout( - describedAs = "Presents an error style message.", + cssClass = "btn-danger", cssClassFa="fa-sticky-note", - position = Position.PANEL) - @Action - public MessageServiceDemoVm errorMessage(){ + position = Position.PANEL + ) + public MessageServiceDemoPage raiseError(){ messageService.raiseError("Demo Error Message."); return this; } - +//end::raiseError[] } diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoPage.layout.xml similarity index 92% rename from examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm.layout.xml rename to examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoPage.layout.xml index bec6370b06..106e5ac7dd 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm.layout.xml +++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoPage.layout.xml @@ -24,9 +24,9 @@ <bs3:col span="6"> <bs3:row> <bs3:col span="12"> - <cpt:action id="infoMessage" cssClass="btn-info"/> - <cpt:action id="warnMessage" cssClass="btn-warning"/> - <cpt:action id="errorMessage" cssClass="btn-danger"/> + <cpt:action id="informUser"/> + <cpt:action id="warnUser"/> + <cpt:action id="raiseError"/> </bs3:col> </bs3:row> <bs3:row> diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm-description.adoc deleted file mode 100644 index 60663506ea..0000000000 --- a/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm-description.adoc +++ /dev/null @@ -1,32 +0,0 @@ -:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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 ag [...] - -(since 2.0) - -The framework supports 3 styles of messages that can be presented to the user within the browser. - -[source,java] ----- -class MyViewmodel { - - @Inject private MessageService messageService; - - @Action - public MyViewmodel infoMessage(){ - messageService.informUser("Info Message."); - return this; - } - - @Action - public MyViewmodel warnMessage(){ - messageService.warnUser("Warning Message."); - return this; - } - - @Action - public MyViewmodel errorMessage(){ - messageService.raiseError("Error Message."); - return this; - } - -} -----
