You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Leszek Gawron <lg...@apache.org> on 2011/03/04 13:47:07 UTC

Panel factories and @SpringBean

Hello,

Let's say I want to write some UI to edit some complicated configuration 
split into multiple entities in multiple maven modules. The UI needs to 
have one entry point though. So:

Let's create the UI based on TabbedPanel. Each of the tabs will be 
provided by different maven modules by the means of factories:

  > public interface JukeboxConfigPanelFactory extends Ordered {
> 	public IModel<String> getPanelTitle();
>
> 	public Panel getPanel( String id, IModel<Jukebox> jukeboxModel );
> }



Provided that I have a list of all panel factories (that is an actual 
problem!) I can do that:


> 		List<ITab> tabs = new ArrayList<ITab>();
>
> 		for ( JukeboxConfigPanelFactory factory : getPanelFactories() ) {
> 			tabs.add( new JukeboxConfigPanelFactoryAwareAbstractTab( factory, getJukeboxModel() ) );
> 		}
>
> 		add( new AjaxTabbedPanel( "tabs", tabs ) );

The problem is: HOW do I get all the panel factories defined in Spring 
context?

I cannot do :

@SpringBean
private List<JukeboxConfigPanelFactory> factories;

because this is not supported by 
org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.

I could create another spring bean:

> public interface JukeboxConfigPanelFactoryManager {
> 	public List<JukeboxConfigPanelFactory> getPanelFactoryList();
> }


> @Component
> public class JukeboxConfigPanelFactoryManagerImpl implements JukeboxConfigPanelFactoryManager, InitializingBean {
> 	private List<JukeboxConfigPanelFactory>	factoryList;
>
> 	@Autowired
> 	public JukeboxConfigPanelFactoryManagerImpl( List<JukeboxConfigPanelFactory> factoryList ) {
> 		this.factoryList = factoryList;
> 	}
>
> 	@Override
> 	public List<JukeboxConfigPanelFactory> getPanelFactoryList() {
> 		return Collections.unmodifiableList( factoryList );
> 	}
>
> 	@Override
> 	public void afterPropertiesSet() throws Exception {
> 		Collections.sort(	factoryList,
> 							new OrderComparator() );
> 	}
> }

so now I am able to get all factory implementations in one place:

> 		List<ITab> tabs = new ArrayList<ITab>();
>
> 		for ( JukeboxConfigPanelFactory factory : panelFactoryManager.getPanelFactoryList() ) {
> 			tabs.add( new JukeboxConfigPanelFactoryAwareAbstractTab( factory, getJukeboxModel() ) );
> 		}
>
> 		add( new AjaxTabbedPanel( "tabs", tabs ) );

But now the JukeboxConfigPanelFactoryAwareAbstractTab will fail 
miserably at serializing as only the manager has been wrapped with a 
proxy and not the factories underneath.

How can I approach the problem using current state of wicket-spring 
module? I haven't found a way to wrap the "factory" beans with proxy 
manually.

-- 
Leszek Gawron                              http://lgawron.blogspot.com

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


Re: Panel factories and @SpringBean

Posted by Igor Vaynberg <ig...@gmail.com>.
http://wicketinaction.com/2008/10/creating-pluggable-applications-with-wicket-and-spring/

-igor

2011/3/4 Leszek Gawron <lg...@apache.org>:
> Hello,
>
> Let's say I want to write some UI to edit some complicated configuration
> split into multiple entities in multiple maven modules. The UI needs to have
> one entry point though. So:
>
> Let's create the UI based on TabbedPanel. Each of the tabs will be provided
> by different maven modules by the means of factories:
>
>  > public interface JukeboxConfigPanelFactory extends Ordered {
>>
>>        public IModel<String> getPanelTitle();
>>
>>        public Panel getPanel( String id, IModel<Jukebox> jukeboxModel );
>> }
>
>
>
> Provided that I have a list of all panel factories (that is an actual
> problem!) I can do that:
>
>
>>                List<ITab> tabs = new ArrayList<ITab>();
>>
>>                for ( JukeboxConfigPanelFactory factory :
>> getPanelFactories() ) {
>>                        tabs.add( new
>> JukeboxConfigPanelFactoryAwareAbstractTab( factory, getJukeboxModel() ) );
>>                }
>>
>>                add( new AjaxTabbedPanel( "tabs", tabs ) );
>
> The problem is: HOW do I get all the panel factories defined in Spring
> context?
>
> I cannot do :
>
> @SpringBean
> private List<JukeboxConfigPanelFactory> factories;
>
> because this is not supported by
> org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.
>
> I could create another spring bean:
>
>> public interface JukeboxConfigPanelFactoryManager {
>>        public List<JukeboxConfigPanelFactory> getPanelFactoryList();
>> }
>
>
>> @Component
>> public class JukeboxConfigPanelFactoryManagerImpl implements
>> JukeboxConfigPanelFactoryManager, InitializingBean {
>>        private List<JukeboxConfigPanelFactory> factoryList;
>>
>>        @Autowired
>>        public JukeboxConfigPanelFactoryManagerImpl(
>> List<JukeboxConfigPanelFactory> factoryList ) {
>>                this.factoryList = factoryList;
>>        }
>>
>>        @Override
>>        public List<JukeboxConfigPanelFactory> getPanelFactoryList() {
>>                return Collections.unmodifiableList( factoryList );
>>        }
>>
>>        @Override
>>        public void afterPropertiesSet() throws Exception {
>>                Collections.sort(       factoryList,
>>                                                        new
>> OrderComparator() );
>>        }
>> }
>
> so now I am able to get all factory implementations in one place:
>
>>                List<ITab> tabs = new ArrayList<ITab>();
>>
>>                for ( JukeboxConfigPanelFactory factory :
>> panelFactoryManager.getPanelFactoryList() ) {
>>                        tabs.add( new
>> JukeboxConfigPanelFactoryAwareAbstractTab( factory, getJukeboxModel() ) );
>>                }
>>
>>                add( new AjaxTabbedPanel( "tabs", tabs ) );
>
> But now the JukeboxConfigPanelFactoryAwareAbstractTab will fail miserably at
> serializing as only the manager has been wrapped with a proxy and not the
> factories underneath.
>
> How can I approach the problem using current state of wicket-spring module?
> I haven't found a way to wrap the "factory" beans with proxy manually.
>
> --
> Leszek Gawron                              http://lgawron.blogspot.com
>
> ---------------------------------------------------------------------
> 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