You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2021/02/03 12:13:47 UTC

[myfaces-tobago] 03/03: demo: example

This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git

commit 39e6f7d2f6984fb7b2d09c23ffa841dc0e3b71d8
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Wed Feb 3 13:10:19 2021 +0100

    demo: <f:viewAction> example
---
 .../tobago/example/demo/nonfacesrequest/FishPond.java    |  4 ++++
 .../30-concept/90-non-faces-request/x-fish-pond.xhtml    | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/nonfacesrequest/FishPond.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/nonfacesrequest/FishPond.java
index 91c75fe..b8ad51f 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/nonfacesrequest/FishPond.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/nonfacesrequest/FishPond.java
@@ -49,6 +49,10 @@ public class FishPond implements Serializable {
     fishes.put(4, "Tamboril");
   }
 
+  public void viewAction() {
+    LOG.info("View action called! selectedFishId='{}'", selectedFishId);
+  }
+
   public void action() {
     LOG.info("Event is called! selectedFishId='{}'", selectedFishId);
     // not needed for this example
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/90-non-faces-request/x-fish-pond.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/90-non-faces-request/x-fish-pond.xhtml
index 16a7132..a5af54a 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/90-non-faces-request/x-fish-pond.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/90-non-faces-request/x-fish-pond.xhtml
@@ -26,6 +26,7 @@
   <ui:define name="metadata">
     <f:metadata>
       <f:viewParam name="fishId" value="#{fishPond.selectedFishId}"/>
+      <f:viewAction action="#{fishPond.viewAction}"/>
       <f:event type="preRenderView" listener="#{fishPond.action}"/>
     </f:metadata>
   </ui:define>
@@ -42,6 +43,21 @@
                  action="/content/30-concept/90-non-faces-request/Non_Faces_Request.xhtml?faces-redirect=true"/>
     </tc:buttons>
 
+    <!-- todo: space between buttons and in -->
+
+    <tc:in label="Id:" value="#{fishPond.selectedFishId}">
+      <f:facet name="after">
+        <tc:link label="Go"
+                 action="/content/30-concept/90-non-faces-request/x-fish-pond.xhtml?faces-redirect=true&amp;includeViewParams=true"/>
+      </f:facet>
+    </tc:in>
+
+    <tc:panel>
+      This example uses
+      <code class="language-markup">&lt;f:viewParam/></code> (since JSF 2.0) and
+      <code class="language-markup">&lt;f:viewAction/></code> (since JSF 2.2).
+    </tc:panel>
+
   </tc:panel>
 
 </ui:composition>