You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by David Leangen <wi...@leangen.net> on 2007/08/30 03:31:31 UTC
Best way to add a MarkupFilter
What's the best way to add a markup filter to my app?
I noticed that in the settings I can override the MarkupParserFactory
and provide my own filter, but that is not what I want to do. I just
want to use the default factory, but add my own filter.
Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Best way to add a MarkupFilter
Posted by David Leangen <wi...@leangen.net>.
Hi, Eelco,
Well... looking at the other filters, the key to this is getting the
ContainerInfo from the Markup, since ContainerInfo has a getLocale()
method.
The best example of this is WicketMessageTagHandler, whose constructor
requires the ContainerInfo in its constructor:
public WicketMessageTagHandler(final ContainerInfo containerInfo)
The WicketMessageTagHandler is instantiated in
MarkupParser.initializeMarkupFilters():
final MarkupResourceStream resource = markup.getResource();
if (resource != null)
{
final ContainerInfo containerInfo = resource.getContainerInfo();
if (containerInfo != null)
{
if (WicketMessageTagHandler.enable)
{
appendMarkupFilter(new
WicketMessageTagHandler(containerInfo));
}
....
}
....
}
If I could also inject this into the constructor of my filter, I'd be
set!
This could be possible if we changed
protected void initFilterChain()
{
}
to
protected void initFilterChain(ContainerInfo containerInfo)
{
}
(or if we added in that method to the api)
That way, I'd just need to sublcass MarkupParser.
wdyt?
On Sat, 2007-09-01 at 12:56 -0700, Eelco Hillenius wrote:
> On 8/30/07, David Leangen <wi...@leangen.net> wrote:
> >
> > Ok, thanks!
> >
> > I've been looking for a way to somehow attach a Session to this filter,
> > but can't see one.
> >
> > Essentially, I am trying to grab certain tags (such as <p>) and add the
> > attribute lang="en" (or whatever, according to the current locale).
> >
> > Tried looking at the Page component, too, but didn't see any nice way of
> > doing this.
>
> Take a look at how other markup filters are implemented to get some
> inspiration. I think you should be able to do it by inserting auto
> tags when you recognize tags you want to modify at runtime. You might
> even make something neatly reusable out of it (a similar construct
> like <wicket:link> maybe?). Keep us informed.
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Best way to add a MarkupFilter
Posted by Eelco Hillenius <ee...@gmail.com>.
On 8/30/07, David Leangen <wi...@leangen.net> wrote:
>
> Ok, thanks!
>
> I've been looking for a way to somehow attach a Session to this filter,
> but can't see one.
>
> Essentially, I am trying to grab certain tags (such as <p>) and add the
> attribute lang="en" (or whatever, according to the current locale).
>
> Tried looking at the Page component, too, but didn't see any nice way of
> doing this.
Take a look at how other markup filters are implemented to get some
inspiration. I think you should be able to do it by inserting auto
tags when you recognize tags you want to modify at runtime. You might
even make something neatly reusable out of it (a similar construct
like <wicket:link> maybe?). Keep us informed.
Eelco
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Best way to add a MarkupFilter
Posted by David Leangen <wi...@leangen.net>.
Ok, thanks!
I've been looking for a way to somehow attach a Session to this filter,
but can't see one.
Essentially, I am trying to grab certain tags (such as <p>) and add the
attribute lang="en" (or whatever, according to the current locale).
Tried looking at the Page component, too, but didn't see any nice way of
doing this.
Any suggestions?
On Thu, 2007-08-30 at 11:19 +0200, Matej Knopp wrote:
> Hi,
>
> but the default factory doesn't do much, just creates markup parse. You have
> to create your own markup factory, it's trivial.
>
> IMarkupSettings.setMarkupParserFactory(new IMarkupParserFactory() {
> public MarkupParser newMarkupParser(final MarkupResourceStream resource)
> {
> MarkupParser mp = new MarkupParser(new XmlPullParser(), resource);
> mp.appendMarkupFilter(yourFilter);
> return mp;
> }
> });
>
> -Matej
>
> On 8/30/07, David Leangen <wi...@leangen.net> wrote:
> >
> >
> > What's the best way to add a markup filter to my app?
> >
> > I noticed that in the settings I can override the MarkupParserFactory
> > and provide my own filter, but that is not what I want to do. I just
> > want to use the default factory, but add my own filter.
> >
> >
> > Thanks!
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Best way to add a MarkupFilter
Posted by Matej Knopp <ma...@gmail.com>.
Hi,
but the default factory doesn't do much, just creates markup parse. You have
to create your own markup factory, it's trivial.
IMarkupSettings.setMarkupParserFactory(new IMarkupParserFactory() {
public MarkupParser newMarkupParser(final MarkupResourceStream resource)
{
MarkupParser mp = new MarkupParser(new XmlPullParser(), resource);
mp.appendMarkupFilter(yourFilter);
return mp;
}
});
-Matej
On 8/30/07, David Leangen <wi...@leangen.net> wrote:
>
>
> What's the best way to add a markup filter to my app?
>
> I noticed that in the settings I can override the MarkupParserFactory
> and provide my own filter, but that is not what I want to do. I just
> want to use the default factory, but add my own filter.
>
>
> Thanks!
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>