Re: Stateless ModalDialog
Thanks Sven and Martin! I've tested it, it works perfectly. Op ma 11 jan. 2021 om 09:40 schreef Martin Grigorov : > > Hi, > > Sven Meier already explained you the problem at > https://stackoverflow.com/questions/65632010/stateless-modaldialog-in-wicket/65664328 > I've added sample code how to achieve it. > > On Sun, Jan 10, 2021 at 7:20 PM Prag Progger wrote: > > > Hi, > > > > Is it possible to create a stateless ModalDialog? > > > > I tried the following code, but it results in an error. The error > > doesn't occur when removing the getStatelessHint() overrides, but that > > would make it stateful. If it's not possible, would it be possible > > with the deprecated ModalWindow? > > > > HTML Code: > > > > > > > > > > > > .modal-dialog { border-radius: 5px; } > > .modal-dialog .modal-dialog-content { display: flex; > > flex-direction: column; } > > .modal-dialog-overlay.current-focus-trap .modal-dialog-content > > { resize: both; } > > .modal-dialog .modal-dialog-form { margin: 0; padding: 0; > > overflow: hidden; flex: 1; display: flex; flex-direction: column; } > > .modal-dialog .modal-dialog-header { border-radius: 5px 5px > > 0px 0px; background: #ffb158; margin: 0; padding-top: 4px; text-align: > > center; } > > .modal-dialog .modal-dialog-body { flex: 1; overflow-y: auto; > > padding: 20px; } > > .modal-dialog .modal-dialog-footer { padding: 5px; } > > > > > > > > Open modal > > > > > > > > > > Modal Dialog > > Close modal > > > > > > > > > > Java Code: > > > > package org.example.modaltest; > > > > import org.apache.wicket.ajax.AjaxRequestTarget; > > import org.apache.wicket.ajax.markup.html.AjaxLink; > > import org.apache.wicket.extensions.ajax.markup.html.modal.ModalDialog; > > import > > org.apache.wicket.extensions.ajax.markup.html.modal.theme.DefaultTheme; > > import org.apache.wicket.markup.html.GenericWebPage; > > import org.apache.wicket.markup.html.panel.Fragment; > > > > public class ModalPage extends GenericWebPage { > > public ModalPage() { > > ModalDialog window = new ModalDialog("window"); > > window.add(new DefaultTheme()); > > window.setMarkupId("window"); > > window.setOutputMarkupId(true); > > add(window); > > > > Fragment modalContentFragment = new > > Fragment(ModalDialog.CONTENT_ID, "modalContentFragment", this); > > window.setContent(modalContentFragment); > > modalContentFragment.setOutputMarkupId(true); > > > > AjaxLink closeModalLink = new > > AjaxLink("closeModalLink") { > > @Override > > public void onClick(AjaxRequestTarget target) { > > target.add(window); > > ModalDialog window1 = (ModalDialog) > > findPage().get("window"); > > window1.close(target); > > } > > > > @Override > > protected boolean getStatelessHint() { > > return true; > > } > > }; > > closeModalLink.setOutputMarkupId(true); > > modalContentFragment.add(closeModalLink); > > > > AjaxLink openModalLink = new AjaxLink("openModalLink") > > { > > @Override > > public void onClick(AjaxRequestTarget target) { > > ModalDialog window1 = (ModalDialog) > > findPage().get("window"); > > window1.open(target); > > } > > > > @Override > > protected boolean getStatelessHint() { > > return true; > > } > > }; > > add(openModalLink); > > } > > } > > > > > > Error in Browser: > > "Access Denied. You do not have access to the page you requested. > > Return to home page" > > > > Java Exception: > > > > 16:34:16.382 [http-nio-8080-exec-4] WARN > > o.a.w.c.r.h.ListenerRequestHandler - behavior not enabled; ignore > > call. Behavior org.apache.wicket.ajax.markup.html.AjaxLink$1@5a149041 > > at component [AjaxLink [Component id = closeModalLink]] > > 16:34:16.386 [http-nio-8080-exec-4] WARN RequestCycleExtra - > >
Re: Stateless ModalDialog
Hi, Sven Meier already explained you the problem at https://stackoverflow.com/questions/65632010/stateless-modaldialog-in-wicket/65664328 I've added sample code how to achieve it. On Sun, Jan 10, 2021 at 7:20 PM Prag Progger wrote: > Hi, > > Is it possible to create a stateless ModalDialog? > > I tried the following code, but it results in an error. The error > doesn't occur when removing the getStatelessHint() overrides, but that > would make it stateful. If it's not possible, would it be possible > with the deprecated ModalWindow? > > HTML Code: > > > > > > .modal-dialog { border-radius: 5px; } > .modal-dialog .modal-dialog-content { display: flex; > flex-direction: column; } > .modal-dialog-overlay.current-focus-trap .modal-dialog-content > { resize: both; } > .modal-dialog .modal-dialog-form { margin: 0; padding: 0; > overflow: hidden; flex: 1; display: flex; flex-direction: column; } > .modal-dialog .modal-dialog-header { border-radius: 5px 5px > 0px 0px; background: #ffb158; margin: 0; padding-top: 4px; text-align: > center; } > .modal-dialog .modal-dialog-body { flex: 1; overflow-y: auto; > padding: 20px; } > .modal-dialog .modal-dialog-footer { padding: 5px; } > > > > Open modal > > > > > Modal Dialog > Close modal > > > > > Java Code: > > package org.example.modaltest; > > import org.apache.wicket.ajax.AjaxRequestTarget; > import org.apache.wicket.ajax.markup.html.AjaxLink; > import org.apache.wicket.extensions.ajax.markup.html.modal.ModalDialog; > import > org.apache.wicket.extensions.ajax.markup.html.modal.theme.DefaultTheme; > import org.apache.wicket.markup.html.GenericWebPage; > import org.apache.wicket.markup.html.panel.Fragment; > > public class ModalPage extends GenericWebPage { > public ModalPage() { > ModalDialog window = new ModalDialog("window"); > window.add(new DefaultTheme()); > window.setMarkupId("window"); > window.setOutputMarkupId(true); > add(window); > > Fragment modalContentFragment = new > Fragment(ModalDialog.CONTENT_ID, "modalContentFragment", this); > window.setContent(modalContentFragment); > modalContentFragment.setOutputMarkupId(true); > > AjaxLink closeModalLink = new > AjaxLink("closeModalLink") { > @Override > public void onClick(AjaxRequestTarget target) { > target.add(window); > ModalDialog window1 = (ModalDialog) > findPage().get("window"); > window1.close(target); > } > > @Override > protected boolean getStatelessHint() { > return true; > } > }; > closeModalLink.setOutputMarkupId(true); > modalContentFragment.add(closeModalLink); > > AjaxLink openModalLink = new AjaxLink("openModalLink") > { > @Override > public void onClick(AjaxRequestTarget target) { > ModalDialog window1 = (ModalDialog) > findPage().get("window"); > window1.open(target); > } > > @Override > protected boolean getStatelessHint() { > return true; > } > }; > add(openModalLink); > } > } > > > Error in Browser: > "Access Denied. You do not have access to the page you requested. > Return to home page" > > Java Exception: > > 16:34:16.382 [http-nio-8080-exec-4] WARN > o.a.w.c.r.h.ListenerRequestHandler - behavior not enabled; ignore > call. Behavior org.apache.wicket.ajax.markup.html.AjaxLink$1@5a149041 > at component [AjaxLink [Component id = closeModalLink]] > 16:34:16.386 [http-nio-8080-exec-4] WARN RequestCycleExtra - > > 16:34:16.390 [http-nio-8080-exec-4] WARN RequestCycleExtra - Handling > the following exception > > org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException: > Behavior rejected interface invocation. Component: [AjaxLink > [Component id = closeModalLink]] Behavior: > org.apache.wicket.ajax.markup.html.AjaxLink$1@5a149041 > at > org.apache.wicket.core.request.handler.ListenerRequestHandler.invoke(ListenerRequestHandler.java:276) > at > org.apache.wicket.core.request.handler.ListenerRequestHandler.invokeListener(ListenerRequestHandler.java:222) > at > org.apache.wicket.core.request.handler.ListenerRequestHandler.respond(ListenerRequestHandler.java:208) > at > org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:902) > at > org.apache.wicket.request.RequestHandlerExecutor.execute(RequestHandlerExecutor.java:63) > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Stateless ModalDialog
Hi, Is it possible to create a stateless ModalDialog? I tried the following code, but it results in an error. The error doesn't occur when removing the getStatelessHint() overrides, but that would make it stateful. If it's not possible, would it be possible with the deprecated ModalWindow? HTML Code: .modal-dialog { border-radius: 5px; } .modal-dialog .modal-dialog-content { display: flex; flex-direction: column; } .modal-dialog-overlay.current-focus-trap .modal-dialog-content { resize: both; } .modal-dialog .modal-dialog-form { margin: 0; padding: 0; overflow: hidden; flex: 1; display: flex; flex-direction: column; } .modal-dialog .modal-dialog-header { border-radius: 5px 5px 0px 0px; background: #ffb158; margin: 0; padding-top: 4px; text-align: center; } .modal-dialog .modal-dialog-body { flex: 1; overflow-y: auto; padding: 20px; } .modal-dialog .modal-dialog-footer { padding: 5px; } Open modal Modal Dialog Close modal Java Code: package org.example.modaltest; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.extensions.ajax.markup.html.modal.ModalDialog; import org.apache.wicket.extensions.ajax.markup.html.modal.theme.DefaultTheme; import org.apache.wicket.markup.html.GenericWebPage; import org.apache.wicket.markup.html.panel.Fragment; public class ModalPage extends GenericWebPage { public ModalPage() { ModalDialog window = new ModalDialog("window"); window.add(new DefaultTheme()); window.setMarkupId("window"); window.setOutputMarkupId(true); add(window); Fragment modalContentFragment = new Fragment(ModalDialog.CONTENT_ID, "modalContentFragment", this); window.setContent(modalContentFragment); modalContentFragment.setOutputMarkupId(true); AjaxLink closeModalLink = new AjaxLink("closeModalLink") { @Override public void onClick(AjaxRequestTarget target) { target.add(window); ModalDialog window1 = (ModalDialog) findPage().get("window"); window1.close(target); } @Override protected boolean getStatelessHint() { return true; } }; closeModalLink.setOutputMarkupId(true); modalContentFragment.add(closeModalLink); AjaxLink openModalLink = new AjaxLink("openModalLink") { @Override public void onClick(AjaxRequestTarget target) { ModalDialog window1 = (ModalDialog) findPage().get("window"); window1.open(target); } @Override protected boolean getStatelessHint() { return true; } }; add(openModalLink); } } Error in Browser: "Access Denied. You do not have access to the page you requested. Return to home page" Java Exception: 16:34:16.382 [http-nio-8080-exec-4] WARN o.a.w.c.r.h.ListenerRequestHandler - behavior not enabled; ignore call. Behavior org.apache.wicket.ajax.markup.html.AjaxLink$1@5a149041 at component [AjaxLink [Component id = closeModalLink]] 16:34:16.386 [http-nio-8080-exec-4] WARN RequestCycleExtra - 16:34:16.390 [http-nio-8080-exec-4] WARN RequestCycleExtra - Handling the following exception org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException: Behavior rejected interface invocation. Component: [AjaxLink [Component id = closeModalLink]] Behavior: org.apache.wicket.ajax.markup.html.AjaxLink$1@5a149041 at org.apache.wicket.core.request.handler.ListenerRequestHandler.invoke(ListenerRequestHandler.java:276) at org.apache.wicket.core.request.handler.ListenerRequestHandler.invokeListener(ListenerRequestHandler.java:222) at org.apache.wicket.core.request.handler.ListenerRequestHandler.respond(ListenerRequestHandler.java:208) at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:902) at org.apache.wicket.request.RequestHandlerExecutor.execute(RequestHandlerExecutor.java:63) - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org