From 65b2ff352ddbc711516c240391f5a797dc326f20 Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Sun, 17 Jul 2016 13:59:18 +0200 Subject: [PATCH] [portlet] Fix the build against Wicket 8.x --- pom.xml | 22 ++++++------ .../wicketstuff-portlet-examples/pom.xml | 19 ++-------- .../examples/ajax/builtin/ChoicePage.java | 8 ++--- .../examples/ajax/builtin/EffectsPage.java | 9 ++--- .../examples/ajax/builtin/FileUploadPage.java | 18 +++------- .../examples/ajax/builtin/LinksPage.java | 10 +++--- .../examples/ajax/builtin/RatingsPage.java | 14 ++++---- .../examples/ajax/builtin/TodoList.java | 35 ++++++------------- .../wicket/examples/ajax/prototype/Index.java | 3 +- .../wicket/examples/asemail/MailTemplate.java | 14 ++++---- .../events/DecoupledAjaxUpdatePage.java | 11 ++---- .../navomatic/NavomaticApplication.java | 29 +++++++-------- .../wicket/examples/source/SourcesPage.java | 13 ++++--- .../CheckedSelectableFolderContent.java | 10 +++--- .../tree/content/EditableFolderContent.java | 8 +++-- .../tree/content/MultiLineLabelContent.java | 11 ++---- .../content/MultiSelectableFolderContent.java | 10 +++--- .../tree/content/SelectableFolderContent.java | 10 +++--- .../apache/wicket/portlet/PortletFilter.java | 23 +++--------- .../wicket/portlet/PortletRequestMapper.java | 14 ++++---- .../request/mapper/PortletSystemMapper.java | 30 +++------------- 21 files changed, 119 insertions(+), 202 deletions(-) diff --git a/pom.xml b/pom.xml index af3c59e82d..6a25d0180f 100644 --- a/pom.xml +++ b/pom.xml @@ -259,21 +259,21 @@ false 4.3.11.Final - 3.18.2-GA - 8.1.16.v20140903 + 3.20.0-GA + 9.3.10.v20160621 2.0.1 - 1.2.3 - 1.7.12 - 1.1.3 + 1.2.6 + 1.7.21 + 1.1.7 1.2.17 - 4.1.6.RELEASE - 3.1 - 2.1 - 2.11.8 + 4.3.1.RELEASE + 3.2.4 + 2.4 + 2.12.0-M5 - 3.0.4 + 3.3.9 @@ -1290,7 +1290,7 @@ true utf-8 - 1.7 + 1.8 100 diff --git a/portlet-parent/wicketstuff-portlet-examples/pom.xml b/portlet-parent/wicketstuff-portlet-examples/pom.xml index b453c7288b..99007d1ba3 100644 --- a/portlet-parent/wicketstuff-portlet-examples/pom.xml +++ b/portlet-parent/wicketstuff-portlet-examples/pom.xml @@ -28,8 +28,8 @@ javax.servlet - servlet-api - 2.5 + javax.servlet-api + 3.1.0 provided @@ -243,19 +243,6 @@ - - true - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - UTF-8 - true - true - - org.eclipse.jetty jetty-maven-plugin @@ -292,7 +279,7 @@ javax.servlet javax.servlet-api - 3.0.1 + 3.1.0 provided diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ChoicePage.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ChoicePage.java index c8a727fb75..fbb9683790 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ChoicePage.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ChoicePage.java @@ -100,10 +100,10 @@ public List getObject() add(form); final DropDownChoice makes = new DropDownChoice<>("makes", - new PropertyModel(this, "selectedMake"), makeChoices); + new PropertyModel<>(this, "selectedMake"), makeChoices); final DropDownChoice models = new DropDownChoice<>("models", - new Model(), modelChoices); + new Model<>(), modelChoices); models.setOutputMarkupId(true); form.add(makes); @@ -116,9 +116,9 @@ public List getObject() form.add(new AjaxButton("go") { @Override - protected void onAfterSubmit(AjaxRequestTarget target, Form form) + protected void onAfterSubmit(AjaxRequestTarget target) { - super.onAfterSubmit(target, form); + super.onAfterSubmit(target); info("You have selected: " + makes.getModelObject() + " " + models.getModelObject()); target.add(feedback); } diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/EffectsPage.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/EffectsPage.java index a78e4b8f45..38594b458c 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/EffectsPage.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/EffectsPage.java @@ -16,6 +16,8 @@ */ package org.apache.wicket.examples.ajax.builtin; +import java.util.Optional; + import org.apache.wicket.ajax.AjaxChannel; import org.apache.wicket.ajax.AjaxChannel.Type; import org.apache.wicket.ajax.AjaxRequestTarget; @@ -105,15 +107,14 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) add(new AjaxFallbackLink("c2-link") { @Override - public void onClick(AjaxRequestTarget target) + public void onClick(Optional targetOptional) { counter2++; - if (target != null) - { + targetOptional.ifPresent(target -> { target.add(c2); target.appendJavaScript(String.format("jQuery('#%s').effect('highlight');", c2.getMarkupId())); - } + }); } @Override diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/FileUploadPage.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/FileUploadPage.java index 1d1c69befa..694c029eac 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/FileUploadPage.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/FileUploadPage.java @@ -26,7 +26,6 @@ import org.apache.wicket.markup.html.form.upload.FileUpload; import org.apache.wicket.markup.html.form.upload.FileUploadField; import org.apache.wicket.markup.html.panel.FeedbackPanel; -import org.apache.wicket.model.AbstractReadOnlyModel; import org.apache.wicket.model.Model; import org.apache.wicket.util.lang.Bytes; import org.apache.wicket.validation.validator.StringValidator; @@ -82,22 +81,13 @@ protected void onSubmit() add(form); // create a textfield to demo non-file content - form.add(text = new TextField<>("text", new Model())); + form.add(text = new TextField<>("text", new Model<>())); text.add(StringValidator.minimumLength(2)); // create the file upload field form.add(file = new FileUploadField("file")); - form.add(new Label("max", new AbstractReadOnlyModel() - { - private static final long serialVersionUID = 1L; - - @Override - public String getObject() - { - return form.getMaxSize().toString(); - } - })); + form.add(new Label("max", () -> form.getMaxSize().toString())); form.add(new UploadProgressBar("progress", form, file)); @@ -107,7 +97,7 @@ public String getObject() private static final long serialVersionUID = 1L; @Override - protected void onSubmit(AjaxRequestTarget target, Form form) + protected void onSubmit(AjaxRequestTarget target) { info("This request was processed using AJAX"); @@ -116,7 +106,7 @@ protected void onSubmit(AjaxRequestTarget target, Form form) } @Override - protected void onError(AjaxRequestTarget target, Form form) + protected void onError(AjaxRequestTarget target) { // update feedback to display errors target.add(feedback); diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/LinksPage.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/LinksPage.java index 5594db804d..952b0a84fc 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/LinksPage.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/LinksPage.java @@ -17,6 +17,7 @@ package org.apache.wicket.examples.ajax.builtin; import java.util.List; +import java.util.Optional; import org.apache.wicket.Component; import org.apache.wicket.WicketRuntimeException; @@ -97,21 +98,18 @@ public void onClick(AjaxRequestTarget target) add(new AjaxFallbackLink("c2-link") { @Override - public void onClick(AjaxRequestTarget target) + public void onClick(Optional targetOptional) { counter2++; // notice that for a fallback link we need to makesure the // target is not null. if the target is null ajax failed and the // fallback was used, so there is no need to do any ajax-related // processing. - if (target != null) - { - target.add(c2); - } + targetOptional.ifPresent(target -> target.add(c2)); } }); - add(new IndicatingAjaxLink("c3-link") + add(new IndicatingAjaxLink("c3-link") { @Override public void onClick(AjaxRequestTarget target) diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/RatingsPage.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/RatingsPage.java index 8e026ac429..624d5ad150 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/RatingsPage.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/RatingsPage.java @@ -16,7 +16,8 @@ */ package org.apache.wicket.examples.ajax.builtin; -import org.apache.wicket.util.io.IClusterable; +import java.util.Optional; + import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.extensions.rating.RatingPanel; import org.apache.wicket.markup.html.link.Link; @@ -27,6 +28,7 @@ import org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler; import org.apache.wicket.request.resource.PackageResourceReference; import org.apache.wicket.request.resource.ResourceReference; +import org.apache.wicket.util.io.IClusterable; /** @@ -172,7 +174,7 @@ public int getSumOfRatings() public RatingsPage() { add(new RatingPanel("rating1", new PropertyModel(rating1, "rating"), 5, - new PropertyModel(rating1, "nrOfVotes"), true) + new PropertyModel<>(rating1, "nrOfVotes"), true) { @Override public boolean onIsStarActive(int star) @@ -181,15 +183,15 @@ public boolean onIsStarActive(int star) } @Override - public void onRated(int rating, AjaxRequestTarget target) + public void onRated(int rating, Optional target) { RatingsPage.rating1.addRating(rating); } }); add(new RatingPanel("rating2", new PropertyModel(rating2, "rating"), - new Model(5), new PropertyModel(rating2, "nrOfVotes"), - new PropertyModel(this, "hasVoted"), true) + new Model<>(5), new PropertyModel<>(rating2, "nrOfVotes"), + new PropertyModel<>(this, "hasVoted"), true) { @Override protected String getActiveStarUrl(int iteration) @@ -212,7 +214,7 @@ public boolean onIsStarActive(int star) } @Override - public void onRated(int rating, AjaxRequestTarget target) + public void onRated(int rating, Optional target) { // make sure the user can't vote again hasVoted = Boolean.TRUE; diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/TodoList.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/TodoList.java index 9be42036ca..8d51459ffb 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/TodoList.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/TodoList.java @@ -18,6 +18,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Optional; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxFallbackLink; @@ -165,7 +166,7 @@ public class AddItemsContainer extends WebMarkupContainer private boolean linkVisible = true; /** Link for displaying the AddTodo form. */ - private final class AddTodoLink extends AjaxFallbackLink + private final class AddTodoLink extends AjaxFallbackLink { /** Constructor. */ private AddTodoLink(String id) @@ -180,9 +181,9 @@ private AddTodoLink(String id) * the request target. */ @Override - public void onClick(AjaxRequestTarget target) + public void onClick(Optional target) { - onShowForm(target); + onShowForm(target.get()); } /** @@ -201,7 +202,7 @@ public boolean isVisible() * Link for removing all completed todos from the list, this link follows the same * visibility rules as the add link. */ - private final class RemoveCompletedTodosLink extends AjaxFallbackLink + private final class RemoveCompletedTodosLink extends AjaxFallbackLink { /** * Constructor. @@ -214,13 +215,10 @@ public RemoveCompletedTodosLink(String id) super(id); } - /** - * @see AjaxFallbackLink#onClick(org.apache.wicket.ajax.AjaxRequestTarget) - */ @Override - public void onClick(AjaxRequestTarget target) + public void onClick(Optional target) { - onRemoveCompletedTodos(target); + onRemoveCompletedTodos(target.get()); } /** @@ -256,7 +254,7 @@ public AddTodoForm(String id) add(new AjaxButton("add", this) { @Override - protected void onSubmit(AjaxRequestTarget target, Form form) + protected void onSubmit(AjaxRequestTarget target) { // retrieve the todo item TodoItem item = (TodoItem)getParent().getDefaultModelObject(); @@ -264,25 +262,15 @@ protected void onSubmit(AjaxRequestTarget target, Form form) // add the item onAdd(item, target); } - - @Override - protected void onError(AjaxRequestTarget target, Form form) - { - } }); add(new AjaxButton("cancel", this) { @Override - public void onSubmit(AjaxRequestTarget target, Form form) + public void onSubmit(AjaxRequestTarget target) { onCancelTodo(target); } - - @Override - protected void onError(AjaxRequestTarget target, Form form) - { - } }); } @@ -413,11 +401,8 @@ public TodoList() add(new AjaxFallbackLink("ajaxback") { - /** - * @see org.apache.wicket.ajax.markup.html.AjaxFallbackLink#onClick(org.apache.wicket.ajax.AjaxRequestTarget) - */ @Override - public void onClick(AjaxRequestTarget target) + public void onClick(Optional target) { setResponsePage(getPage()); } diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/prototype/Index.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/prototype/Index.java index 1c21ac8c05..ef9f2737bf 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/prototype/Index.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/ajax/prototype/Index.java @@ -18,7 +18,6 @@ import org.apache.wicket.examples.WicketExamplePage; import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.link.ILinkListener; import org.apache.wicket.markup.html.link.Link; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.request.IRequestHandler; @@ -81,7 +80,7 @@ public void onClick() protected String getOnClickScript(CharSequence url) { IRequestHandler handler = new ListenerInterfaceRequestHandler( - new PageAndComponentProvider(getPage(), this), ILinkListener.INTERFACE); + new PageAndComponentProvider(getPage(), this)); Url componentUrl = RequestCycle.get().mapUrlFor(handler); componentUrl.addQueryParameter("anticache", Math.random()); return new AppendingStringBuffer("new Ajax.Updater('counter', '").append( diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/asemail/MailTemplate.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/asemail/MailTemplate.java index 720bf05aca..3b09b4c016 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/asemail/MailTemplate.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/asemail/MailTemplate.java @@ -83,7 +83,7 @@ public MailTemplate(final PageParameters parameters) private static final long serialVersionUID = 1L; @Override - protected void onSubmit(AjaxRequestTarget target, Form form) + protected void onSubmit(AjaxRequestTarget target) { PageParameters parameters = new PageParameters(); parameters.set("name", name); @@ -95,7 +95,7 @@ protected void onSubmit(AjaxRequestTarget target, Form form) } @Override - protected void onError(AjaxRequestTarget target, Form form) + protected void onError(AjaxRequestTarget target) { target.add(feedback); } @@ -106,17 +106,17 @@ protected void onError(AjaxRequestTarget target, Form form) private static final long serialVersionUID = 1L; @Override - protected void onSubmit(AjaxRequestTarget target, Form form) + protected void onSubmit(AjaxRequestTarget target) { CharSequence panelHtml = ComponentRenderer.renderComponent(new MailTemplatePanel("someId", - new PropertyModel(MailTemplate.this, "name"))); + new PropertyModel<>(MailTemplate.this, "name"))); updateResult(result, panelHtml, target); target.add(feedback); } @Override - protected void onError(AjaxRequestTarget target, Form form) + protected void onError(AjaxRequestTarget target) { target.add(feedback); } @@ -127,7 +127,7 @@ protected void onError(AjaxRequestTarget target, Form form) private static final long serialVersionUID = 1L; @Override - protected void onSubmit(AjaxRequestTarget target, Form form) + protected void onSubmit(AjaxRequestTarget target) { Map variables = new HashMap<>(); variables.put("name", name); @@ -145,7 +145,7 @@ protected void onSubmit(AjaxRequestTarget target, Form form) } @Override - protected void onError(AjaxRequestTarget target, Form form) + protected void onError(AjaxRequestTarget target) { target.add(feedback); } diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/events/DecoupledAjaxUpdatePage.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/events/DecoupledAjaxUpdatePage.java index 5e2e4b50ea..7a7f3bf00a 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/events/DecoupledAjaxUpdatePage.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/events/DecoupledAjaxUpdatePage.java @@ -52,24 +52,17 @@ public DecoupledAjaxUpdatePage() add(form); // add the textfield that will update the counter value - form.add(new TextField("counter", new PropertyModel(this, "counter"), + form.add(new TextField<>("counter", new PropertyModel<>(this, "counter"), Integer.class).setRequired(true)); // add button that will broadcast counter update event form.add(new AjaxButton("submit") { - @Override - protected void onSubmit(AjaxRequestTarget target, Form form) + protected void onSubmit(AjaxRequestTarget target) { send(getPage(), Broadcast.BREADTH, new CounterUpdate(target)); } - - @Override - protected void onError(AjaxRequestTarget target, Form form) - { - } - }); } diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/navomatic/NavomaticApplication.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/navomatic/NavomaticApplication.java index bc6ab58079..693a155d9b 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/navomatic/NavomaticApplication.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/navomatic/NavomaticApplication.java @@ -16,9 +16,12 @@ */ package org.apache.wicket.examples.navomatic; +import org.apache.wicket.Component; import org.apache.wicket.Page; +import org.apache.wicket.application.IComponentInstantiationListener; import org.apache.wicket.examples.WicketExampleApplication; -import org.apache.wicket.markup.html.link.DisabledLinkBehavior; +import org.apache.wicket.markup.html.link.AbstractLink; +import org.apache.wicket.markup.html.link.DisabledAttributeLinkBehavior; /** * Application class. @@ -27,29 +30,27 @@ */ public class NavomaticApplication extends WicketExampleApplication { - /** - * Constructor. - */ - public NavomaticApplication() - { - } - @Override protected void init() { super.init(); - getComponentInstantiationListeners().add(new DisabledLinkBehavior.LinkInstantiationListener()); + getComponentInstantiationListeners().add(new IComponentInstantiationListener() + { + @Override + public void onInstantiation(Component component) + { + if (component instanceof AbstractLink) + { + component.add(new DisabledAttributeLinkBehavior()); + } + } + }); } - /** - * @see org.apache.wicket.Application#getHomePage() - */ @Override public Class getHomePage() { return Page1.class; } - - } diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/source/SourcesPage.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/source/SourcesPage.java index 830abc2450..5cc18765b1 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/source/SourcesPage.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/source/SourcesPage.java @@ -29,9 +29,12 @@ import java.util.Collections; import java.util.Enumeration; import java.util.List; +import java.util.Optional; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import com.uwyn.jhighlight.renderer.Renderer; +import com.uwyn.jhighlight.renderer.XhtmlRendererFactory; import org.apache.wicket.Component; import org.apache.wicket.Page; import org.apache.wicket.WicketRuntimeException; @@ -58,9 +61,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.uwyn.jhighlight.renderer.Renderer; -import com.uwyn.jhighlight.renderer.XhtmlRendererFactory; - /** * Displays the resources in a packages directory in a browsable format. * @@ -293,15 +293,14 @@ protected void populateItem(final ListItem item) item.getModel()) { @Override - public void onClick(AjaxRequestTarget target) + public void onClick(Optional targetOptional) { setName(getDefaultModelObjectAsString()); - if (target != null) - { + targetOptional.ifPresent(target -> { target.add(codePanel); target.add(filename); - } + }); } @Override diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/CheckedSelectableFolderContent.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/CheckedSelectableFolderContent.java index e2467f6b58..920b88c73a 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/CheckedSelectableFolderContent.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/CheckedSelectableFolderContent.java @@ -16,6 +16,8 @@ */ package org.apache.wicket.examples.tree.content; +import java.util.Optional; + import org.apache.wicket.Component; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.examples.tree.Foo; @@ -62,7 +64,7 @@ protected void onUpdate(AjaxRequestTarget target) foo = foo.getParent(); } - tree.updateBranch(foo, target); + tree.updateBranch(foo, Optional.of(target)); } /** @@ -75,9 +77,9 @@ protected boolean isClickable() } @Override - protected void onClick(AjaxRequestTarget target) + protected void onClick(Optional targetOptional) { - CheckedSelectableFolderContent.this.select(getModelObject(), tree, target); + CheckedSelectableFolderContent.this.select(getModelObject(), tree, targetOptional); } @Override @@ -87,4 +89,4 @@ protected boolean isSelected() } }; } -} \ No newline at end of file +} diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/EditableFolderContent.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/EditableFolderContent.java index 9e9438f8d0..6776eaa6ae 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/EditableFolderContent.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/EditableFolderContent.java @@ -16,6 +16,8 @@ */ package org.apache.wicket.examples.tree.content; +import java.util.Optional; + import org.apache.wicket.Component; import org.apache.wicket.MarkupContainer; import org.apache.wicket.ajax.AjaxRequestTarget; @@ -72,7 +74,7 @@ protected void onComponentTag(ComponentTag tag) @Override protected Component newLabelComponent(String id, final IModel model) { - return new AjaxEditableLabel(id, new PropertyModel(model, "bar")) + return new AjaxEditableLabel(id, new PropertyModel<>(model, "bar")) { @Override protected void onSubmit(AjaxRequestTarget target) @@ -82,10 +84,10 @@ protected void onSubmit(AjaxRequestTarget target) /** * update whole node in case we're located inside TableTree */ - tree.updateNode(model.getObject(), target); + tree.updateNode(model.getObject(), Optional.of(target)); } }; } }; } -} \ No newline at end of file +} diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/MultiLineLabelContent.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/MultiLineLabelContent.java index c845d46271..3225139632 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/MultiLineLabelContent.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/MultiLineLabelContent.java @@ -37,13 +37,6 @@ public class MultiLineLabelContent extends Content public Component newContentComponent(String id, final AbstractTree tree, final IModel model) { - return new MultiLineLabel(id, new AbstractReadOnlyModel() - { - @Override - public String getObject() - { - return model.getObject().getId() + " " + LOREM_IPSUM; - } - }); + return new MultiLineLabel(id, () -> model.getObject().getId() + " " + LOREM_IPSUM); } -} \ No newline at end of file +} diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/MultiSelectableFolderContent.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/MultiSelectableFolderContent.java index e4eb1dd2e8..f7383982e3 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/MultiSelectableFolderContent.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/MultiSelectableFolderContent.java @@ -16,6 +16,8 @@ */ package org.apache.wicket.examples.tree.content; +import java.util.Optional; + import org.apache.wicket.Component; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.examples.tree.Foo; @@ -51,7 +53,7 @@ protected boolean isSelected(Foo foo) return selected.contains(foo); } - protected void toggle(Foo foo, AbstractTree tree, final AjaxRequestTarget target) + protected void toggle(Foo foo, AbstractTree tree, final Optional target) { if (isSelected(foo)) { @@ -82,9 +84,9 @@ protected boolean isClickable() } @Override - protected void onClick(AjaxRequestTarget target) + protected void onClick(Optional targetOptional) { - MultiSelectableFolderContent.this.toggle(getModelObject(), tree, target); + MultiSelectableFolderContent.this.toggle(getModelObject(), tree, targetOptional); } @Override @@ -94,4 +96,4 @@ protected boolean isSelected() } }; } -} \ No newline at end of file +} diff --git a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/SelectableFolderContent.java b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/SelectableFolderContent.java index 247eb1fcbc..c43e5a89cd 100644 --- a/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/SelectableFolderContent.java +++ b/portlet-parent/wicketstuff-portlet-examples/src/main/java/org/apache/wicket/examples/tree/content/SelectableFolderContent.java @@ -16,6 +16,8 @@ */ package org.apache.wicket.examples.tree.content; +import java.util.Optional; + import org.apache.wicket.Component; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.examples.tree.Foo; @@ -64,7 +66,7 @@ protected boolean isSelected(Foo foo) } } - protected void select(Foo foo, AbstractTree tree, final AjaxRequestTarget target) + protected void select(Foo foo, AbstractTree tree, final Optional target) { if (selected != null) { @@ -96,9 +98,9 @@ protected boolean isClickable() } @Override - protected void onClick(AjaxRequestTarget target) + protected void onClick(Optional targetOptional) { - SelectableFolderContent.this.select(getModelObject(), tree, target); + SelectableFolderContent.this.select(getModelObject(), tree, targetOptional); } @Override @@ -108,4 +110,4 @@ protected boolean isSelected() } }; } -} \ No newline at end of file +} diff --git a/portlet-parent/wicketstuff-portlet/src/main/java/org/apache/wicket/portlet/PortletFilter.java b/portlet-parent/wicketstuff-portlet/src/main/java/org/apache/wicket/portlet/PortletFilter.java index a91213090b..e3305bd8ce 100644 --- a/portlet-parent/wicketstuff-portlet/src/main/java/org/apache/wicket/portlet/PortletFilter.java +++ b/portlet-parent/wicketstuff-portlet/src/main/java/org/apache/wicket/portlet/PortletFilter.java @@ -29,14 +29,9 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import org.apache.wicket.IPageRendererProvider; -import org.apache.wicket.IRequestCycleProvider; -import org.apache.wicket.core.request.handler.RenderPageRequestHandler; import org.apache.wicket.protocol.http.WicketFilter; import org.apache.wicket.request.UrlRenderer; import org.apache.wicket.request.cycle.RequestCycle; -import org.apache.wicket.request.cycle.RequestCycleContext; -import org.apache.wicket.request.handler.render.PageRenderer; import org.apache.wicket.request.http.WebResponse; import org.apache.wicket.request.http.flow.AbortWithHttpErrorCodeException; import org.apache.wicket.settings.RequestCycleSettings.RenderStrategy; @@ -68,22 +63,12 @@ public void init(boolean isServlet, FilterConfig filterConfig) throws ServletExc getApplication().getMarkupSettings().setMarkupIdGenerator(new PortletMarkupIdGenerator()); getApplication().setRootRequestMapper(new PortletRequestMapper(getApplication())); //Application must use the portlet specific page renderer provider. - getApplication().setPageRendererProvider(new IPageRendererProvider() { - @Override - public PageRenderer get(RenderPageRequestHandler handler) { - return new PortletPageRenderer(handler); - } - }); + getApplication().setPageRendererProvider(PortletPageRenderer::new); // fix for https://github.com/wicketstuff/core/issues/478 issue - getApplication().setRequestCycleProvider(new IRequestCycleProvider() { + getApplication().setRequestCycleProvider(context -> new RequestCycle(context) { @Override - public RequestCycle get(RequestCycleContext context) { - return new RequestCycle(context) { - @Override - protected UrlRenderer newUrlRenderer() { - return new PortletUrlRenderer(getRequest()); - } - }; + protected UrlRenderer newUrlRenderer() { + return new PortletUrlRenderer(getRequest()); } }); } diff --git a/portlet-parent/wicketstuff-portlet/src/main/java/org/apache/wicket/portlet/PortletRequestMapper.java b/portlet-parent/wicketstuff-portlet/src/main/java/org/apache/wicket/portlet/PortletRequestMapper.java index ebe00e073a..b6caf7264a 100644 --- a/portlet-parent/wicketstuff-portlet/src/main/java/org/apache/wicket/portlet/PortletRequestMapper.java +++ b/portlet-parent/wicketstuff-portlet/src/main/java/org/apache/wicket/portlet/PortletRequestMapper.java @@ -26,10 +26,8 @@ import javax.servlet.http.HttpServletRequest; import org.apache.wicket.Application; -import org.apache.wicket.IResourceListener; -import org.apache.wicket.RequestListenerInterface; +import org.apache.wicket.IRequestListener; import org.apache.wicket.SystemMapper; -import org.apache.wicket.behavior.IBehaviorListener; import org.apache.wicket.core.request.handler.BookmarkableListenerInterfaceRequestHandler; import org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler; import org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler; @@ -39,6 +37,7 @@ import org.apache.wicket.request.IRequestHandler; import org.apache.wicket.request.Request; import org.apache.wicket.request.Url; +import org.apache.wicket.request.component.IRequestableComponent; import org.apache.wicket.request.cycle.RequestCycle; import org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler; import org.apache.wicket.request.resource.IResource; @@ -104,17 +103,16 @@ else if (requestHandler instanceof BookmarkablePageRequestHandler) { } //added mapping for request handlers with type of BookmarkableListenerInterfaceRequestHandler. The handling is the same as for handlers of type ListenerInterfaceRequestHandler else if (requestHandler instanceof ListenerInterfaceRequestHandler || requestHandler instanceof BookmarkableListenerInterfaceRequestHandler) { - RequestListenerInterface listenerInterface; + IRequestableComponent component; if (requestHandler instanceof ListenerInterfaceRequestHandler) { - listenerInterface = ((ListenerInterfaceRequestHandler) requestHandler).getListenerInterface(); + component = ((ListenerInterfaceRequestHandler) requestHandler).getComponent(); } else { - listenerInterface = ((BookmarkableListenerInterfaceRequestHandler)requestHandler).getListenerInterface(); + component = ((BookmarkableListenerInterfaceRequestHandler)requestHandler).getComponent(); } - Class listenerClass = listenerInterface.getMethod().getDeclaringClass(); - if ((IResourceListener.class.isAssignableFrom(listenerClass)) || (IBehaviorListener.class.isAssignableFrom(listenerClass))) { + if (component instanceof IRequestListener) { url = encodeResourceUrl(url); } else { diff --git a/portlet-parent/wicketstuff-portlet/src/main/java/org/apache/wicket/portlet/request/mapper/PortletSystemMapper.java b/portlet-parent/wicketstuff-portlet/src/main/java/org/apache/wicket/portlet/request/mapper/PortletSystemMapper.java index 9d8d7efeab..22b2c125aa 100644 --- a/portlet-parent/wicketstuff-portlet/src/main/java/org/apache/wicket/portlet/request/mapper/PortletSystemMapper.java +++ b/portlet-parent/wicketstuff-portlet/src/main/java/org/apache/wicket/portlet/request/mapper/PortletSystemMapper.java @@ -1,6 +1,7 @@ package org.apache.wicket.portlet.request.mapper; import java.util.Iterator; +import java.util.function.Supplier; import org.apache.wicket.Application; import org.apache.wicket.Page; @@ -17,7 +18,6 @@ import org.apache.wicket.request.mapper.info.PageInfo; import org.apache.wicket.request.mapper.parameter.IPageParametersEncoder; import org.apache.wicket.request.mapper.parameter.PageParameters; -import org.apache.wicket.util.IProvider; /** *

@@ -95,11 +95,6 @@ protected IRequestMapper newBookmarkableMapper() { return new BookmarkableMapper() { - /** - * @see org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper#processHybrid(org.apache.wicket.request.mapper.info.PageInfo, - * java.lang.Class, org.apache.wicket.request.mapper.parameter.PageParameters, - * java.lang.Integer) - */ @Override protected IRequestHandler processHybrid(PageInfo pageInfo, Class pageClass, PageParameters pageParameters, @@ -108,11 +103,6 @@ protected IRequestHandler processHybrid(PageInfo pageInfo, return delegate.processHybrid(pageInfo, pageClass, pageParameters, renderCount); } - /** - * @see org.apache.wicket.request.mapper.AbstractMapper#encodePageParameters(org.apache.wicket.request.Url, - * org.apache.wicket.request.mapper.parameter.PageParameters, - * org.apache.wicket.request.mapper.parameter.IPageParametersEncoder) - */ @Override protected Url encodePageParameters(Url url, PageParameters pageParameters, IPageParametersEncoder encoder) @@ -123,20 +113,13 @@ protected Url encodePageParameters(Url url, PageParameters pageParameters, } /** - * @see org.apache.wicket.SystemMapper#newHomePageMapper(org.apache.wicket.util.IProvider) + * @see org.apache.wicket.SystemMapper#newHomePageMapper(Supplier) */ @Override - protected IRequestMapper newHomePageMapper( - IProvider> homePageProvider) + protected IRequestMapper newHomePageMapper(Supplier> homePageProvider) { - return new HomePageMapper(homePageProvider) { - /** - * @see org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper#processHybrid(org.apache.wicket.request.mapper.info.PageInfo, - * java.lang.Class, org.apache.wicket.request.mapper.parameter.PageParameters, - * java.lang.Integer) - */ @Override protected IRequestHandler processHybrid(PageInfo pageInfo, Class pageClass, PageParameters pageParameters, @@ -145,11 +128,6 @@ protected IRequestHandler processHybrid(PageInfo pageInfo, return delegate.processHybrid(pageInfo, pageClass, pageParameters, renderCount); } - /** - * @see org.apache.wicket.request.mapper.AbstractMapper#encodePageParameters(org.apache.wicket.request.Url, - * org.apache.wicket.request.mapper.parameter.PageParameters, - * org.apache.wicket.request.mapper.parameter.IPageParametersEncoder) - */ @Override protected Url encodePageParameters(Url url, PageParameters pageParameters, IPageParametersEncoder encoder) @@ -159,4 +137,4 @@ protected Url encodePageParameters(Url url, PageParameters pageParameters, }; } -} \ No newline at end of file +}