Skip to content

Commit

Permalink
[portlet] Fix the build against Wicket 8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-g committed Jul 17, 2016
1 parent b3ee763 commit 65b2ff3
Show file tree
Hide file tree
Showing 21 changed files with 119 additions and 202 deletions.
22 changes: 11 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,21 +259,21 @@
<sources.disabled>false</sources.disabled>

<hibernate.version>4.3.11.Final</hibernate.version>
<javassist.version>3.18.2-GA</javassist.version>
<jetty.version>8.1.16.v20140903</jetty.version>
<javassist.version>3.20.0-GA</javassist.version>
<jetty.version>9.3.10.v20160621</jetty.version>
<sf-jung.version>2.0.1</sf-jung.version>
<shiro.version>1.2.3</shiro.version>
<slf4j.version>1.7.12</slf4j.version>
<logback.version>1.1.3</logback.version>
<shiro.version>1.2.6</shiro.version>
<slf4j.version>1.7.21</slf4j.version>
<logback.version>1.1.7</logback.version>
<log4j.version>1.2.17</log4j.version>
<spring.version>4.1.6.RELEASE</spring.version>
<cglib.version>3.1</cglib.version>
<objenesis.version>2.1</objenesis.version>
<scala.version>2.11.8</scala.version>
<spring.version>4.3.1.RELEASE</spring.version>
<cglib.version>3.2.4</cglib.version>
<objenesis.version>2.4</objenesis.version>
<scala.version>2.12.0-M5</scala.version>
</properties>

<prerequisites>
<maven>3.0.4</maven>
<maven>3.3.9</maven>
</prerequisites>

<modules>
Expand Down Expand Up @@ -1290,7 +1290,7 @@
<configuration>
<linkXRef>true</linkXRef>
<sourceEncoding>utf-8</sourceEncoding>
<targetJdk>1.7</targetJdk>
<targetJdk>1.8</targetJdk>
<minimumTokens>100</minimumTokens>
</configuration>
</plugin>
Expand Down
19 changes: 3 additions & 16 deletions portlet-parent/wicketstuff-portlet-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<!-- JEE DEPENDECIES -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -243,19 +243,6 @@
</execution>
</executions>
</plugin>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
Expand Down Expand Up @@ -292,7 +279,7 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ public List<String> getObject()
add(form);

final DropDownChoice<String> makes = new DropDownChoice<>("makes",
new PropertyModel<String>(this, "selectedMake"), makeChoices);
new PropertyModel<>(this, "selectedMake"), makeChoices);

final DropDownChoice<String> models = new DropDownChoice<>("models",
new Model<String>(), modelChoices);
new Model<>(), modelChoices);
models.setOutputMarkupId(true);

form.add(makes);
Expand All @@ -116,9 +116,9 @@ public List<String> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -105,15 +107,14 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
add(new AjaxFallbackLink<Void>("c2-link")
{
@Override
public void onClick(AjaxRequestTarget target)
public void onClick(Optional<AjaxRequestTarget> targetOptional)
{
counter2++;
if (target != null)
{
targetOptional.ifPresent(target -> {
target.add(c2);
target.appendJavaScript(String.format("jQuery('#%s').effect('highlight');",
c2.getMarkupId()));
}
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String>()));
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<String>()
{
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));

Expand All @@ -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");

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -97,21 +98,18 @@ public void onClick(AjaxRequestTarget target)
add(new AjaxFallbackLink<Void>("c2-link")
{
@Override
public void onClick(AjaxRequestTarget target)
public void onClick(Optional<AjaxRequestTarget> 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<Void>("c3-link")
{
@Override
public void onClick(AjaxRequestTarget target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;


/**
Expand Down Expand Up @@ -172,7 +174,7 @@ public int getSumOfRatings()
public RatingsPage()
{
add(new RatingPanel("rating1", new PropertyModel<Integer>(rating1, "rating"), 5,
new PropertyModel<Integer>(rating1, "nrOfVotes"), true)
new PropertyModel<>(rating1, "nrOfVotes"), true)
{
@Override
public boolean onIsStarActive(int star)
Expand All @@ -181,15 +183,15 @@ public boolean onIsStarActive(int star)
}

@Override
public void onRated(int rating, AjaxRequestTarget target)
public void onRated(int rating, Optional<AjaxRequestTarget> target)
{
RatingsPage.rating1.addRating(rating);
}
});

add(new RatingPanel("rating2", new PropertyModel<Integer>(rating2, "rating"),
new Model<Integer>(5), new PropertyModel<Integer>(rating2, "nrOfVotes"),
new PropertyModel<Boolean>(this, "hasVoted"), true)
new Model<>(5), new PropertyModel<>(rating2, "nrOfVotes"),
new PropertyModel<>(this, "hasVoted"), true)
{
@Override
protected String getActiveStarUrl(int iteration)
Expand All @@ -212,7 +214,7 @@ public boolean onIsStarActive(int star)
}

@Override
public void onRated(int rating, AjaxRequestTarget target)
public void onRated(int rating, Optional<AjaxRequestTarget> target)
{
// make sure the user can't vote again
hasVoted = Boolean.TRUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Void>
{
/** Constructor. */
private AddTodoLink(String id)
Expand All @@ -180,9 +181,9 @@ private AddTodoLink(String id)
* the request target.
*/
@Override
public void onClick(AjaxRequestTarget target)
public void onClick(Optional<AjaxRequestTarget> target)
{
onShowForm(target);
onShowForm(target.get());
}

/**
Expand All @@ -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<Void>
{
/**
* Constructor.
Expand All @@ -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<AjaxRequestTarget> target)
{
onRemoveCompletedTodos(target);
onRemoveCompletedTodos(target.get());
}

/**
Expand Down Expand Up @@ -256,33 +254,23 @@ 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();

// 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)
{
}
});
}

Expand Down Expand Up @@ -413,11 +401,8 @@ public TodoList()

add(new AjaxFallbackLink<Void>("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<AjaxRequestTarget> target)
{
setResponsePage(getPage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
Loading

0 comments on commit 65b2ff3

Please sign in to comment.