Date: Tue, 19 Mar 2024 02:47:07 +0000 (UTC) Message-ID: <693502477.54030.1710816427339@cwiki-he-fi.apache.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_54029_1349776147.1710816427339" ------=_Part_54029_1349776147.1710816427339 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Wicket developers have worked to make migration from 7.x to 8.x as smoot= h as possible. Most of the time the required changes to migrate to the new = version will be spotted by the Java compiler producing a compile error. The= re are however some important changes (in the API or in the framework's beh= avior) that won't result in a compilation problem but which are nonetheless= very important and could lead to undesired changes in your application's b= ehavior. The following is a list of such changes. You are strongly invited = to review them as part of the migration process:
if (Reque= stCycle.get().find(AjaxRequestTarget.class) =3D=3D null) { // executed for non-ajax-request in Wicket 7 // never executed in Wicket 8 ... }
See Migration to Wi= cket 8.0#WICKET-6189 for more details
@Override public void init() { setHeaderResponseDecorator(new JavaScriptToBodyCustomResponseDecorator("= footer")); }
This code doesn't work anymore. See Migration to Wicket 8.0#WICKET-6498 for more details= p>
Ajax multipart uploads (e.g. FileUploadField in Ajax submits) require https://developer.mozilla.org/en-US/docs/= Web/API/FormData , for Internet Explorer that implies version 10 or hig= her. WICK= ET-6517 - Getting issue details... STATUS
Because of license issues all json.org classes in that package have been= removed and open-json (https://github.com/tdunning/open-js= on) is used as new dependency. Basic functionalities can be reused= by only changing the imports from org.apache.wicket.ajax.json.* to org.jso= n.*, org.apache.wicket.ajax.json.JsonFunction has been renamed to org.apach= e.wicket.ajax.json.JSONFunction and some classes are deleted without a= ny replacements (example: org.json.HTTP)
Replace it with standard Java 8 java.util.function.Supplier<T> whi= ch is virtually identical.
Replace IContextProvider<T, C> with standard Java 8 java.util.func= tion.Function<C, T> which is virtually identical.
As a consequence IPageManager= Provider, IPageRendererProvider = and IRequestCycleProvider now ov= erride #apply() method instead of #get().
Tests based on HtmlDocumentValidator are very fragile. They start to fai= l as soon as there is a single character change somewhere in the page marku= p.
We believe that there are very few users of this API. It is recomme= nded to use TagTester and WicketTestCase#executeTest() instead.
Use an anonymous instance of IModel instead. Since Wicket 8.0 IModel doe= sn't require providing implementation of #setObject(Object) method.
Concurr= entHashMap.= span>newKeySet() should be used instead= p>
All specialization classes return their type.
For consistency with other components and the new l= ambda support, the submitted form is no longer passed as argument to callba= ck methods (e.g. #onSubmit(), #onClick()) of AjaxButton, AjaxSubmitLink and= AjaxFallbackButton. You can call #getForm() instead.
Code calling RequestCycle#find(Class<T>) has to check whether &nbs= p;a matching IRequestHandler is found. This is now enforced by returning an= Optional<T>:
getComponent().getRequestCycle().find(AjaxRequestTarget.class).ifPresent= (target -> target.add(this));
Silent API break
=During migration you should check your old code for places where the Aja= xRequestCycle (now an Optional<AjaxRequestTarget>) is compared with n= ull:
if (cycle.find(AjaxRequestTarget.class) =3D=3D null) { // this is *never* executed since #find() always returns an Optional } if (cycle.find(AjaxRequestTarget.class) !=3D null) { // this is *always* executed since #find() always returns an Optional }
All AjaxFallback** components and the containers which use internally Aj= axFallback** components, like AjaxTab= bedPanel, RatingPanel and <= span style=3D"color: rgb(34,34,34);">TableTree, h= ave been reworked to pass Optional<AjaxRequestTarget> instead of just= AjaxRequestTarget to their onXyz() callback methods. This way the applicat= ion developer should not forget to check that the AjaxRequestTarget is not = null.
AbstractChoice#getChoices() has been made final. If the application need= s to provide different choices for each render then it should override Abst= ractChoice#getChoicesModel() instead. The application code would be almost = the same as before, it will just need to wrap the final List result in an I= Model, most probably ListModel.
RequestListenerInterface was removed:
A Component or Behavior can now implement IRequestListener once only, th= us removing the need to include an identifier (e.g. "ILinkListener") in the= URL.
If you implemented IResourceListener previously, you have to override IR= equestListener#rendersPage() now to return false.
Change notification was moved from CheckBox, DropDownChoice, RadioChoice= , CheckGroup/Check and RadioGroup/Radio into a new behavior FormComponentUp= datingBehavior.
Instead of subclasses the component, this behavior can now be added to t= he component:
// Wicket 7.x new CheckBox("id", model) { =09protected boolean wantOnSelectionChangedNotifications() { =09=09return true; } =09protected void onSelectionChanged(Boolean newSelection) { =09=09// do something, page will be rerendered; =09} }; // Wicket 8.x new CheckBox("id", model) .add(new FormComponentUpdatingBehavior() { =09protected void onUpdate() { =09=09// do something, page will be rerendered; =09} protected void onError(RuntimeException ex) { super.onError(ex); } });
As with AjaxFormComponentUpdatingBehavior any error during processing of= the form component can now be handled in #onError().
Renderers (IChoiceRendere, IOptionRenderer and IAutoCompleteRenderer now= take part in detachment as other Wicket concepts like components and model= s. The owning component is responsible to detach it.
Before WICKET-6498 users used to create a custom implementation of IHead= erResponseDecorator to place JavaScript items inside page body:
@Override public void init() { setHeaderResponseDecorator(new JavaScriptToBodyCustomResponseDecorat= or("footer")); }
Each Application has an IHeaderResponseDecorator now by default, which d= ecorates header responses with a ResourceAggregator. Projects using their o= wn response decoration (e.g. via JavaScriptFilteredIntoFooterHeaderResponse= ) have to make sure, that each response is explicitly decorated with a Reso= urceAggregator too, since Application no longer does it implicitly, e.g.:= p>
setHeaderResp= onseDecorator(response -> { return new ResourceAggregator(new JavaScriptFilteredIntoFooterH= eaderResponse(response, "footer")); });
Component verifies that subclasses overriding #onConfigure() delegate to= their parent implementation now, as it does for other callbacks like #onIn= itialize(). Make sure that you call super.onConfigure() if you haven't done= so already,
FormComponent#clearInput() has been made non-final, so that now containe= rs like FormComponentPanel could override this method and call #clearInput(= ) on its children of type FormComponent.
By using org.apache.wicket.resource.DynamicJQueryResourceReference Wicke= t will contribute jQuery ver. 2.x for modern browsers and ver. 1.x when the= request is done by Internet Explorer older than ver. 9.
The old behavior of #signOut() didn't bring much value and caused confus= ion to some users. Now it is just an alias of Session#invalidate().
If this setting is enabled then a page could not be requested via
WicketObjects#cloneObject() and #sizeof() now create a new instanc= e of JavaSerializer to clone or take the size of an object respectively.
If the configured ISerializer in the IFrameworkSettings is not an = instance of JavaSerializer then it is used as is!
StatelessChecker now provides an overrideable method named #fail() that = accepts an instance of StatelessCheckFailureException. This method is being= called
Using FeedbackCollector(Component) constructor will collect only the mes= sages related to the passed Component but not any Session scoped feedback m= essages.
Ajax multipart requests are now done via Ajax like their non-multi=
part counterparts. Therefore onsubmit() is no longer called via JS on the f=
orm by default.
AjaxFormSubmitBehavior offers an alternative via overriding and returning t=
rue from #shouldTriggerJavaScriptSubmitEvent(), which will trigger an 'subm=
it' event on the form regardless of multipart or normal Ajax requests.
<=
/span>
Since Wicket 8.x requires Servlet 3.1 the modules for native websocket s= upport for Jetty 7.x/9.0.x have been dropped.
Users are advised to use wicket-native-websocket-javax = module with Jetty 9.2+, Apache Tomcat 7/8, JBoss WildFly.
The experimental integration for Atmosphere has been removed because of = stability issues.
Users are advised to use wicket-native-websocket-javax = ;module with Jetty 9.2+, Apache Tomcat 7/8, JBoss WildFly.
Several deprecated classes where removed:
With WICKET-6503 several internal method= s were removed from the Component API (i.e. those marked with "THIS METHOD = IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT!"). #onAfteRenderChildr= en() was removed too, if you had overriden it use #afterRender() instead.= p>
#renderPart() is now the main entrance to render a single component - th= e caller has to make sure that #beforeRender() has been called on it before= .
WICKET-6544 deprecates Wicket's user age= nt detection, as the API and implementation was not sufficient for modern b= rowsers - it will be removed in Wicket 9.
Users are encouraged to utilize https://github.com/nielsb= asjes/yauaa
The helper method for casting of models was moved from Model to IModel#o= f(IModel<?>).
For convenience IModel class provides a do-nothing implementation of IDe= tachable#detach() method, so custom implementations are not required to imp= lement it when not needed.
For convenience IRequestHandler class provides a do-nothing implementati= on of its #detach() method, so custom implementations are not required to i= mplement it when not needed.
For access to the response, the request and its parameters now ResourceS= treamResource#getResourceStream() receives an instance of org.apache.wicket= .request.resource.IResource.Attributes.
java.util.function.Consumer and other classes are not serializable and t= his makes them unusable in stateful Wicket pages. For this reason Wick= et provides org.apache.wicket.model.lambda.WicketSupplier, org.ap= ache.wicket.model.lambda.WicketConsumer, org.apache.wicket.model.lambda.Wic= ketFunction and org.apache.wicket.model.lambda.WicketBiFunction. Those= interfaces should be used in method signatures where Java 8 lambdas or met= hod references could be used. At the call site there is nothing specific to= be done, i.e. just use lambdas and method references without any casting.<= /p>
Wicket provides a new implementation of IModel which uses Java 8 consume= rs and suppliers, i.e. may be used with lambda or method references
org.apache.wicket.model.LambdaModel
Person person =3D ...; IModel<String> personNameModel =3D new LambdaModel<>( () -> person.getName(), (name) -> person.setName(name));
org.apache.wicket.model.LambdaModel with method references
Person person =3D ...; IModel<String> personNameModel =3D LambdaModel.of(person::getName, pe= rson::setName);
org.apache.wicket.model.LambdaModel can be created with a target mod= el too - note the upper-case 'P' for the function references:
IModel<Person> person =3D ...; IModel<String> personNameModel =3D LambdaModel.of(person, Person::get= Name, Person::getName);
IGenericComponent uses Java 8 default methods to implement #setModel(IMo= del<T>), #getModel(), #setModelObject(T) and #getModelObject() by del= egating to the respective get/setDefaultModel[Object] methods.
This way it could be easily used by any Component by just implementing i= t.
IModel provides default implementations of #detach() (do nothing) and #s= etObject(T) (throws UnsupportedOperationException), so it is possible to us= e it as a functional interface.
new Link<String>("", () -> "abc") { @Override public void onClick() { // ... } }; Label label =3D new Label("id", person::getName); // the method reference i= s actually IModel<String>
columns.add(new LambdaColumn<Contact, String>(new Model<>("= Last Name"), "lastName", Contact::getLastName)
For convenience IColumn class provides an implementation of #isSortable(= ) method that uses #getSortProperty() to decide. Just like AbstractColumn d= id until Wicket 7.
New methods have been added to help manipulating the tables' headers: IC= olumn#getHeaderColspan() and IColumn#getHeaderRowSpan(). Both of them retur= n 1, so the header cells do not span by default.
IRequestCycleListeners are now notified of the execution of all<=
/strong> IRequestHandlers, including those scheduled by other handlers, tho=
se replacing other handlers, and any handler executed due to an exception:<=
/p>
RequestHandlerStack is now renamed to RequestHandlerExecutor.
With this method now an application may explicitly expire pages selectiv= ely.
By overriding org.apache.wicket.request.mapper.AbstractMapper#resol= veLocale(), e.g. like in the test case, the application may = use the session/request's locale while parsing numbers with PageParameters#= get("someNumericParameter").toInt().
All libraries on which Wicket modules depend are updated to their latest=
stable versions.
The most notable ones are: