Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

RequestCycle#find(Class<T>) returns java.util.Optional 
Jira
serverASF JIRA
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyWICKET-6189

 

Code calling RequestCycle#find(Class<T>) has to check whether  a matching IRequestHandler is found. This is now enforced by returning an Optional<T>:

Code Block
languagejava
titleRequestCycle.find(Class<T>)
collapsetrue
getComponent().getRequestCycle().find(AjaxRequestTarget.class).ifPresent(target -> target.add(this)); 
Warning
titleSilent API break

During migration you should check your old code for places where the AjaxRequestCycle (now an Optional<AjaxRequestTarget>) is compared with null:

 

 

Code Block
languagejava
titlePitfall when comparing with null
collapsetrue
if (cycle.find(AjaxRequestTarget.class) == null) {
  // this is *never* executed since #find() always returns an Optional
}

if (cycle.find(AjaxRequestTarget.class) != null) {
  // this is *always* executed since #find() always returns an Optional
}

...