You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2021/03/04 08:39:19 UTC
[myfaces-tobago] branch master updated: refactor(demo): refresh
popup content
This is an automated email from the ASF dual-hosted git repository.
bommel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/master by this push:
new 6c27890 refactor(demo): refresh popup content
6c27890 is described below
commit 6c278902a545dcca64f9968c5abb68780c7c1936
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Wed Mar 3 17:48:59 2021 +0100
refactor(demo): refresh popup content
Example for a popup where the content is refreshed with AJAX after two seconds.
---
.../myfaces/tobago/example/demo/PopupController.java | 16 ++++++++++++++++
.../webapp/content/20-component/060-popup/Popup.xhtml | 18 ++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/PopupController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/PopupController.java
index 50e05bf..013d14b 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/PopupController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/PopupController.java
@@ -21,8 +21,10 @@ package org.apache.myfaces.tobago.example.demo;
import javax.enterprise.context.SessionScoped;
+import javax.faces.event.AjaxBehaviorEvent;
import javax.inject.Named;
import java.io.Serializable;
+import java.time.LocalTime;
@SessionScoped
@Named
@@ -31,6 +33,7 @@ public class PopupController implements Serializable {
private boolean popup1Collapsed = true;
private String popup1Text;
private String popup2Text;
+ private String time;
public boolean isPopup1Collapsed() {
return popup1Collapsed;
@@ -63,4 +66,17 @@ public class PopupController implements Serializable {
public void setPopup2Text(final String popup2Text) {
this.popup2Text = popup2Text;
}
+
+ public String getTime() {
+ return time;
+ }
+
+ public void setTime(String time) {
+ this.time = time;
+ }
+
+ public void refreshContent(final AjaxBehaviorEvent event) throws InterruptedException {
+ Thread.sleep(2000);
+ time = LocalTime.now().toString();
+ }
}
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/060-popup/Popup.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/060-popup/Popup.xhtml
index ecf6faa..d301f96 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/060-popup/Popup.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/060-popup/Popup.xhtml
@@ -138,4 +138,22 @@
</tc:box>
</tc:popup>
</tc:section>
+
+ <tc:section label="Refresh Content">
+ <p>The content of the popup will be refreshed with AJAX after opening the popup. The refresh method waits two
+ seconds before execution.</p>
+ <tc:button label="Open Popup" immediate="true">
+ <tc:operation name="show" for="refreshPopup"/>
+ <f:ajax render="refreshPopup:refreshPopupContent" listener="#{popupController.refreshContent}"/>
+ </tc:button>
+
+ <tc:popup id="refreshPopup" collapsedMode="hidden" markup="small">
+ <tc:box id="refreshPopupContent" label="Current Time">
+ <tc:out label="Current Time" value="#{popupController.time}"/>
+ <tc:button label="Close" omit="true">
+ <tc:operation name="hide" for="refreshPopup"/>
+ </tc:button>
+ </tc:box>
+ </tc:popup>
+ </tc:section>
</ui:composition>