You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "spam2008@meeque.de" <sp...@meeque.de> on 2010/08/03 01:26:30 UTC

Proposal: HierarchicConverterLocator, an IConverterLocator that adheres to the class hierarchy

Hello Folks,


Recently I came across a small shortcoming (IMHO) in the way Wicket's
default IConverterLocator implementation handles inheritance. It seems
that the ConverterLocator only returns an IConverter, if one is
registered for the exact given Class. If such an IConverter is not
present, it returns null. 

However, any IConverter that is capable of converting a superclass of
the given Class, might also be suitable. For instance, if an IConverter
for Class ArrayList is requested, a more generic IConverter for Class
List might work as well.

It might be handy to register a generic IConverter for a supertype of
the class hierarchy and let it handle conversion for all subclasses.
This would also allow to register IConverters for abstract classes and
interfaces. And it might solve certain problems people have reported
about converting CGLib-enhanced proxy objects, like the ones often
returned by Hibernate.


In my Wicket app, I use a custom HierarchicConverterLocator, that
searches for IConverters using the superclass hierarchy. It is a
quick-and-dirty implementation, without any performance optimizations.
But it works very well for me!

If anyone thinks this might be useful, I can do a little more effort and
maybe contribute it. You can find (most of) the code below...


Regards,
Michael Riedel



/**
 *
 */
public class HierarchicConverterLocator implements IConverterLocator
{	
	/** */
	private ConverterLocator converterLocator = 
			new ConverterLocator();

	/**
	 * 
	 */
	@Override
	public IConverter getConverter( Class<?> type )
	{
		final IConverter converter = getConverterOrNull( type );
		if( converter == null )
		{
			return converterLocator.getConverter( type );
		}
		return converter;
	}
	
	/**
	 * 
	 */
	private IConverter getConverterOrNull( Class<?> type )
	{
		if( type == null )
		{
			return null;
		}
		
		final IConverter converter = get( type );
		if( converter == null )
		{
			final List<Class<?>> superTypes = 
				new LinkedList<Class<?>>();
			superTypes.add( type.getSuperclass() );
			superTypes.addAll( 
				Arrays.asList( type.getInterfaces() ) 
				);
			
			for( Class<?> superType : superTypes )
			{
				final IConverter superTypeConverter = 
					getConverterOrNull( superType );
				if ( superTypeConverter != null )
				{
					return superTypeConverter;
				}
			}
		}
		return converter;
	}

	/**
	 * 
	 */
	public IConverter get( final Class<?> type )
	{
		return converterLocator.get( type );
	}

	/**
	 * 
	 */
	public IConverter set( final Class<?> c, 
			final IConverter converter )
	{
		return converterLocator.set( c, converter );
	}
	
	/**
	 * 
	 */
	public IConverter remove(Class<?> c)
	{
		return converterLocator.remove( c );
	}
}


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: KonaKart shopping cart integration

Posted by Decebal Suiu <de...@asf.ro>.
Another good options is http://www.broadleafcommerce.org. 

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Proposal-HierarchicConverterLocator-an-IConverterLocator-that-adheres-to-the-class-hierarchy-tp2311126p2315426.html
Sent from the Wicket - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: KonaKart shopping cart integration

Posted by Steve Coughlan <st...@yahoo.com.au>.
Yes it manages inventory, order processing, payment gateways, users 
etc... So all of that is done with a nice admin interface already to 
go.  I'm just looking at building some front end component that use it's 
api for actual store front.  Their own default storefront is JSP based 
and they have an example of another one which I think was flash.

Got the rough outline of a category tree, product list, cart and search 
box done today to see how hard it was going to be and seems quite workable.

Per Lundholm wrote:
> When you wrote "shopping cart", I assumed it was only the widget which
> presents what the customer bought and some mechanism for keeping that
> in the session. KonaKart seems to be a lot more than that.
>
> /Per
>
> On Tue, Aug 3, 2010 at 2:35 AM, Steve Coughlan
> <st...@yahoo.com.au> wrote:
>   
>> I've been looking for a shopping cart solution that I can properly integrate
>> with wicket.  There's been a few threads on this list where people have
>> indicated they were building one but as far as I know nothing has ever
>> eventuated.
>>
>> I don't really want to build to whole engine from scratch so I've been
>> looking around and come across konakart.  It's partially open source.
>>  Meaning the engine itself is closed but it has a complete (and well
>> documented) integration layer.  I think this would be a good solution
>> because all the backend functionality is there along with a nice admin
>> panel.
>>
>> The interface is either Java or SOAP (one line of code to switch between the
>> two) which means you can run your cart engine on another server if you want.
>>
>> So what I'm proposing is build a set of front-end wicket components.  I'd
>> prefer a fully open source solution but in the free java space this seems to
>> be the easiest solution I can find.  I really don't have time to build an
>> engine from the ground up.
>>
>> So before I get going I just wanted to bounce it off the community and see
>> if anyone can think of a better solution?
>>
>> I only just come across brix and I'm still trying to get my head around it.
>>  Any comments on whether  I should make this brix centric or pure wicket?
>>
>> p.s. If I do build these components then I will release them as LGPL...
>>
>> ---------------------------------------------------------------------
>> 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: KonaKart shopping cart integration

Posted by Per Lundholm <pe...@crisp.se>.
When you wrote "shopping cart", I assumed it was only the widget which
presents what the customer bought and some mechanism for keeping that
in the session. KonaKart seems to be a lot more than that.

/Per

On Tue, Aug 3, 2010 at 2:35 AM, Steve Coughlan
<st...@yahoo.com.au> wrote:
> I've been looking for a shopping cart solution that I can properly integrate
> with wicket.  There's been a few threads on this list where people have
> indicated they were building one but as far as I know nothing has ever
> eventuated.
>
> I don't really want to build to whole engine from scratch so I've been
> looking around and come across konakart.  It's partially open source.
>  Meaning the engine itself is closed but it has a complete (and well
> documented) integration layer.  I think this would be a good solution
> because all the backend functionality is there along with a nice admin
> panel.
>
> The interface is either Java or SOAP (one line of code to switch between the
> two) which means you can run your cart engine on another server if you want.
>
> So what I'm proposing is build a set of front-end wicket components.  I'd
> prefer a fully open source solution but in the free java space this seems to
> be the easiest solution I can find.  I really don't have time to build an
> engine from the ground up.
>
> So before I get going I just wanted to bounce it off the community and see
> if anyone can think of a better solution?
>
> I only just come across brix and I'm still trying to get my head around it.
>  Any comments on whether  I should make this brix centric or pure wicket?
>
> p.s. If I do build these components then I will release them as LGPL...
>
> ---------------------------------------------------------------------
> 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


KonaKart shopping cart integration

Posted by Steve Coughlan <st...@yahoo.com.au>.
I've been looking for a shopping cart solution that I can properly 
integrate with wicket.  There's been a few threads on this list where 
people have indicated they were building one but as far as I know 
nothing has ever eventuated.

I don't really want to build to whole engine from scratch so I've been 
looking around and come across konakart.  It's partially open source.  
Meaning the engine itself is closed but it has a complete (and well 
documented) integration layer.  I think this would be a good solution 
because all the backend functionality is there along with a nice admin 
panel.

The interface is either Java or SOAP (one line of code to switch between 
the two) which means you can run your cart engine on another server if 
you want.

So what I'm proposing is build a set of front-end wicket components.  
I'd prefer a fully open source solution but in the free java space this 
seems to be the easiest solution I can find.  I really don't have time 
to build an engine from the ground up.

So before I get going I just wanted to bounce it off the community and 
see if anyone can think of a better solution?

I only just come across brix and I'm still trying to get my head around 
it.  Any comments on whether  I should make this brix centric or pure 
wicket?

p.s. If I do build these components then I will release them as LGPL...

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org