Re: Parent page container required in child page?

2021-06-26 Thread Prag Progger
Works perfectly, thanks!

Op za 26 jun. 2021 om 22:58 schreef Bas Gooren :
>
> Hi,
>
> Have a look at TransparentWebMarkupContainer, it was specifically made
> for this. This does involve some (internal) magic in wicket but allows
> you to simply say this.add() in child pages instead of
> rootContainer.add().
>
> // Bas
>
> Verstuurd vanaf mijn iPhone
>
> > Op 26 jun. 2021 om 18:09 heeft Prag Progger  het 
> > volgende geschreven:
> >
> > Hi,
> >
> > I have a ParentPage and many sub class child pages that extend it. I
> > decided to add a root container element to the parent page, but this
> > breaks all ChildPage.add() method calls in the child pages. A solution
> > is to pass the root container to every child, but that is a lot of
> > work. Is there a cleaner way to solve this problem without breaking
> > all the child pages?
> >
> > // ParentPage.java
> > public class ParentPage extends WebPage {
> >// Shared with sub classes
> >protected MarkupContainer rootContainer;
> >
> >public ParentPage() {
> >rootContainer = new WebMarkupContainer("rootContainer");
> >add(rootContainer);
> >
> >rootContainer.add(new Label("parentLabel", "Parent component"));
> >}
> > }
> >
> > // ParentPage.html
> > 
> >ParentPage
> >
> >
> >
> >
> >
> >
> >
> >
> > 
> >
> >
> > // ChildPage.java
> > public class ChildPage extends ParentPage {
> >public ChildPage() {
> >// This should preferably be add() instead of rootContainer.add()
> >// So that I don't have such dependency on the parentPage.
> >rootContainer.add(new Label("childComponent", "Child component"));
> >}
> > }
> >
> > // ChildPage.html
> > 
> >
> >Child page
> >
> >
> >
> > 
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>

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



Parent page container required in child page?

2021-06-26 Thread Prag Progger
Hi,

I have a ParentPage and many sub class child pages that extend it. I
decided to add a root container element to the parent page, but this
breaks all ChildPage.add() method calls in the child pages. A solution
is to pass the root container to every child, but that is a lot of
work. Is there a cleaner way to solve this problem without breaking
all the child pages?

// ParentPage.java
public class ParentPage extends WebPage {
// Shared with sub classes
protected MarkupContainer rootContainer;

public ParentPage() {
rootContainer = new WebMarkupContainer("rootContainer");
add(rootContainer);

rootContainer.add(new Label("parentLabel", "Parent component"));
}
}

// ParentPage.html

ParentPage











// ChildPage.java
public class ChildPage extends ParentPage {
public ChildPage() {
// This should preferably be add() instead of rootContainer.add()
// So that I don't have such dependency on the parentPage.
rootContainer.add(new Label("childComponent", "Child component"));
}
}

// ChildPage.html


Child page





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



Re: Stateless ModalDialog

2021-01-11 Thread Prag Progger
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 -
> > 

Stateless ModalDialog

2021-01-10 Thread Prag Progger
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