|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jsxp.framework.ViewController
public class ViewController
The Class ViewController. A ViewController contains the code for any jsxp component. It has method
to be initialized, to validate input parameter, to define the result and so on.
Mostly it has
a corresponding view design file (e.g. index.xhtml), for an exclusion see AbstractCommandController
.
The ViewController is called by the jsxp framework if the corresponding view is requested.
Normally a ViewController class will be generated by the framework for each view design file.
You have to derive this generated class to enter your code. The generated file will have
special method to set view variables and to get access to identified jsxp element of the view.
These methods help you to get compile time safety.
You can also derive your own ViewController classes to build specialized ones or to make a
new component based on an existing.
The ViewController follows a ViewControllerLifeCycle
for each request. You can get access
to the life cycle by getLifeCycle()
and you can add a PhaseListener
to get more control by ViewControllerLifeCycle.addPhaseListener(LifeCyclePhase, PhaseListener)
.
The possibles phases are listed in this enum: ViewControllerLifeCycle.LifeCyclePhase
.
Field Summary | |
---|---|
java.util.Map<java.lang.String,InternalElement> |
idElements
|
Constructor Summary | |
---|---|
ViewController(java.lang.String viewFilename)
Instantiates a new view controller. |
Method Summary | ||
---|---|---|
void |
addElement(Element element)
Adds the element. |
|
void |
addElementProcessor(ElementProcessor elementProcessor)
Adds an element processor to this view controller. |
|
boolean |
containsVariable(java.lang.String key)
Check if the view contains the variable. |
|
void |
execute()
This method will be called by the jsxp framework in the execution phase. |
|
java.lang.String |
getCharacterEncoding()
Gets the character encoding from the Application.getDefaultCharacterEncoding() . |
|
java.lang.String |
getContentType()
Gets the content type from the Application.getDefaultContentType() . |
|
Element |
getElement(java.lang.String id)
Returns the element with the jsxp id. |
|
protected
|
getElement(java.lang.String id,
java.lang.Class<T> interfaceType)
Gets the element with the jsxp id. |
|
Element |
getElement(java.lang.String id,
int index)
Returns the element with the jsxp id and index (used if elements are inserted via element templating). |
|
Element |
getElement(java.lang.String idPrefix,
java.lang.String id)
Returns the element with the jsxp id prefix and id |
|
Element |
getElement(java.lang.String idPrefix,
java.lang.String id,
int index)
Returns the element with the jsxp id prefix and id and index (used if elements are inserted via element templating). |
|
java.lang.String |
getIdPrefix()
Gets the id prefix. |
|
java.lang.Object |
getInputParameterBean()
Gets an instance of the input parameter bean. |
|
ViewControllerLifeCycle |
getLifeCycle()
Gets the life cycle. |
|
protected ViewController |
getParent()
Gets the parent ViewController, e.g. |
|
java.lang.Object |
getPreviousInputParameterBean()
Gets an instance of the previous input parameter bean. |
|
Element |
getRootElement()
Gets the root element. |
|
int |
getStatusCode()
Gets the status code. |
|
protected ViewController |
getTemplatedView()
Gets the templated view if this view controller is use as a template. |
|
protected Element[] |
getTemplateElements()
Gets the template elements. |
|
protected Validator |
getValidator()
Gets the validator that you can use in the view controller.. |
|
java.lang.String |
getValueForVariable(java.lang.String key)
Gets the value for a view variable. |
|
java.util.Map<java.lang.String,java.lang.String> |
getVariables()
Gets the variables as key/value map. |
|
java.lang.String |
getViewFilename()
Gets the view filename. |
|
ViewController |
getViewTemplate()
Gets the view template. |
|
void |
handleExecutingException(java.lang.Exception e,
ViewController source)
Throws the given exception encapsulated in a runtime exception per default. |
|
void |
handleInitException(java.lang.Exception e,
ViewController source)
Throws the given exception encapsulated in a runtime exception per default. |
|
void |
handleInputProcessingException(java.lang.Exception e,
ViewController source)
Throws the given exception encapsulated in a runtime exception per default. |
|
void |
handlePreparingException(java.lang.Exception e,
ViewController source)
Throws the given exception encapsulated in a runtime exception per default. |
|
void |
handleRenderingException(java.lang.Exception e,
ViewController source)
Throws the given exception encapsulated in a runtime exception per default. |
|
void |
handleTemplatingException(java.lang.Exception e,
ViewController source)
Throws the given exception encapsulated in a runtime exception per default. |
|
void |
handleValidatingException(java.lang.Exception e,
ViewController source)
Throws the given exception encapsulated in a runtime exception per default. |
|
|
importView(T ViewController)
Import view. |
|
|
importView(T ViewController,
java.lang.String idPrefix,
boolean inputParameterInjection,
java.lang.String inputParameterPrefix)
Import view. |
|
protected void |
init()
This method will be called by the jsxp framework in the initializing phase. |
|
protected boolean |
isApplicationTemplateEnabled()
Configures if application template is enabled. |
|
protected boolean |
isSkipExecution()
Checks if is skip execution. |
|
boolean |
isUsedAsImportedView()
Checks if is used as imported view. |
|
boolean |
isUsedAsTemplate()
Checks if is used as template. |
|
boolean |
needToSaveScopesToSession()
Need to save scopes to session. |
|
protected void |
replaceVariableValue(java.lang.String variableName,
java.lang.String newValue)
Replace variable value. |
|
void |
setApplicationTemplateEnabled(boolean applicationTemplating)
|
|
void |
setNeedToSaveScopesToSession(boolean needToSaveScopesToSession)
Sets the need to save scopes to session. |
|
void |
setVariable(java.lang.String variableName,
java.lang.String value)
Sets the variable. |
|
|
setViewTemplate(ViewController viewTemplate)
Sets the view template. |
|
protected void |
skipExecution()
Skip execution. |
|
void |
validate()
This method will be called by the jsxp framework in the validation lifecycle phase. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.util.Map<java.lang.String,InternalElement> idElements
Constructor Detail |
---|
public ViewController(java.lang.String viewFilename)
viewFilename
- the view filenameMethod Detail |
---|
public final void addElement(Element element)
element
- the elementpublic final void addElementProcessor(ElementProcessor elementProcessor)
ViewControllerLifeCycle.LifeCyclePhase.ELEMENTPROCESSING
. The various ElementProcessor
can add special behaviour to elements (like Ajax behaviour or change of design).
elementProcessor
- public final boolean containsVariable(java.lang.String key)
key
- the key
public void execute() throws java.lang.Exception
execute()
method explicitly if
you want them also to be called. But recommended is to implemented code that should be executed
also if the ViewController is used indirectly when imported in the init()
method.
java.lang.Exception
- the exceptionpublic java.lang.String getCharacterEncoding()
Application.getDefaultCharacterEncoding()
. Override this method if your view has a special character
encoding. Default is UTF-8.
public java.lang.String getContentType()
Application.getDefaultContentType()
. Override this
method to get return a special content type.
public final Element getElement(java.lang.String id)
id
-
protected final <T extends Element> T getElement(java.lang.String id, java.lang.Class<T> interfaceType)
id
- the idinterfaceType
- the interface type
public final Element getElement(java.lang.String id, int index)
id
- index
-
public final Element getElement(java.lang.String idPrefix, java.lang.String id)
idPrefix
- id
-
public final Element getElement(java.lang.String idPrefix, java.lang.String id, int index)
idPrefix
- id
- index
-
public java.lang.String getIdPrefix()
public java.lang.Object getInputParameterBean()
public final ViewControllerLifeCycle getLifeCycle()
protected final ViewController getParent()
public java.lang.Object getPreviousInputParameterBean()
public final Element getRootElement()
public int getStatusCode()
protected final ViewController getTemplatedView()
protected Element[] getTemplateElements()
protected final Validator getValidator()
public final java.lang.String getValueForVariable(java.lang.String key)
key
- the key
public java.util.Map<java.lang.String,java.lang.String> getVariables()
public final java.lang.String getViewFilename()
public final ViewController getViewTemplate()
public void handleExecutingException(java.lang.Exception e, ViewController source)
handleExecutingException
in interface ViewControllerLifeCycleExceptionHandler
e
- the esource
- the sourceViewControllerLifeCycleExceptionHandler.handleExecutingException(java.lang.Exception, org.jsxp.framework.ViewController)
public void handleInitException(java.lang.Exception e, ViewController source)
handleInitException
in interface ViewControllerLifeCycleExceptionHandler
e
- the esource
- the sourceViewControllerLifeCycleExceptionHandler.handleInitException(java.lang.Exception, org.jsxp.framework.ViewController)
public void handleInputProcessingException(java.lang.Exception e, ViewController source)
handleInputProcessingException
in interface ViewControllerLifeCycleExceptionHandler
e
- the esource
- the sourceViewControllerLifeCycleExceptionHandler.handleInputProcessingException(java.lang.Exception, org.jsxp.framework.ViewController)
public void handlePreparingException(java.lang.Exception e, ViewController source)
handlePreparingException
in interface ViewControllerLifeCycleExceptionHandler
e
- the esource
- the sourceViewControllerLifeCycleExceptionHandler.handlePreparingException(java.lang.Exception, org.jsxp.framework.ViewController)
public void handleRenderingException(java.lang.Exception e, ViewController source)
handleRenderingException
in interface ViewControllerLifeCycleExceptionHandler
e
- the esource
- the sourceViewControllerLifeCycleExceptionHandler.handleRenderingException(java.lang.Exception, org.jsxp.framework.ViewController)
public void handleTemplatingException(java.lang.Exception e, ViewController source)
handleTemplatingException
in interface ViewControllerLifeCycleExceptionHandler
e
- the esource
- the sourceViewControllerLifeCycleExceptionHandler.handleTemplatingException(java.lang.Exception, org.jsxp.framework.ViewController)
public void handleValidatingException(java.lang.Exception e, ViewController source)
handleValidatingException
in interface ViewControllerLifeCycleExceptionHandler
e
- the esource
- the sourceViewControllerLifeCycleExceptionHandler.handleValidatingException(java.lang.Exception, org.jsxp.framework.ViewController)
public final <T extends ViewController> T importView(T ViewController) throws java.lang.Exception
ViewController
- the view control
java.lang.Exception
- the exceptionpublic final <T extends ViewController> T importView(T ViewController, java.lang.String idPrefix, boolean inputParameterInjection, java.lang.String inputParameterPrefix) throws java.lang.Exception
ViewController
- the view controlidPrefix
- the id prefixinputParameterInjection
- the input parameter injectioninputParameterPrefix
- the input parameter prefix
java.lang.Exception
- the exceptionprotected void init() throws java.lang.Exception
java.lang.Exception
- the exceptionprotected boolean isApplicationTemplateEnabled()
setApplicationTemplateEnabled(boolean)
method.
protected final boolean isSkipExecution()
public final boolean isUsedAsImportedView()
public final boolean isUsedAsTemplate()
public final boolean needToSaveScopesToSession()
setNeedToSaveScopesToSession(boolean)
with true as parameter.
This has the effect that the jsxp framework will create a session and save the scopes
in it, so you can access them later.
protected final void replaceVariableValue(java.lang.String variableName, java.lang.String newValue)
variableName
- the variable namenewValue
- the new valuepublic final void setApplicationTemplateEnabled(boolean applicationTemplating)
public final void setNeedToSaveScopesToSession(boolean needToSaveScopesToSession)
needToSaveScopesToSession
- the new need to save scopes to sessionpublic final void setVariable(java.lang.String variableName, java.lang.String value)
variableName
- the variable namevalue
- the valuepublic final <ViewTemplateInputParameterType> void setViewTemplate(ViewController viewTemplate)
viewTemplate
- the new view templateprotected final void skipExecution()
public void validate() throws java.lang.Exception
Validator
if you want the simple jsxp validation support.
java.lang.Exception
- the exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |