Hi,

I'm using Wicket on a project that requires hiding all traces of the
framework in use, eg. in URLs for pages and forms.
WebApplication#mountBookmarkablePage covers pages mostly. I've managed
to implement my own AbstractRequestTargetUrlCodingStrategy for forms,
which still needs improvements (see below). Now I'm stuck with
redirect links, eg. when a register form is invoked via
redirectToInterceptPage - after completing the form, I'm again
confronted with those wicket:interface=....:::::... URLs.

I'm posting this to the dev list as I suspect that so far the
framework doesn't promote usage like that or doesn't even support it
(according to replies I got on the users list).

Here is my AbstractRequestTargetUrlCodingStrategy to mount forms,
making blunt use of the http session:

import org.apache.wicket.*;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.request.RequestParameters;
import 
org.apache.wicket.request.target.coding.AbstractRequestTargetUrlCodingStrategy;
import 
org.apache.wicket.request.target.component.listener.IListenerInterfaceRequestTarget;

public class FormMount extends AbstractRequestTargetUrlCodingStrategy {
        
        private final Class<? extends Form> formClass;

        public FormMount(String mountPath, Class<? extends Form> formClass) {
                super(mountPath);
                this.formClass = formClass;
        }

        public IRequestTarget decode(RequestParameters requestParameters) {
                return (IRequestTarget)
Application.get().getSessionStore().getAttribute(RequestCycle.get().getRequest(),
getMountPath());
        }

        public CharSequence encode(IRequestTarget requestTarget) {
                
Application.get().getSessionStore().setAttribute(RequestCycle.get().getRequest(),
getMountPath(), requestTarget);
                return getMountPath();
        }

        public boolean matches(IRequestTarget requestTarget) {
                if (requestTarget instanceof IListenerInterfaceRequestTarget) {
                        IListenerInterfaceRequestTarget target =
(IListenerInterfaceRequestTarget) requestTarget;
                        return target.getTarget().getClass().equals(formClass);
                }
                return false;
        }

}

I still have no idea what alternative strategy could be used to encode
and decode the request target in thise case.

So my actual questions:
How can I improve the FormMount implemention, to avoid all the
potential session storage issues?
How can I mount redirect-links?

Thanks
Jörn Zaefferer

Reply via email to