You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Satyavathi Iynaparthi <sa...@hcl.com.INVALID> on 2021/03/22 23:09:29 UTC

Wicket 8.x Migration Issues with AjaxFallBackLink

Classification: Confidential

Hi Team,

We are in process of migration our Web application from Wicket 6.30 to Wicket 8.11.0.
As a first step, placed below jars in the classpath.

wicket-auth-roles-8.11.0.jar
wicket-core-8.11.0.jar
wicket-datetime-8.0.0-M7.jar
wicket-extensions-8.11.0.jar
wicket-request-8.11.0.jar
wicket-util-8.11.0.jar
wicketstuff-inmethod-grid-8.11.0.jar

Addressed the compilation issues related to AjaxFallBackLink onClick() method .
Changed the method signature to public void onClick(Optional<AjaxRequestTarget> target).

We have a Html page

SettingsPanel.html

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" lang="en">

<wicket:panel>
                              <a href="#" wicket:id="saveSettingsLink"><img wicket:id="saveIcon" /></a>


</wicket:panel>

</html>

SettingsPanel.java

AjaxFallbackLink<Serializable> settingsLink = new AjaxFallbackLink<Serializable>("saveSettingsLink") {
                  private static final long serialVersionUID = 1L;

                  @Override
                  public void onClick(Optional<AjaxRequestTarget> target) {
                        //some logic
target.get().add(feedback);

                  }
            };
            Image img = new Image("saveIcon", new Model<Serializable>() {
                  private static final long serialVersionUID = 1L;

                  @Override
                  public Serializable getObject() {
                        return new PackageResourceReference(SettingsPanel.class,"save.png");
                  }
            });
            img.add(new AttributeModifier("title", new StringResourceModel("saveTitle", ColumnSettingsLinkPanel.this,
                        new Model<String>())));
            settingsLink.add(img);

With the above code, in Wicket 6.30, save image (save.png) gets displayed on the page and when user clicks on the image link, onlick(AjaxRequestTarget target) gets triggered.
Post migrating to Wicket 8.11.0, image is not displaying on the page and when user clicks on the image link, onClick(Optional<AjaxRequestTarget> target) getting triggered, but the target value is always Empty.

Below is the stack trace
ERROR - DefaultExceptionMapper - Unexpected error occurred
java.util.NoSuchElementException: No value present
at java.base/java.util.Optional.get(Optional.java:148)
at com.csc.pts.web.ui.ColumnSettingsLinkPanel$3.onClick(SettingsPanel.java:98)
at org.apache.wicket.ajax.markup.html.AjaxFallbackLink.onClick(AjaxFallbackLink.java:122)
at org.apache.wicket.markup.html.link.Link.onRequest(Link.java:189)
at org.apache.wicket.core.request.handler.ListenerRequestHandler.internalInvoke(ListenerRequestHandler.java:306)
at org.apache.wicket.core.request.handler.ListenerRequestHandler.invoke(ListenerRequestHandler.java:255)
at org.apache.wicket.core.request.handler.ListenerRequestHandler.invokeListener(ListenerRequestHandler.java:215)
at org.apache.wicket.core.request.handler.ListenerRequestHandler.respond(ListenerRequestHandler.java:208)
at org.apache.wicket.core.request.handler.RequestSettingRequestHandler.respond(RequestSettingRequestHandler.java:78)
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:912)
at org.apache.wicket.request.RequestHandlerExecutor.execute(RequestHandlerExecutor.java:65)
at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:283)
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:253)
at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:221)
at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:262)
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:204)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:286)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)

Can you please advise on the changes required to make this functionality work with Wicket 8.11.0 version.

Thanks,
Satya
::DISCLAIMER::
________________________________
The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents (with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates. Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of authorized representative of HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any email and/or attachments, please check them for viruses and other defects.
________________________________

Re: Wicket 8.x Migration Issues with AjaxFallBackLink

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Tue, Mar 23, 2021 at 7:43 AM Satyavathi Iynaparthi
<sa...@hcl.com.invalid> wrote:

> Classification: Confidential
>

I am not sure whether I am allowed to read further.


>
> Hi Team,
>
> We are in process of migration our Web application from Wicket 6.30 to
> Wicket 8.11.0.
> As a first step, placed below jars in the classpath.
>
> wicket-auth-roles-8.11.0.jar
> wicket-core-8.11.0.jar
> wicket-datetime-8.0.0-M7.jar
>

better use
https://github.com/wicketstuff/core/tree/master/wicket-datetime-parent ,
https://search.maven.org/artifact/org.wicketstuff/wicketstuff-datetime-yui/8.11.0/jar


> wicket-extensions-8.11.0.jar
> wicket-request-8.11.0.jar
> wicket-util-8.11.0.jar
> wicketstuff-inmethod-grid-8.11.0.jar
>
> Addressed the compilation issues related to AjaxFallBackLink onClick()
> method .
> Changed the method signature to public void
> onClick(Optional<AjaxRequestTarget> target).
>
> We have a Html page
>
> SettingsPanel.html
>
> <?xml version="1.0" encoding="UTF-8"?>
> <html xmlns:wicket="
> http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" lang="en">
>
> <wicket:panel>
>                               <a href="#"
> wicket:id="saveSettingsLink"><img wicket:id="saveIcon" /></a>
>
>
> </wicket:panel>
>
> </html>
>
> SettingsPanel.java
>
> AjaxFallbackLink<Serializable> settingsLink = new
> AjaxFallbackLink<Serializable>("saveSettingsLink") {
>                   private static final long serialVersionUID = 1L;
>
>                   @Override
>                   public void onClick(Optional<AjaxRequestTarget> target) {
>                         //some logic
> target.get().add(feedback);
>

replace it with: target.ifPresent(t -> t.add(feedback));

I am not sure what is the reason to still use AjaxFallback** components but
if your users really disable JavaScript in their browsers then you have to
check that the Optional brings AjaxRequestTarget before trying to use it.


>
>                   }
>             };
>             Image img = new Image("saveIcon", new Model<Serializable>() {
>                   private static final long serialVersionUID = 1L;
>
>                   @Override
>                   public Serializable getObject() {
>                         return new
> PackageResourceReference(SettingsPanel.class,"save.png");
>                   }
>             });
>             img.add(new AttributeModifier("title", new
> StringResourceModel("saveTitle", ColumnSettingsLinkPanel.this,
>                         new Model<String>())));
>             settingsLink.add(img);
>
> With the above code, in Wicket 6.30, save image (save.png) gets displayed
> on the page and when user clicks on the image link,
> onlick(AjaxRequestTarget target) gets triggered.
> Post migrating to Wicket 8.11.0, image is not displaying on the page and
> when user clicks on the image link, onClick(Optional<AjaxRequestTarget>
> target) getting triggered, but the target value is always Empty.
>
> Below is the stack trace
> ERROR - DefaultExceptionMapper - Unexpected error occurred
> java.util.NoSuchElementException: No value present
> at java.base/java.util.Optional.get(Optional.java:148)
> at
> com.csc.pts.web.ui.ColumnSettingsLinkPanel$3.onClick(SettingsPanel.java:98)
> at
> org.apache.wicket.ajax.markup.html.AjaxFallbackLink.onClick(AjaxFallbackLink.java:122)
> at org.apache.wicket.markup.html.link.Link.onRequest(Link.java:189)
> at
> org.apache.wicket.core.request.handler.ListenerRequestHandler.internalInvoke(ListenerRequestHandler.java:306)
> at
> org.apache.wicket.core.request.handler.ListenerRequestHandler.invoke(ListenerRequestHandler.java:255)
> at
> org.apache.wicket.core.request.handler.ListenerRequestHandler.invokeListener(ListenerRequestHandler.java:215)
> at
> org.apache.wicket.core.request.handler.ListenerRequestHandler.respond(ListenerRequestHandler.java:208)
> at
> org.apache.wicket.core.request.handler.RequestSettingRequestHandler.respond(RequestSettingRequestHandler.java:78)
> at
> org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:912)
> at
> org.apache.wicket.request.RequestHandlerExecutor.execute(RequestHandlerExecutor.java:65)
> at
> org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:283)
> at
> org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:253)
> at
> org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:221)
> at
> org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:262)
> at
> org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:204)
> at
> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:286)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
> at
> org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
> at
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
> at
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
> at
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
> at org.apache.tomcat.util.net
> .NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
> at org.apache.tomcat.util.net
> .SocketProcessorBase.run(SocketProcessorBase.java:49)
> at
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
> at
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
> at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> at java.base/java.lang.Thread.run(Thread.java:834)
>
> Can you please advise on the changes required to make this functionality
> work with Wicket 8.11.0 version.
>
> Thanks,
> Satya
> ::DISCLAIMER::
> ________________________________
> The contents of this e-mail and any attachment(s) are confidential and
> intended for the named recipient(s) only. E-mail transmission is not
> guaranteed to be secure or error-free as information could be intercepted,
> corrupted, lost, destroyed, arrive late or incomplete, or may contain
> viruses in transmission. The e mail and its contents (with or without
> referred errors) shall therefore not attach any liability on the originator
> or HCL or its affiliates. Views or opinions, if any, presented in this
> email are solely those of the author and may not necessarily reflect the
> views or opinions of HCL or its affiliates. Any form of reproduction,
> dissemination, copying, disclosure, modification, distribution and / or
> publication of this message without the prior written consent of authorized
> representative of HCL is strictly prohibited. If you have received this
> email in error please delete it and notify the sender immediately. Before
> opening any email and/or attachments, please check them for viruses and
> other defects.
> ________________________________
>

Re: Wicket 8.x Migration Issues with AjaxFallBackLink

Posted by Johannes Renoth <jo...@gmx.de>.
Hi,

you have to use

target.ifPresent(t -> t.add(feedback));

instead of

target.get().add(feedback);

Trying to get an O

Optional with no value present results in the mentioned error.

Greetings,

Johannes Renoth

On 2021-03-23 0:09, Satyavathi Iynaparthi wrote:
> Classification: Confidential
>
> Hi Team,
>
> We are in process of migration our Web application from Wicket 6.30 to Wicket 8.11.0.
> As a first step, placed below jars in the classpath.
>
> wicket-auth-roles-8.11.0.jar
> wicket-core-8.11.0.jar
> wicket-datetime-8.0.0-M7.jar
> wicket-extensions-8.11.0.jar
> wicket-request-8.11.0.jar
> wicket-util-8.11.0.jar
> wicketstuff-inmethod-grid-8.11.0.jar
>
> Addressed the compilation issues related to AjaxFallBackLink onClick() method .
> Changed the method signature to public void onClick(Optional<AjaxRequestTarget> target).
>
> We have a Html page
>
> SettingsPanel.html
>
> <?xml version="1.0" encoding="UTF-8"?>
> <html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" lang="en">
>
> <wicket:panel>
>                               <a href="#" wicket:id="saveSettingsLink"><img wicket:id="saveIcon" /></a>
>
>
> </wicket:panel>
>
> </html>
>
> SettingsPanel.java
>
> AjaxFallbackLink<Serializable> settingsLink = new AjaxFallbackLink<Serializable>("saveSettingsLink") {
>                   private static final long serialVersionUID = 1L;
>
>                   @Override
>                   public void onClick(Optional<AjaxRequestTarget> target) {
>                         //some logic
> target.get().add(feedback);
>
>                   }
>             };
>             Image img = new Image("saveIcon", new Model<Serializable>() {
>                   private static final long serialVersionUID = 1L;
>
>                   @Override
>                   public Serializable getObject() {
>                         return new PackageResourceReference(SettingsPanel.class,"save.png");
>                   }
>             });
>             img.add(new AttributeModifier("title", new StringResourceModel("saveTitle", ColumnSettingsLinkPanel.this,
>                         new Model<String>())));
>             settingsLink.add(img);
>
> With the above code, in Wicket 6.30, save image (save.png) gets displayed on the page and when user clicks on the image link, onlick(AjaxRequestTarget target) gets triggered.
> Post migrating to Wicket 8.11.0, image is not displaying on the page and when user clicks on the image link, onClick(Optional<AjaxRequestTarget> target) getting triggered, but the target value is always Empty.
>
> Below is the stack trace
> ERROR - DefaultExceptionMapper - Unexpected error occurred
> java.util.NoSuchElementException: No value present
> at java.base/java.util.Optional.get(Optional.java:148)
> at com.csc.pts.web.ui.ColumnSettingsLinkPanel$3.onClick(SettingsPanel.java:98)
> at org.apache.wicket.ajax.markup.html.AjaxFallbackLink.onClick(AjaxFallbackLink.java:122)
> at org.apache.wicket.markup.html.link.Link.onRequest(Link.java:189)
> at org.apache.wicket.core.request.handler.ListenerRequestHandler.internalInvoke(ListenerRequestHandler.java:306)
> at org.apache.wicket.core.request.handler.ListenerRequestHandler.invoke(ListenerRequestHandler.java:255)
> at org.apache.wicket.core.request.handler.ListenerRequestHandler.invokeListener(ListenerRequestHandler.java:215)
> at org.apache.wicket.core.request.handler.ListenerRequestHandler.respond(ListenerRequestHandler.java:208)
> at org.apache.wicket.core.request.handler.RequestSettingRequestHandler.respond(RequestSettingRequestHandler.java:78)
> at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:912)
> at org.apache.wicket.request.RequestHandlerExecutor.execute(RequestHandlerExecutor.java:65)
> at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:283)
> at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:253)
> at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:221)
> at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:262)
> at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:204)
> at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:286)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
> at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
> at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
> at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
> at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
> at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
> at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
> at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
> at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
> at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> at java.base/java.lang.Thread.run(Thread.java:834)
>
> Can you please advise on the changes required to make this functionality work with Wicket 8.11.0 version.
>
> Thanks,
> Satya
> ::DISCLAIMER::
> ________________________________
> The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents (with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates. Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of authorized representative of HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any email and/or attachments, please check them for viruses and other defects.
> ________________________________
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org