I tried migrating a small application made with Wicket7 to Wicket8. A play that erases errors and warnings and enumerates the rewritten contents up to the point where it works for the time being. I'm not feeling any better now. Also, Lambda is not handled.
This is a nanika like a memorandum. If you want to migrate properly, you should definitely see Migration Guide for Home.
The Form that was passed as an argument until now is gone. I didn't refer to it in my code, so just delete the argument. If you want, you can get it with ʻAjaxButton.getForm ()`.
and ʻAjaxFallbackButton.onSubmit ()
.For example, ʻAjaxFormComponentUpdatingBehavior`.
python
//until now"onchange"It worked even if I specified it ...
hoge.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
//Something processing
}
});
There are no exceptions even if ʻon is attached, but JavaScript does not work. From the time of Wicket 6.x, it seems that a warning log appeared in the log saying "Don't write on. I'll forgive you now, but forgive me from 8." I didn't notice. I don't care, but I think the class name ʻAjaxFormComponentUpdatingBehavior
is too long.
Don't use batten. If it is an IDE, the strikethrough will be drawn and the feeling of use will be doubled. It's easy to fix, just replace it with ʻIModel`.
I used it via a label like the one below, so I only changed it in one place. ʻAbstractReadOnlyModel` has a lot of characters, so I just didn't want to write it many times.
ReadOnlyLabel.java
package yamane.wicket;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;
public abstract class ReadOnlyLabel<T> extends Label {
public ReadOnlyLabel(String id) {
super(id);
//I rewrote this to IModel
// setDefaultModel(new AbstractReadOnlyModel<T>() {
setDefaultModel(new IModel<T>() {
@Override
public T getObject() {
return load();
}
});
}
protected abstract T load();
}
Because Java8 is required and the default method of the interface can be used. Very refreshing.
This is almost the same as ʻAbstractReadOnlyModel. Replace ʻextends
with ʻimplements and replace ʻIRequestCycleListener
with the default method added.
But this wasn't mentioned in the migration guide, right? I often use it for handling before writing out the error page, but I wonder if everyone is using it.
Super.onConfigure ()
is now required when overriding.
Until now, the implementation of Component.onConfigure ()
was empty, so I thought "I don't need to call it, the one-line description will be reduced", but from Wicket8, "No, exception, you will die". I will.
eh? Did you mention that it is essential for JavaDoc from before?
I'm sorry I didn't read it.
It's a method that is overridden frequently, so there are many changes. I just grep and copy. This was the biggest for me.
It was a lot less change than I expected.
I personally think that the code for Wicket applications will be quite different for each programmer. Which is not the right mistake, but the individuality or habit. So, I'm sure there will be different rewrite locations for Wicket 7 applications made by different people. I haven't seen much code for Wicket applications made by anyone other than myself, so I'm not sure.
It ends abruptly after appealing the uselessness of this article.
Recommended Posts