Can we autoadd it if we regconize we are handling a mounted URL? So
that the page will keep on working without the user having to know
anything else than just how to mount to a certain path?

Eelco

On 12/3/05, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> for non-portlet environments the same can be accomplished by adding one of
> these to the <head> element, should i drop this into core?
>
> import javax.servlet.http.HttpServletRequest;
>
> import wicket.RequestCycle ;
> import wicket.markup.ComponentTag;
> import wicket.markup.html.WebComponent;
> import wicket.protocol.http.servlet.ServletWebRequest;
>
> /**
>  * Base tag that makes sure all links with relative paths are relative to
> the context root
>  *
>  * @author Igor Vaynberg (ivaynberg)
>  */
> public class BaseTag extends WebComponent {
>
>     public BaseTag(String id) {
>         super(id);
>     }
>
>     @Override
>     protected void onComponentTag(ComponentTag tag) {
>         checkComponentTag(tag, "base");
>         String href=buildBaseHref();
>         tag.put("href", href);
>     }
>
>     private String buildBaseHref() {
>         RequestCycle cycle=getRequestCycle();
>         ServletWebRequest request=(ServletWebRequest) cycle.getRequest();
>         HttpServletRequest req=request.getHttpServletRequest();
>
>         StringBuffer href = new StringBuffer();
>
>         String scheme = req.getScheme();
>
>         href.append(scheme);
>         href.append("://");
>         href.append(req.getServerName());
>
>         if(req.getServerPort()!=80) {
>             href.append(":");
>             href.append(req.getServerPort());
>         }
>         href.append(req.getContextPath());
>         href.append("/");
>
>         return href.toString();
>     }
> }
>
> -Igor
>
>
>
> On 12/3/05, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
> >
> > exactly :)
> >
> > Eelco
> >
> > On 12/3/05, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> > > here is my understanding of the usecase ( eelco feel free to jump in and
> > > tell me im smoking something at any point )
> > >
> > > lets say we have a wicket app that lives in http://localhost/wicketapp/
> and
> > > the servlet is mounted as /app/*   I also have a page called Test and
> inside
> > > the markup it has a link to an image like so <img src="images/dot.gif">
> > >
> > > when i hit the page its url is
> > > http://localhost/wicketapp/app?bookmarkablePage=Test
> > > so the browser sees this request originate for document:
> > > http://localhost/wicketapp/app when it is going to resolve the path of
> the
> > > image it will first check if it starts with /, it it does the exact path
> > > will be used, if it doesnt the path will be relative to the parent
> > > document's path.
> > >
> > > since the document is http://localhost/wicketapp/app its path is
> > > http://localhost/wicketapp/ so the image path will be resolved to
> > > http://localhost/wicketapp/images/dot.gif
> > >
> > > this is great because no matter what page i access the browser will
> always
> > > resolve its path to the root of my context. this allows me to have an
> images
> > > dir and a css dir and it is always safe to link as
> > > src="images/something.gif" or href="css/something.css"
> > >
> > > path mounting introduces a problem because while the entry point remains
> the
> > > same, browser will not see it that way. lets say i mount Test on
> > > /pages/t/Test. The url becomes
> > > http://localhost/wicketapp/app/pages/t/Test. now when
> the
> > > browser will try to resolve the image it will be resolved to
> > > http://localhost/wicketapp/app/pages/t/images/dot.gif .
> > > this is the problem.
> > >
> > > a key to fixing this would be to prepend all paths that do not start
> with a
> > > / with the context path.
> > > so <img src="images/dot.gif"> would become <img
> > > src="/wicketapp/images/dot.gif"> this will guarantee
> that
> > > no matter where the page lives the browser will always resolve relative
> to
> > > the root context (because the path starts with a / )
> > >
> > > -Igor
> > >
> > >
> > >
> > > On 12/3/05, Juergen Donnerstag <[EMAIL PROTECTED] > wrote:
> > > > On 12/3/05, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> > > > > Hi Juergen,
> > > > > just checked out your cvs changes for url prefixing. wouldnt it make
> > > more
> > > > > sense to prefix urls that /do not/ start with a slash. after all,
> those
> > > are
> > > > > the ones that would be broken if url mounting is used. i think all
> urls
> > > that
> > > > > start with a slash should be left alone because those are the ones
> that
> > > are
> > > > > referencing something off the server root context. all urls without
> the
> > > > > slash (relative to the app context) should be prefixed.
> > > > >
> > > >
> > > > I must admit I don't understand the whole use case already. And I
> > > > don't understand the mounted paths yet.
> > > > How do know that the relativ path is relative the context? wicket:link
> > > > creates links relative to the page (on the class path). Is that no
> > > > longer needed/possible?
> > > >
> > > >
> > > > > also is it really safe to modify every attribute? i would limit this
> to
> > > href
> > > > > and src attrs only i think.
> > > > >
> > > >
> > > > That is a good question. I had a short discussion with Eelco after he
> > > > asked how difficult it would be to implement it. We shortly discussed
> > > > using wicket:link, but the whole discussion I guess has only started
> > > > yet. The current implementation is not meant to be final at all.
> > > >
> > > > Juergen
> > > >
> > > >
> > > >
> -------------------------------------------------------
> > > > This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> > > files
> > > > for problems?  Stop!  Download the new AJAX search engine that makes
> > > > searching your log files as easy as surfing the  web.  DOWNLOAD
> SPLUNK!
> > > > http://ads.osdn.com/?ad_idv37&alloc_id865&opclick
> > > > _______________________________________________
> > > > Wicket-develop mailing list
> > > > Wicket-develop@lists.sourceforge.net
> > > >
> > >
> https://lists.sourceforge.net/lists/listinfo/wicket-develop
> > > >
> > >
> > >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> > for problems?  Stop!  Download the new AJAX search engine that makes
> > searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> > http://ads.osdn.com/?ad_idv37&alloc_id865&opclick
> > _______________________________________________
> > Wicket-develop mailing list
> > Wicket-develop@lists.sourceforge.net
> >
> https://lists.sourceforge.net/lists/listinfo/wicket-develop
> >
>
>


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Wicket-develop mailing list
Wicket-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to