org.springframework.richclient.script
Class ScriptedView

java.lang.Object
  extended by org.springframework.richclient.application.support.ApplicationServicesAccessor
      extended by org.springframework.richclient.factory.AbstractControlFactory
          extended by org.springframework.richclient.application.support.AbstractView
              extended by org.springframework.richclient.script.ScriptedView
All Implemented Interfaces:
InitializingBean, PropertyChangePublisher, PageComponent, View, DescribedElement, VisualizedElement, ControlFactory

public class ScriptedView
extends AbstractView
implements InitializingBean

A View implementation that uses ScriptEngine to build its control.

Author:
Peter De Bruycker

Field Summary
 
Fields inherited from class org.springframework.richclient.application.support.ApplicationServicesAccessor
logger
 
Fields inherited from interface org.springframework.richclient.core.DescribedElement
CAPTION_PROPERTY, DESCRIPTION_PROPERTY, DISPLAY_NAME_PROPERTY
 
Constructor Summary
ScriptedView()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  JComponent createControl()
          Subclasses must override this method to create a new instance of the control that this factory produces.
protected  javax.script.ScriptEngine createScriptEngine()
          Creates the ScriptEngine, by using the engineName if provided.
protected  void populateBindings(javax.script.Bindings bindings, JComponent container)
          Populates the bindings that will be passed to the script.
 void setContainerBindingName(String containerBindingName)
          Sets the container binding name.
 void setEngineName(String name)
          Sets the name of the engine to be created.
 void setScript(Resource script)
           
 void setScriptBindings(Map<String,Object> bindings)
          Set the bindings to be passed to the script.
 void setViewBindingName(String viewBindingName)
          Sets the view binding name.
 
Methods inherited from class org.springframework.richclient.application.support.AbstractView
addPropertyChangeListener, addPropertyChangeListener, canClose, close, componentClosed, componentFocusGained, componentFocusLost, componentOpened, dispose, getCaption, getContext, getDescription, getDescriptor, getDisplayName, getIcon, getId, getImage, getStatusBar, getWindowCommandManager, getWindowControl, registerLocalCommandExecutors, removePropertyChangeListener, removePropertyChangeListener, setContext, setDescriptor
 
Methods inherited from class org.springframework.richclient.factory.AbstractControlFactory
createControlIfNecessary, getControl, isControlCreated, isSingleton, setSingleton
 
Methods inherited from class org.springframework.richclient.application.support.ApplicationServicesAccessor
getActiveWindow, getApplication, getApplicationContext, getApplicationName, getApplicationServices, getCommandConfigurer, getComponentFactory, getConversionService, getIconSource, getImageSource, getMessage, getMessage, getMessage, getMessage, getMessages, getMessageSource, getObjectConfigurer, getService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.richclient.factory.ControlFactory
getControl
 

Constructor Detail

ScriptedView

public ScriptedView()
Method Detail

createControl

protected JComponent createControl()
Description copied from class: AbstractControlFactory
Subclasses must override this method to create a new instance of the control that this factory produces.

Specified by:
createControl in class AbstractView
Returns:
The newly created control, never null.

createScriptEngine

protected javax.script.ScriptEngine createScriptEngine()
Creates the ScriptEngine, by using the engineName if provided. If no engine name is set, the extension of the file name of the script is used.

Returns:
the ScriptEngine
See Also:
ScriptEngineManager.getEngineByName(String), ScriptEngineManager.getEngineByExtension(String)

populateBindings

protected void populateBindings(javax.script.Bindings bindings,
                                JComponent container)
Populates the bindings that will be passed to the script.

If the containerBindingName is set, the container instance will be included in the bindings.

If the viewBindingName is set, the view instance will be included in the bindings.

All the variables in the scriptBindings will also be included in the bindings.

Parameters:
bindings - the bindings
container - the compontent that will be passed into the script
See Also:
setContainerBindingName(String), setViewBindingName(String), setScriptBindings(Map)

setScript

public void setScript(Resource script)

setEngineName

public void setEngineName(String name)
Sets the name of the engine to be created. This name will be used to create the engine.

Parameters:
name - the name
See Also:
ScriptEngineManager.getEngineByName(String)

setScriptBindings

public void setScriptBindings(Map<String,Object> bindings)
Set the bindings to be passed to the script.

Parameters:
bindings - the bindings

setViewBindingName

public void setViewBindingName(String viewBindingName)
Sets the view binding name.

Parameters:
viewBindingName - the name
See Also:
for more details

setContainerBindingName

public void setContainerBindingName(String containerBindingName)
Sets the container binding name.

Parameters:
containerBindingName - the name
See Also:
for more details

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.