get() is supposed to throw an exception if there is no value. If you want
it to return null you should do:

RequestCycle.get().find(AjaxRequestTarget.class).orElse(null);

2016-08-05 1:09 GMT+02:00 Sebastien <[email protected]>:

> Hi dev,
>
> I've an issue with
> org.apache.wicket.request.cycle.RequestCycle.find(Class<T>)
>
> If I put this code in a page (#onInitialize, #onConfigure, ...):
> RequestCycle.get().find(AjaxRequestTarget.class).get(); // expects
> returning null
>
> It breaks with:
>
> java.util.NoSuchElementException: No value present
>      at java.util.Optional.get(Optional.java:135)
>      at com.company.MyPage.onConfigure(MyPage.java:78)
>      at org.apache.wicket.Component.configure(Component.java:1053)
>
>
> The debugger seems to go until "return Optional.empty();" as expected, but
> the RTE is still thrown right after...
>
> Could someone confirm?
>
> Thanks in advance,
> Sebastien.
>



-- 
Jeroen Steenbeeke

Reply via email to