You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2026/03/13 12:27:04 UTC
(myfaces-tobago) branch main updated: test(page): includeViewParams
This is an automated email from the ASF dual-hosted git repository.
hnoeth pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/main by this push:
new cf841abc08 test(page): includeViewParams
cf841abc08 is described below
commit cf841abc08d26516863dab453050e64a5326b172
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Fri Mar 6 13:37:07 2026 +0100
test(page): includeViewParams
Test added.
Issue: TOBAGO-2462
---
.../demo/test/page/ViewParamController.java | 50 ++++++++++++++++++
.../main/webapp/content/900-test/page/page.xhtml | 40 ++++++++++++++
.../tobago-example-demo/src/main/webapp/main.xhtml | 2 +-
.../src/test/typescript/page.test.ts | 61 ++++++++++++++++++++++
4 files changed, 152 insertions(+), 1 deletion(-)
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/test/page/ViewParamController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/test/page/ViewParamController.java
new file mode 100644
index 0000000000..7fd0f4c306
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/test/page/ViewParamController.java
@@ -0,0 +1,50 @@
+/*
+ * 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 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.apache.myfaces.tobago.example.demo.test.page;
+
+import jakarta.enterprise.context.RequestScoped;
+import jakarta.inject.Named;
+
+import java.io.Serializable;
+import java.time.Instant;
+
+@Named
+@RequestScoped
+public class ViewParamController implements Serializable {
+
+ private String parameter;
+
+ public String getParameter() {
+ return parameter;
+ }
+
+ public void setParameter(String parameter) {
+ this.parameter = parameter;
+ }
+
+ public long getTimestamp() {
+ return Instant.now().toEpochMilli();
+ }
+
+ public String reset() {
+ parameter = null;
+ return "/content/900-test/page/page.xhtml?faces-redirect=true";
+ }
+}
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/page/page.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/page/page.xhtml
new file mode 100644
index 0000000000..8cb7d5e64c
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/page/page.xhtml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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 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.
+-->
+
+<ui:composition template="/main.xhtml"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="jakarta.faces.core"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:ui="jakarta.faces.facelets">
+ <ui:define name="metadata">
+ <f:metadata>
+ <f:viewParam name="parameter" value="#{viewParamController.parameter}"/>
+ </f:metadata>
+ </ui:define>
+
+ <tc:section label="includeViewParams=true">
+ <tc:in id="param" label="Parameter from URL" value="#{viewParamController.parameter}" readonly="true"/>
+ <tc:out id="timestamp" label="Timestamp" value="#{viewParamController.timestamp}"/>
+
+ <tc:link id="addTobagoParamLink" label="add 'parameter=tobago' to URL" outcome="/content/900-test/page/page.xhtml">
+ <f:param name="parameter" value="tobago"/>
+ </tc:link>
+ <tc:button id="reset" label="Reset" action="#{viewParamController.reset}"/>
+ <tc:button id="submit" label="Submit"/>
+ </tc:section>
+</ui:composition>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/main.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/main.xhtml
index 251b6ab67b..68b8c2e8d0 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/main.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/main.xhtml
@@ -33,7 +33,7 @@
</f:metadata>
-->
- <tc:page id="page"
+ <tc:page id="page" includeViewParams="true"
label="#{'Tobago Demo - '.concat(navigationState.currentNode.label != null ? navigationState.currentNode.label : '')}">
<!--
diff --git a/tobago-example/tobago-example-demo/src/test/typescript/page.test.ts b/tobago-example/tobago-example-demo/src/test/typescript/page.test.ts
new file mode 100644
index 0000000000..e3a69645c1
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/test/typescript/page.test.ts
@@ -0,0 +1,61 @@
+/*
+ * 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 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.
+ */
+
+import {expect, Page, test} from "@playwright/test";
+
+test.describe("900-test/page/page.xhtml", () => {
+
+ test.beforeEach(async ({page}, testInfo) => {
+ await page.goto("/content/900-test/page/page.xhtml");
+ });
+
+ test("tc:page: includeViewParams", async ({page, browserName}) => {
+ const paramFromUrl = page.locator("input[id='page:mainForm:param::field']");
+ const addParamLink = page.locator("a[id='page:mainForm:addTobagoParamLink']");
+ const reset = page.locator("button[id='page:mainForm:reset']");
+ const submit = page.locator("button[id='page:mainForm:submit']");
+
+ let timestampValue: number;
+
+ timestampValue = await getCurrentTimestamp(page);
+ await addParamLink.click();
+ await expect.poll(() => getCurrentTimestamp(page)).toBeGreaterThan(timestampValue);
+ await expect(paramFromUrl).toHaveValue("tobago");
+
+ timestampValue = await getCurrentTimestamp(page);
+ await submit.click();
+ await expect.poll(() => getCurrentTimestamp(page)).toBeGreaterThan(timestampValue);
+ await expect(paramFromUrl).toHaveValue("tobago");
+
+ timestampValue = await getCurrentTimestamp(page);
+ await reset.click();
+ await expect.poll(() => getCurrentTimestamp(page)).toBeGreaterThan(timestampValue);
+ await expect(paramFromUrl).toHaveValue("");
+
+ timestampValue = await getCurrentTimestamp(page);
+ await submit.click();
+ await expect.poll(() => getCurrentTimestamp(page)).toBeGreaterThan(timestampValue);
+ await expect(paramFromUrl).toHaveValue("");
+ });
+
+ async function getCurrentTimestamp(page: Page): Promise<number> {
+ const timestamp = page.locator("tobago-out[id='page:mainForm:timestamp'] .form-control-plaintext");
+ return Number(await timestamp.textContent());
+ }
+});