You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Norris <th...@gmail.com> on 2006/02/02 21:20:43 UTC

Specifying my own tapestry.url.BaseTagWriter

I'd like to use my own implementation of BaseTagWriter that does nothing.
This is so that relative anchor tag links work like our designers are used
to in static html pages.  I've tried overriding the Shell class to do
everything but write the base tag, and everything works fine (our html
templates are all in the servlet root).  But that's hackish and ugly.  Is
there a hivemind way to do this?  I'm sure there is but it's not jumping out
at me.

Thanks,
Chris

Re: Specifying my own tapestry.url.BaseTagWriter

Posted by Jason Suplizio <su...@gmail.com>.
Works well with friendly urls tho.

On 2/3/06, Kent Tong <ke...@cpttm.org.mo> wrote:
>
> Kent Tong <kent <at> cpttm.org.mo> writes:
>
> > I think this is a bug. BaseTagWriter should really use the URL of the
> > template as the BASE url, not the URL of its directory.
>
> On a second though, it will work only if friendly url is used with
> "html" as the extension. So, not a good solution.
>
> --
> Author of a book for learning Tapestry (http://www.agileskills2.org/EWDT)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

Re: Specifying my own tapestry.url.BaseTagWriter

Posted by Kent Tong <ke...@cpttm.org.mo>.
Kent Tong <kent <at> cpttm.org.mo> writes:

> I think this is a bug. BaseTagWriter should really use the URL of the
> template as the BASE url, not the URL of its directory.

On a second though, it will work only if friendly url is used with
"html" as the extension. So, not a good solution.

--
Author of a book for learning Tapestry (http://www.agileskills2.org/EWDT)


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Specifying my own tapestry.url.BaseTagWriter

Posted by Kent Tong <ke...@cpttm.org.mo>.
Chris Norris <thechrisproject.lists <at> gmail.com> writes:

> I'd like to use my own implementation of BaseTagWriter that does nothing.
> This is so that relative anchor tag links work like our designers are used
> to in static html pages. 

I think this is a bug. BaseTagWriter should really use the URL of the
template as the BASE url, not the URL of its directory.

--
Author of a book for learning Tapestry (http://www.agileskills2.org/EWDT)


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Specifying my own tapestry.url.BaseTagWriter

Posted by Chris Norris <th...@gmail.com>.
I found this, which explains the hivemind override pretty well:
http://jakarta.apache.org/hivemind/override.html

I made a BaseTagWriter that just does nothing.  I'm not sure we really need
any base tag at all.

-chris

On 2/2/06, Jason Suplizio <su...@gmail.com> wrote:
>
> Yeah, I had the same issue. I resolved it by creating my own version of
> the
> BaseTagWriter and then referencing that in hivemind...see the notes below.
>
> /**
> * Using the Tapestry shell component will construct and write a base
> * tag to the rendered html output. Doing so makes all the links within
> * the page relative to this tag. This ultimately breaks any inline anchor
> * tags. The solution is this class, which essentially does not write the
> * tag at all. Writing the base tag is a configurable Hivemind service,
> * therefore, to configure your Tapestry application you must tell Hivemind
> * to use this class as the base tag rendering service:
> *
> *  <implementation service-id="tapestry.url.BaseTagWriter">
> *      <create-instance class="
> com.expd.app.expo2.tapestry.components.EmptyBaseTagWriter"/>
> *    </implementation>
> *
> * @author
> *
> */
> public class EmptyBaseTagWriter implements IRender {
>
>     /**
>      * This prevents rendering of the any base tag.
>      */
>     public void render(IMarkupWriter writer, IRequestCycle cycle)
>     {
>         IPage page = cycle.getPage();
>         StringBuffer sb = new StringBuffer();
>         sb.append("/");
>         if(page.getNamespace().getId() == null)
>         {
>             String name = page.getPageName();
>             int slashx = name.lastIndexOf('/');
>             if(slashx > 0)
>                 sb.append(name.substring(0, slashx + 1));
>         }
>     }
>
> }
>
> On 2/2/06, Chris Norris <th...@gmail.com> wrote:
> >
> > I'd like to use my own implementation of BaseTagWriter that does
> nothing.
> > This is so that relative anchor tag links work like our designers are
> used
> > to in static html pages.  I've tried overriding the Shell class to do
> > everything but write the base tag, and everything works fine (our html
> > templates are all in the servlet root).  But that's hackish and
> ugly.  Is
> > there a hivemind way to do this?  I'm sure there is but it's not jumping
> > out
> > at me.
> >
> > Thanks,
> > Chris
> >
> >
>
>

Re: Specifying my own tapestry.url.BaseTagWriter

Posted by Jason Suplizio <su...@gmail.com>.
Yeah, I had the same issue. I resolved it by creating my own version of the
BaseTagWriter and then referencing that in hivemind...see the notes below.

/**
 * Using the Tapestry shell component will construct and write a base
 * tag to the rendered html output. Doing so makes all the links within
 * the page relative to this tag. This ultimately breaks any inline anchor
 * tags. The solution is this class, which essentially does not write the
 * tag at all. Writing the base tag is a configurable Hivemind service,
 * therefore, to configure your Tapestry application you must tell Hivemind
 * to use this class as the base tag rendering service:
 *
 *  <implementation service-id="tapestry.url.BaseTagWriter">
 *      <create-instance class="
com.expd.app.expo2.tapestry.components.EmptyBaseTagWriter"/>
 *    </implementation>
 *
 * @author
 *
 */
public class EmptyBaseTagWriter implements IRender {

    /**
     * This prevents rendering of the any base tag.
     */
    public void render(IMarkupWriter writer, IRequestCycle cycle)
    {
        IPage page = cycle.getPage();
        StringBuffer sb = new StringBuffer();
        sb.append("/");
        if(page.getNamespace().getId() == null)
        {
            String name = page.getPageName();
            int slashx = name.lastIndexOf('/');
            if(slashx > 0)
                sb.append(name.substring(0, slashx + 1));
        }
    }

}

On 2/2/06, Chris Norris <th...@gmail.com> wrote:
>
> I'd like to use my own implementation of BaseTagWriter that does nothing.
> This is so that relative anchor tag links work like our designers are used
> to in static html pages.  I've tried overriding the Shell class to do
> everything but write the base tag, and everything works fine (our html
> templates are all in the servlet root).  But that's hackish and ugly.  Is
> there a hivemind way to do this?  I'm sure there is but it's not jumping
> out
> at me.
>
> Thanks,
> Chris
>
>