[Seaside] Re: How to register a WADispatcher derivate?

Stephan Eggermont stephan at stack.nl
Mon Mar 2 09:11:56 UTC 2015


On 02/03/15 09:33, David Carlos Manuelda wrote:
> I learnt how to register new application under default dispatcher or unders
> specified one with WAAdmin>>register:at: and its derivated functions.
>
> But now, I subclassed WADispatcher and I want to register it for later using
> to add root components to it programatically.
>
> It can be done via web config so I guess it can also be done
> programatically, but have no idea.

In QCMagritte, we do the following to make it easy to have
production and development versions
- production has no development tools
- production sets itself as default application (assumes one 
application/image)
- development sets the debugger error handler

QCApplication class>>registerForProductionAt: anApplicationName
	| application |
	application := self registerAt: anApplicationName.
	WAAdmin disableDevelopmentTools.
	WAAdmin defaultDispatcher defaultName: anApplicationName.
	^application

QCApplication class>>registerForDevelopmentAt: anApplicationName
	| application |
	WAAdmin enableDevelopmentTools.
	application := self registerAt: anApplicationName.
	application filter configuration at: #exceptionHandler put: 
WADebugErrorHandler.
	(self overridesDefaults includes: WAAdmin defaultDispatcher defaultName)
		ifTrue: [ WAAdmin defaultDispatcher defaultName: anApplicationName ].
	^application

QCApplication class>>registerAt: anApplicationName
	^(WAAdmin register: self asApplicationAt: anApplicationName)
		preferenceAt: #sessionClass put: self sessionClass;
		addLibrary: JQDeploymentLibrary;
		addLibrary: JQUiDeploymentLibrary;
		yourself

With overridesDefault we determine which application gets to be
default when loading multiple applications that all want to
be default. There are several groups in the QCMagritte configuration,
and when you load the tutorial, that should override the demo as
default.

QCTutorialApplication>>overridesDefaults
	^#( 'browse' 'welcome' 'QCMagritte Demo' )

QCApplication class>>overridesDefaults
	^#( 'browse' 'welcome' )

You can find a QCMagritte image at
https://ci.inria.fr/pharo-contribution/job/QCMagritte/

Stephan



More information about the seaside mailing list