oh, one last thing.

i think it would be nicer if embedded pages can extend panels. i'm not sure if 
it is possible (so when including a url, the panel class will be called)

ittay

Ittay Dror wrote:
ok, this is what i did given the existing wicket code. i'm sure it can be done better by changing the code itself

1. change newWebRequest in QrmApplication
protected WebRequest newWebRequest(final HttpServletRequest servletRequest) {
       if (servletRequest.getPathInfo() == null) {
if (servletRequest.getAttribute("javax.servlet.include.request_uri") != null) {
               return new IncludedServletWebRequest(servletRequest);
           }
if (servletRequest.getAttribute("javax.servlet.forward.request_uri") != null) {
               return new ForwardedServletWebRequest(servletRequest);
           }
log.error("Could not find an implementation of WebRequest that fits this request. trying the default"); } return super.newWebRequest(servletRequest);
   }

2. create IncludedServletWebRequest and ForwardedServletWebRequest. they extend BaseServletWebRequest
for IncludedServletWebRequest:
    public String getPath() {
return (String)getHttpServletRequest().getAttribute("javax.servlet.include.path_info"); }

    public String getContextPath() {
return (String)getHttpServletRequest().getAttribute("javax.servlet.include.context_path");
    }

    public String getServletPath() {
return (String)getHttpServletRequest().getAttribute("javax.servlet.include.servlet_path");
    }

3. create BaseServletWebRequest, extending ServletWebRequest and rewrite getRelativeURL

    public String getRelativeURL() {
        /**
         * Servlet 2.3 specification :
* * Servlet Path: The path section that directly corresponds to the * mapping which activated this request. This path starts with a "/" * character except in the case where the request is matched with the
         * "/*" pattern, in which case it is the empty string.
* * PathInfo: The part of the request path that is not part of the * Context Path or the Servlet Path. It is either null if there is no
         * extra path, or is a string with a leading "/".
         */
        String url = getServletPath();
        final String pathInfo = getPath();

        if (pathInfo != null)
        {
            url += pathInfo;
        }

final String queryString = getHttpServletRequest().getQueryString();

        if (queryString != null)
        {
            url += ("?" + queryString);
        }

// If url is non-empty it has to start with '/', which we should lose
        if (!url.equals(""))
        {
            // Remove leading '/'
            url = url.substring(1);
        }
        return url;
    }


4. if using a form create an EmbeddedForm class, and override the onComponentTag

here i can't give a generic code, but the basic thing is to rewrite the action, tag, so it goes to the original page, and put the action as a parameter in the url, which is used by the containing page to include

    protected void onComponentTag(ComponentTag tag) {
        super.onComponentTag(tag);
        String action = tag.getAttributes().getString("action");
        Map parameters = new HashMap(getRequest().getParameterMap());
        parameters.put("wicketAction", action);
String newAction = containingUrl + StringUtils.toString(parameters, "&", null);
        tag.put("action", newAction);
    }

in the jsp, the code should be something like
<jsp:include page="<%=request.getParameter("wicketAction") == null ? "url-to-wicket" : request.getParameter("wicketAction") %>"/>

hope it helps,

ittay



Juergen Donnerstag wrote:
Sure. An example is more than welcome.

Juergen

On 5/9/06, Ittay Dror <[EMAIL PROTECTED]> wrote:
i've done some work to enable embedding wicket pages in jsp pages. this is required by us, since we're currently using struts, and can't move all our code to wicket. i think it is important to enable existing projects to start using wicket.

the main problems in that HttpServletRequest.getPath() returns null for forwarded/included pages

i can submit the code if you want

--
===================================
Ittay Dror
Chief architect, openQRM TL,
R&D, Qlusters Inc.
[EMAIL PROTECTED]
+972-3-6081994 Fax: +972-3-6081841

http://www.openQRM.org
- Keeps your Data-Center Up and Running


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=k&kid0709&bid&3057&dat1642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user





--
===================================
Ittay Dror Chief architect, openQRM TL, R&D, Qlusters Inc.
[EMAIL PROTECTED]
+972-3-6081994 Fax: +972-3-6081841

http://www.openQRM.org
- Keeps your Data-Center Up and Running


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to