com.cc.framework.ui.control
Class Control

java.lang.Object
  extended bycom.cc.framework.ui.control.Control
All Implemented Interfaces:
AccessControlled, ActionBehavior, ClientHandler, java.io.Serializable
Direct Known Subclasses:
ButtonControl, CheckboxControl, CheckboxGroupControl, ComboBoxControl, CrumbsControl, FormControl, FrameControl, GaugeControl, HeadlineControl, InfoControl, ListControl, MenuControl, MessageControl, PanelControl, RatingControl, RecurrencePatternControl, SchedulerControl, SelectControl, SwapSelectControl, TabbarControl, TextareaControl, TextControl, TextListControl, TreeControl, TreeSwapSelectControl

public abstract class Control
extends java.lang.Object
implements ActionBehavior, AccessControlled, ClientHandler, java.io.Serializable

Base class for controls

Since:
1.0
Version:
$Revision: 1.63 $
Author:
Harald Schulz
See Also:
Serialized Form

Field Summary
private  java.util.Collection buttons
          Collection of optional Buttons that should be displayed next to the Control Collection<Control>
private static java.lang.String ERR_ACTION
          Error message
private static java.lang.String ERR_MISSING_CTX
          Error Message
protected  org.apache.commons.logging.Log log
          Commons Logging instance.
private  Principal principal
          The principal object
private static long serialVersionUID
          Serial Version UID
 
Constructor Summary
Control()
          Constructor
 
Method Summary
 void addButton(Control button)
          Adds a tool button to the Text Element
 boolean allowAjaxRendering()
          This method decides whether this control instance has enough information to render the control as part of an AJAX response.
 void execute(ControlRequestContext ctx)
          Delegates all incoming action to the action handler
 void execute(ControlRequestContext ctx, java.util.Collection params)
          Delegates all incoming action to the action handler
 void execute(ControlRequestContext ctx, java.lang.Object p1)
          Delegates all incoming action to the action handler
 void execute(ControlRequestContext ctx, java.lang.Object[] params)
          Delegates all incoming action to the action handler
 void execute(ControlRequestContext ctx, java.lang.Object p1, java.lang.Object p2)
          Delegates all incoming action to the action handler
 void execute(ControlRequestContext ctx, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3)
          Delegates all incoming action to the action handler
 void execute(java.lang.Object[] params)
          Delegates all incoming action to the action handler.
 java.lang.String getAction()
          Returns the action which is assigned to the control
 java.lang.String getAjaxId()
          Returns the AJAX container id of the control or null when the control is not AJAX relevant.
 java.util.Collection getButtons()
          Retrieves a list of button that are assigned to this Filed
 java.lang.String getControlName()
          Returns the name of the control
abstract  DataModel getDataModel()
          Returns the data model of the Control
abstract  ControlDesignModel getDesignModel()
          Returns the design model of the control
 DesignRule[] getDesignRules()
          Returns the design rules for this control
 java.lang.String getFrameworkString(java.lang.String resourceId, java.lang.Object[] arguments, java.util.Locale locale)
          This method gets called whenever a string resource identifier needs to be resolved.
 java.lang.String getHandler(ClientEvent event)
          Returns the script handler which was associated for a client event
 ClientEvent[] getHandlers()
          Returns the list of events for which client handler have been registered.
 java.lang.String getHeight()
          Returns the height of the control
 java.lang.String getHelp()
          Returns the Help id that is associated with this control element.
 java.lang.String getId()
          Returns the Control Id
 java.lang.String getLocaleName()
          Gets the Local Setting for this Control
 java.lang.String getName()
          Returns the Control Name
 Permission getPermission()
          Returns the authorizations required to access an object If the method returns null no access rights is required.
 Principal getPrincipal()
          Returns the principal object
 java.lang.String getProperty()
          Returns the property Attribute
 RunAt getRunAt()
          Returns if the control works with or without server round trips.
abstract  StateModel getStateModel()
          Returns the state model of the control
 java.lang.String getStyle()
          Returns the Style
 java.lang.String getStyleClass()
          Returns the StyleClass
 java.lang.String getStyleId()
          returns the StyleId
 java.lang.String getSummary()
          Retrieves the property that can be used for rendering to non-visual media such as speech or Braille
 int getTabIndex()
          Retrieves the optional tooltip text
 java.lang.String getTooltip()
          Retrieves the optional tooltip text
 boolean getTransaction()
          Checks if the framework should include a transaction token (if any) in all generated hyperlinks for this action.
 java.lang.String getUniqueStyleId()
          Returns a unique Style id for the given control
 java.lang.String getWidth()
          Returns the width of the control
 boolean isAjaxEnabled()
          This method checks if the element should send AJAX requests to the server
 boolean isDisabled()
          Returns the disabled Flag
 boolean isFormElement()
          Checks if the control should act like a form element.
 void markDirty(ControlRequestContext ctx)
          This method marks the control as dirty when it has changed its state during an AJAX request.
 void onHelp(ControlRequestContext ctx, java.lang.String helpId)
          Default Handler for the Help Event
private  void readObject(java.io.ObjectInputStream in)
          Read the non-static and non-transient fields of the current class from this stream.
 void setAjaxAttribute(ControlRequestContext ctx, java.lang.String name, java.lang.Object value)
           
 void setHandler(ClientEvent event, java.lang.String handler)
          Registers a client handler for an client event
 void setPrincipal(Principal principal)
          Sets the principal object
 void setValue(RequestContext ctx, ControlValuePath path, java.lang.String[] values)
          This method is called to set the value of the data model
 boolean show(Principal principal)
          Checks if the Object has a required permission.
 boolean showButton(ControlButton button)
          This Method is called by the Painter before rendering a Button.
 void synchronizeState(PropertyMap properties)
          This method applies the given state properties to the controls state model
 void synchronizeState(RequestContext ctx, PropertyMap properties)
          This method applies the given state properties to the controls state model
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serial Version UID

See Also:
Constant Field Values

ERR_ACTION

private static final java.lang.String ERR_ACTION
Error message

See Also:
Constant Field Values

ERR_MISSING_CTX

private static final java.lang.String ERR_MISSING_CTX
Error Message

See Also:
Constant Field Values

log

protected transient org.apache.commons.logging.Log log
Commons Logging instance.


principal

private transient Principal principal
The principal object


buttons

private java.util.Collection buttons
Collection of optional Buttons that should be displayed next to the Control

Collection<Control>

Constructor Detail

Control

public Control()
Constructor

Method Detail

readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Read the non-static and non-transient fields of the current class from this stream. All transient members are initialized.

Parameters:
in - the input stream
Throws:
java.io.IOException - if an I/O error occurs.
java.lang.ClassNotFoundException - if the class of a serialized object could not be found.

getId

public java.lang.String getId()
Returns the Control Id

Returns:
Control Id

getName

public java.lang.String getName()
Returns the Control Name

Returns:
Control Name

getTransaction

public boolean getTransaction()
Description copied from interface: ActionBehavior
Checks if the framework should include a transaction token (if any) in all generated hyperlinks for this action. The Transaction token is used to track form re-submissions.

Specified by:
getTransaction in interface ActionBehavior
Returns:
true if the transaction token should be generated
See Also:
ActionBehavior.getTransaction()

isAjaxEnabled

public boolean isAjaxEnabled()
Description copied from interface: ActionBehavior
This method checks if the element should send AJAX requests to the server

Specified by:
isAjaxEnabled in interface ActionBehavior
Returns:
returns true when the control should send AJAX requests.
See Also:
ActionBehavior.isAjaxEnabled()

getDesignModel

public abstract ControlDesignModel getDesignModel()
Returns the design model of the control

Returns:
The ControlDesignModel

getDataModel

public abstract DataModel getDataModel()
Returns the data model of the Control

Returns:
The data model

getStateModel

public abstract StateModel getStateModel()
Returns the state model of the control

Returns:
The state model

isFormElement

public boolean isFormElement()
Checks if the control should act like a form element. In this case all action on the control must result in a submission of the enclosing form. This means that the data which is required to detected the actual action on the control (drilldown, edit, ...) must be submit as form data and can not attached to the URL.

Returns:
true if the control acts like a form element.

getAction

public java.lang.String getAction()
Returns the action which is assigned to the control

Returns:
String

getWidth

public java.lang.String getWidth()
Returns the width of the control

Returns:
String

getHeight

public java.lang.String getHeight()
Returns the height of the control

Returns:
String

getProperty

public java.lang.String getProperty()
Returns the property Attribute

Returns:
String

getControlName

public java.lang.String getControlName()
Returns the name of the control

Returns:
String

getRunAt

public RunAt getRunAt()
Returns if the control works with or without server round trips.

Returns:
RunAt

allowAjaxRendering

public boolean allowAjaxRendering()
This method decides whether this control instance has enough information to render the control as part of an AJAX response.

Some controls can not be rendered without JSP processing.

Returns:
returns true when the control can be rendered in an AJAX response

getAjaxId

public java.lang.String getAjaxId()
Returns the AJAX container id of the control or null when the control is not AJAX relevant. A Control can be AJAX relevant although it has been configured with ajax="false" because one of its child components is AJAX relevant!

Returns:
AJAX id or null

getUniqueStyleId

public java.lang.String getUniqueStyleId()
Returns a unique Style id for the given control

Returns:
unique style id for the current request

getStyle

public java.lang.String getStyle()
Returns the Style

Returns:
String

getHelp

public java.lang.String getHelp()
Returns the Help id that is associated with this control element. If a control has a help id a little icon with a link to the help system will be created

Returns:
String returns the Help id of the element. The semantic of this id is completely in the responsibility of the applications help system

getTooltip

public java.lang.String getTooltip()
Retrieves the optional tooltip text

Returns:
tooltip text or null

getSummary

public java.lang.String getSummary()
Retrieves the property that can be used for rendering to non-visual media such as speech or Braille

Returns:
receives a description and/or structure of the object or null

getTabIndex

public int getTabIndex()
Retrieves the optional tooltip text

Returns:
tooltip text or null

getStyleId

public java.lang.String getStyleId()
returns the StyleId

Returns:
string

getStyleClass

public java.lang.String getStyleClass()
Returns the StyleClass

Returns:
String

isDisabled

public boolean isDisabled()
Returns the disabled Flag

Returns:
boolean

setHandler

public void setHandler(ClientEvent event,
                       java.lang.String handler)
Description copied from interface: ClientHandler
Registers a client handler for an client event

Specified by:
setHandler in interface ClientHandler
Parameters:
event - The client event (like onClick, onMouseOver, ...)
handler - The script handler associated with the event
See Also:
ClientHandler.setHandler(com.cc.framework.ui.model.ClientEvent, java.lang.String)

getHandler

public java.lang.String getHandler(ClientEvent event)
Returns the script handler which was associated for a client event

Specified by:
getHandler in interface ClientHandler
Parameters:
event - The event (like onClick, onMouseOver, ...)
Returns:
String The script handler oder null if no handler was associated.

getHandlers

public ClientEvent[] getHandlers()
Returns the list of events for which client handler have been registered.

Specified by:
getHandlers in interface ClientHandler
Returns:
the list of events

showButton

public boolean showButton(ControlButton button)
This Method is called by the Painter before rendering a Button. By overwriting this method a derived class can show or hide buttons.

Parameters:
button - ControlButton
Returns:
boolean

getFrameworkString

public java.lang.String getFrameworkString(java.lang.String resourceId,
                                           java.lang.Object[] arguments,
                                           java.util.Locale locale)
This method gets called whenever a string resource identifier needs to be resolved. The base class implementation will return null.

Parameters:
resourceId - the resource identifier
arguments - array with arguments for text markups
locale - the locale
Returns:
localized string resource or null to let the framework resolve the resource identifier

getPrincipal

public Principal getPrincipal()
Returns the principal object

Returns:
The principal object

setPrincipal

public void setPrincipal(Principal principal)
Sets the principal object

Parameters:
principal - The principal object

getLocaleName

public java.lang.String getLocaleName()
Gets the Local Setting for this Control

Returns:
Locale Setting

getDesignRules

public DesignRule[] getDesignRules()
Returns the design rules for this control

Returns:
Array of design rules

getPermission

public Permission getPermission()
Description copied from interface: AccessControlled
Returns the authorizations required to access an object If the method returns null no access rights is required.

Specified by:
getPermission in interface AccessControlled
Returns:
Permission A list with required permissions separated by ";"
See Also:
AccessControlled.getPermission()

show

public boolean show(Principal principal)
Description copied from interface: AccessControlled
Checks if the Object has a required permission.

Specified by:
show in interface AccessControlled
Parameters:
principal - the users principal object
Returns:
true if the permission exists
See Also:
AccessControlled.show(com.cc.framework.security.Principal)

addButton

public void addButton(Control button)
Adds a tool button to the Text Element

Parameters:
button - The button to add

getButtons

public java.util.Collection getButtons()
Retrieves a list of button that are assigned to this Filed

Returns:
Collection<ButtonControl> or null

synchronizeState

public void synchronizeState(PropertyMap properties)
                      throws java.lang.Exception
This method applies the given state properties to the controls state model

Parameters:
properties - State properties
Throws:
java.lang.Exception - is thrown when an error occurs during execution

synchronizeState

public void synchronizeState(RequestContext ctx,
                             PropertyMap properties)
                      throws java.lang.Exception
This method applies the given state properties to the controls state model

Parameters:
ctx - RequestContext
properties - State properties
Throws:
java.lang.Exception - is thrown when an error occurs during execution

setValue

public void setValue(RequestContext ctx,
                     ControlValuePath path,
                     java.lang.String[] values)
              throws java.lang.Exception
This method is called to set the value of the data model

Parameters:
ctx - The Action Context
path - Path Name of the input element
values - the values to set
Throws:
java.lang.Exception - a derived class can throw an exception if the value could not be set

execute

public void execute(ControlRequestContext ctx)
             throws java.lang.Exception
Delegates all incoming action to the action handler

Parameters:
ctx - ControlRequestContext
Throws:
java.lang.Exception - is thrown when an error occurs during execution

execute

public void execute(ControlRequestContext ctx,
                    java.lang.Object p1)
             throws java.lang.Exception
Delegates all incoming action to the action handler

Parameters:
ctx - ControlRequestContext
p1 - Optional parameter 1
Throws:
java.lang.Exception - is thrown when an error occurs during execution

execute

public void execute(ControlRequestContext ctx,
                    java.lang.Object p1,
                    java.lang.Object p2)
             throws java.lang.Exception
Delegates all incoming action to the action handler

Parameters:
ctx - ControlRequestContext
p1 - Optional parameter 1
p2 - Optional parameter 2
Throws:
java.lang.Exception - is thrown when an error occurs during execution

execute

public void execute(ControlRequestContext ctx,
                    java.lang.Object p1,
                    java.lang.Object p2,
                    java.lang.Object p3)
             throws java.lang.Exception
Delegates all incoming action to the action handler

Parameters:
ctx - ControlRequestContext
p1 - Optional parameter 1
p2 - Optional parameter 2
p3 - Optional parameter 3
Throws:
java.lang.Exception - is thrown when an error occurs during execution

execute

public void execute(ControlRequestContext ctx,
                    java.lang.Object[] params)
             throws java.lang.Exception
Delegates all incoming action to the action handler

Parameters:
ctx - ControlRequestContext
params - Parameter
Throws:
java.lang.Exception - is thrown when an error occurs during execution

execute

public void execute(ControlRequestContext ctx,
                    java.util.Collection params)
             throws java.lang.Exception
Delegates all incoming action to the action handler

Parameters:
ctx - ControlRequestContext
params - Parameter
Throws:
java.lang.Exception - is thrown when an error occurs during execution

execute

public void execute(java.lang.Object[] params)
             throws java.lang.Exception
Delegates all incoming action to the action handler. The first parameter must be the ControlRequestContext

Parameters:
params - Parameter
Throws:
java.lang.Exception - is thrown when an error occurs during execution

markDirty

public void markDirty(ControlRequestContext ctx)
This method marks the control as dirty when it has changed its state during an AJAX request. All dirty marked controls will be sent back to the client in a delta stream.

This is also the last chance for a control to cancel the AJAX request.

For example the list control can not render itself when it contains a HTML column. For that column type the JSP page has to be processed again. and the AJAX request has to be canceled. But when the list control has no HTML column it has all information to render itself without JSP processing!

Parameters:
ctx - the action context

setAjaxAttribute

public void setAjaxAttribute(ControlRequestContext ctx,
                             java.lang.String name,
                             java.lang.Object value)
Parameters:
ctx - the action context
name - the attribute name
value - the attribute value

onHelp

public void onHelp(ControlRequestContext ctx,
                   java.lang.String helpId)
            throws java.lang.Exception
Default Handler for the Help Event

Parameters:
ctx - ControlRequestContext
helpId - The Help Id of the Control
Throws:
java.lang.Exception - is thrown when an error occurs


Copyright © 2000-2005 SCC Informationssysteme GmbH. All Rights Reserved.