You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Jan Vermeulen <ja...@isencia.com> on 2007/05/02 14:34:48 UTC

Backporting from 2.0: how to add custom MarkupFilters ?

In the former Wicket 2.0, adding a custom MarkupFilter could be done either
of 2 ways:

	getMarkupSettings().setMarkupParserFactory(new MarkupParserFactory(this) {			
		@Override
		public MarkupParser newMarkupParser() {
			MarkupParser parser = super.newMarkupParser();
				
			// register the additional filter
			parser.appendMarkupFilter(new MyFilter());
			return parser;
		}
	});

With the new trunk, this does no longer work, since MarkupParserFactory now
returns its own innerclass implementation of MarkupParser:

	public MarkupParser newMarkupParser()
	{
		final MarkupParser parser = new MarkupParser(new XmlPullParser())
		{
			public void initFilterChain()
			{
				if (filters != null)
				{
					for (int i = 0; i < filters.length; i++)
					{
						appendMarkupFilter(filters[i]);
					}
				}
			}
		};
		return parser;
	}

Since it adds its own extra filters in the call to initFilterChain(), and
this filters attribute is private, there is no nice way to add any extra
filters. Also the method initMarkupFilters(final MarkupParser parser) has
disappeared.

Would it be possible to:
* either have a method initMarkupFilters(final MarkupParser parser) again,
that could be called from within the newMarkupParser() method of the factory
* or have a way to add extra filters to the 'filters' array of the factory
(with a simple addFilter())

Or did I miss something ? What would be the correct way to add a custom
filter ?

 Jan.
-- 
View this message in context: http://www.nabble.com/Backporting-from-2.0%3A-how-to-add-custom-MarkupFilters---tf3680307.html#a10285092
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: Backporting from 2.0: how to add custom MarkupFilters ?

Posted by Johan Compagner <jc...@gmail.com>.
i am all for things that is simpler and cleaner! :)
backport!

On 5/2/07, Juergen Donnerstag <ju...@gmail.com> wrote:
>
> But I agree, in 2.0 it was much nicer (simpler, obvious, ...). I
> haven't backportet it yet.
>
> Juergen
>
> On 5/2/07, Igor Vaynberg <ig...@gmail.com> wrote:
> > i also see MarkupParser.appendMarkupFilter @ MarkupParser:167
> >
> > -igor
> >
> >
> > On 5/2/07, Jan Vermeulen <ja...@isencia.com> wrote:
> > >
> > >
> > > Sorry, I did miss something: there are constructors for
> > > MarkupParserFactory
> > > that accept one or more filters. Forget my request.
> > >
> > > Jan.
> > > --
> > > View this message in context:
> > >
> http://www.nabble.com/Backporting-from-2.0%3A-how-to-add-custom-MarkupFilters---tf3680307.html#a10285194
> > > Sent from the Wicket - Dev mailing list archive at Nabble.com.
> > >
> > >
> >
>

Re: Backporting from 2.0: how to add custom MarkupFilters ?

Posted by Juergen Donnerstag <ju...@gmail.com>.
But I agree, in 2.0 it was much nicer (simpler, obvious, ...). I
haven't backportet it yet.

Juergen

On 5/2/07, Igor Vaynberg <ig...@gmail.com> wrote:
> i also see MarkupParser.appendMarkupFilter @ MarkupParser:167
>
> -igor
>
>
> On 5/2/07, Jan Vermeulen <ja...@isencia.com> wrote:
> >
> >
> > Sorry, I did miss something: there are constructors for
> > MarkupParserFactory
> > that accept one or more filters. Forget my request.
> >
> > Jan.
> > --
> > View this message in context:
> > http://www.nabble.com/Backporting-from-2.0%3A-how-to-add-custom-MarkupFilters---tf3680307.html#a10285194
> > Sent from the Wicket - Dev mailing list archive at Nabble.com.
> >
> >
>

Re: Backporting from 2.0: how to add custom MarkupFilters ?

Posted by Igor Vaynberg <ig...@gmail.com>.
i also see MarkupParser.appendMarkupFilter @ MarkupParser:167

-igor


On 5/2/07, Jan Vermeulen <ja...@isencia.com> wrote:
>
>
> Sorry, I did miss something: there are constructors for
> MarkupParserFactory
> that accept one or more filters. Forget my request.
>
> Jan.
> --
> View this message in context:
> http://www.nabble.com/Backporting-from-2.0%3A-how-to-add-custom-MarkupFilters---tf3680307.html#a10285194
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>

Re: Backporting from 2.0: how to add custom MarkupFilters ?

Posted by Jan Vermeulen <ja...@isencia.com>.
Sorry, I did miss something: there are constructors for MarkupParserFactory
that accept one or more filters. Forget my request.

Jan.
-- 
View this message in context: http://www.nabble.com/Backporting-from-2.0%3A-how-to-add-custom-MarkupFilters---tf3680307.html#a10285194
Sent from the Wicket - Dev mailing list archive at Nabble.com.