You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by re...@apache.org on 2023/09/20 12:14:44 UTC
[wicket] branch test created (now ee032fc727)
This is an automated email from the ASF dual-hosted git repository.
reiern70 pushed a change to branch test
in repository https://gitbox.apache.org/repos/asf/wicket.git
at ee032fc727 [WICKET-7074] sample application showing error
This branch includes the following new commits:
new ee032fc727 [WICKET-7074] sample application showing error
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[wicket] 01/01: [WICKET-7074] sample application showing error
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reiern70 pushed a commit to branch test
in repository https://gitbox.apache.org/repos/asf/wicket.git
commit ee032fc72797fe1de6e4831a11a800732fca3892
Author: reiern70 <re...@gmail.com>
AuthorDate: Mon Sep 18 15:51:44 2023 -0500
[WICKET-7074] sample application showing error
---
.../examples/ajax/builtin/AjaxApplication.java | 24 +++++++++
.../wicket/examples/ajax/builtin/ErrorPage.html | 10 ++++
.../wicket/examples/ajax/builtin/ErrorPage.java | 4 ++
.../examples/ajax/builtin/ErrorRenderingPage.html | 18 +++++++
.../examples/ajax/builtin/ErrorRenderingPage.java | 59 ++++++++++++++++++++++
.../examples/ajax/builtin/ErrorRenderingPage.js | 7 +++
.../apache/wicket/examples/ajax/builtin/Index.html | 2 +
7 files changed, 124 insertions(+)
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/AjaxApplication.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/AjaxApplication.java
index 4436582cd2..ad27eb9e77 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/AjaxApplication.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/AjaxApplication.java
@@ -16,14 +16,19 @@
*/
package org.apache.wicket.examples.ajax.builtin;
+import org.apache.wicket.Application;
import org.apache.wicket.Component;
+import org.apache.wicket.DefaultExceptionMapper;
import org.apache.wicket.Page;
+import org.apache.wicket.RuntimeConfigurationType;
import org.apache.wicket.ajax.AjaxNewWindowNotifyingBehavior;
import org.apache.wicket.application.IComponentInitializationListener;
+import org.apache.wicket.core.request.handler.PageProvider;
import org.apache.wicket.examples.WicketExampleApplication;
import org.apache.wicket.examples.ajax.builtin.modal.ModalDialogPage;
import org.apache.wicket.examples.ajax.builtin.modal.ModalWindowPage;
import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.response.filter.AjaxServerAndClientTimeFilter;
@@ -37,6 +42,18 @@ public class AjaxApplication extends WicketExampleApplication
{
super.init();
+ setExceptionMapperProvider(()-> new DefaultExceptionMapper()
+ {
+ @Override
+ protected IRequestHandler mapUnexpectedExceptions(Exception e, Application application) {
+ if (e instanceof ErrorRenderingPage.WeirdException) {
+ System.out.println("ErrorRenderingPage!");
+ return createPageRequestHandler(new PageProvider(ErrorPage.class));
+ }
+ return super.mapUnexpectedExceptions(e, application);
+ }
+ });
+
getApplicationSettings().setUploadProgressUpdatesEnabled(true);
getResourceSettings().setThrowExceptionOnMissingResource(false);
@@ -71,10 +88,17 @@ public class AjaxApplication extends WicketExampleApplication
mountPage("world-clock", WorldClockPage.class);
mountPage("upload", FileUploadPage.class);
mountPage("download", AjaxDownloadPage.class);
+ mountPage("dynamicError", AjaxDownloadPage.class);
+ mountPage("error", ErrorPage.class);
mountResource("dynamic-text-file", AjaxDownloadPage.DynamicTextFileResource.instance);
}
+ @Override
+ public RuntimeConfigurationType getConfigurationType() {
+ return RuntimeConfigurationType.DEPLOYMENT;
+ }
+
/**
* @see org.apache.wicket.Application#getHomePage()
*/
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorPage.html b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorPage.html
new file mode 100644
index 0000000000..7942b6a282
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorPage.html
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<html xmlns:wicket="http://wicket.apache.org">
+<wicket:extend>
+<div class="container">
+ <div>
+ Unexpected AJAX error
+ </div>
+</div>
+</wicket:extend>
+</html>
\ No newline at end of file
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorPage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorPage.java
new file mode 100644
index 0000000000..34fd15fc52
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorPage.java
@@ -0,0 +1,4 @@
+package org.apache.wicket.examples.ajax.builtin;
+
+public class ErrorPage extends BasePage {
+}
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorRenderingPage.html b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorRenderingPage.html
new file mode 100644
index 0000000000..5d5c055346
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorRenderingPage.html
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<html xmlns:wicket="http://wicket.apache.org">
+<wicket:extend>
+<div class="container">
+ <div>
+ <p>
+ <a wicket:id="click">Produce error</a>
+ </p>
+ </div>
+ <div>
+ <p wicket:id="error">
+ </p>
+ <p wicket:id="error1">
+ </p>
+ </div>
+</div>
+</wicket:extend>
+</html>
\ No newline at end of file
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorRenderingPage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorRenderingPage.java
new file mode 100644
index 0000000000..2104b76c3b
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorRenderingPage.java
@@ -0,0 +1,59 @@
+package org.apache.wicket.examples.ajax.builtin;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.JavaScriptHeaderItem;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.request.resource.JavaScriptResourceReference;
+
+public class ErrorRenderingPage extends BasePage
+{
+ private static final JavaScriptResourceReference JS = new JavaScriptResourceReference(ErrorRenderingPage.class, "ErrorRenderingPage.js");
+ public static class WeirdException extends UnsupportedOperationException {
+
+ }
+ private boolean produceError = false;
+
+ private final Label error;
+ private final Label error1;
+
+ public ErrorRenderingPage()
+ {
+ add(new AjaxLink<>("click")
+ {
+ @Override
+ public void onClick(AjaxRequestTarget target)
+ {
+ produceError = true;
+ target.add(error1);
+ target.add(error);
+ }
+ });
+
+ add(error = new Label("error", "Click above to trigger dynamic error")
+ {
+ @Override
+ protected void onBeforeRender()
+ {
+ super.onBeforeRender();
+ if (produceError)
+ {
+ produceError = false;
+ throw new WeirdException();
+ }
+ }
+ });
+ error.setOutputMarkupId(true);
+
+ add(error1 = new Label("error1", "No error!"));
+ error1.setOutputMarkupId(true);
+ }
+
+ @Override
+ public void renderHead(IHeaderResponse response) {
+ super.renderHead(response);
+ response.render(JavaScriptHeaderItem.forReference(JS));
+ }
+}
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorRenderingPage.js b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorRenderingPage.js
new file mode 100644
index 0000000000..9a6abb6490
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ErrorRenderingPage.js
@@ -0,0 +1,7 @@
+Wicket.Event.subscribe('/ajax/call/success', function(attrs, jqXHR, data, textStatus) {
+ console.log(data);
+});
+
+Wicket.Event.subscribe('/ajax/call/failure', function(jqEvent, attributes, jqXHR, errorThrown, textStatus) {
+ console.log(errorThrown);
+});
\ No newline at end of file
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/Index.html b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/Index.html
index 0d66d0a7fc..5eb6721fb9 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/Index.html
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/Index.html
@@ -37,6 +37,8 @@
<a href="WorldClockPage.html">World Clock Example</a>: demonstrates a single component with AjaxTimerBehavior updating multiple components
<br/><br/>
<a href="AjaxDownloadPage.html">Ajax Download</a>: download initiated via Ajax
+<br/><br/>
+<a href="ErrorRenderingPage.html">Dynamic AJAX error</a>
</wicket:link>
</wicket:extend>
\ No newline at end of file