/**
 * NM_Component.js
 * abstract class
 *
 * @author	Steffen Heinzelmann <shi@dmc.de>
 * @version	$Id: NM_Component.js 84734 2011-09-13 08:46:14Z sheinzelmann $
 */
var NM_Component = new Class(
{
	comid: 1,

	/**
	 * @var string component name
	 **/
	strComName: '',

	/**
	 * @var string object name if more than two components are registred
	 **/
	strObjName: '',

	/**
	 * @var string client id
	 **/
	strClientId: '',

	/**
	 * @var string country id
	 **/
	strCountryId: '',

	/**
	 * @var string lang id
	 **/
	strLangId: '',

	/**
	 * @var object language
	 **/
	objLang: {},

	/**
	 * @var object configuration
	 **/
	objConf: {},


	/* ---------------------------------------------------------------------- */

	/**
	 * constructor
	 *
	 * @param	object objParam
	 * @return 	void
	 **/
	initialize: function( objParam )
	{
		if( $type( objParam ) == 'object' )
		{
			this.strComName	= objParam.com_name;

			if( true ==  $defined( objParam.js_obj_name ) )
			{
				this.strObjName		= objParam.js_obj_name;
			}

			//localization
			this.strClientId 	= objParam.client_id;
			this.strCountryId 	= objParam.country_id;
			this.strLangId 		= objParam.lang_id;

			//NM_Console.dir( new NM_ConsoleMsg( this.getName(), 'initialize' ), objParam );

			//workaround for missing "com_name"
			if( false == $defined( objParam.com_name ) )
			{
				this.strComName = objParam.ComName;

				if( false == $defined( this.strComName ) )
				{
					this.strComName = objParam.COMName;
					if( false == $defined( this.strComName ) )
					{
						NM_Console.dir( new NM_ConsoleMsg( this.getName(), 'parameter "objParam.ComName" is deprecated, use "objParam.com_name".' ), objParam );
					}
				}
			}

			if( $type( objParam.com_name ) != 'string'
					&& ( objParam.ComName != '' || objParam.COMName != '' )
						)
			{
				this.warning( 'parameter "objParam.ComName" is deprecated, use "objParam.com_name".' );
			}

			// init lang object
			if( true == $defined( objParam.lang )
					&& $type( objParam.lang ) == 'object'
						)
			{
				this.objLang = objParam.lang;
			}

			// init conf object
			if( true == $defined( objParam.conf )
					&& $type( objParam.conf ) == 'object'
						)
			{
				this.objConf = objParam.conf;
			}
		}
		else
		{
			this.error( 'No objParam given. You must use for every component a param object! Ask Steffen for details ;-).' );
		}
	},


	/* ---------------------------------------------------------------------- */

	/**
	 * return the name of the component
	 *
	 * @return string
	 **/
	getName: function()
	{
		if( this.strObjName != '' )
		{
			return this.strObjName;
		}
		else
		{
			return this.strComName;
		}

	},

	// -------------------------------------------------------------------------
	// dimensions
	// -------------------------------------------------------------------------
	getViewPort: function()
	{
		return { 'width': window.getWidth(), 'height': window.getHeight() }
	},


	// -------------------------------------------------------------------------
	// localization
	// -------------------------------------------------------------------------

	/**
	 * return the client id
	 *
	 * @return string
	 **/
	getClientId: function()
	{
		return this.strClientId;
	},

	/**
	 * return the country id
	 *
	 * @return string
	 **/
	getCountryId: function()
	{
		return this.strCountryId;
	},

	/**
	 * return the language id
	 *
	 * @return string
	 **/
	getLangId: function()
	{
		return this.strLangId;
	},


	// -------------------------------------------------------------------------
	// language
	// -------------------------------------------------------------------------

	/**
	 * return a text by a given key
	 *
	 * @param  string strKey
	 * @return string
	 **/
	getText: function( strKey )
	{
		if( true == $defined( this.objLang[ strKey ] ) )
		{
			return this.objLang[ strKey ];
		}
		else
		{
			this.warning( 'text key >'+strKey+'< not found' );
			return 'text key >'+strKey+'< not found';
		}
	},


	// -------------------------------------------------------------------------
	// configuration
	// -------------------------------------------------------------------------

	/**
	 * return a conf value by a given key
	 *
	 * @param  string strKey
	 * @return string
	 **/
	getConf: function( strKey )
	{
		if( true == $defined( this.objConf[ strKey ] ) )
		{
			return this.objConf[ strKey ];
		}
		else
		{
			this.warning( 'conf key >'+strKey+'< not found' );
			return 'conf key >'+strKey+'< not found';
		}
	},


	// -------------------------------------------------------------------------
	// element handling
	// -------------------------------------------------------------------------

	/**
	 * return a text by a given key
	 *
	 * @param  string strKey
	 * @return string
	 **/
	replaceComHtml: function( elmCom, htmlContent )
	{
		try
		{
			if( htmlContent != '' )
			{
			var elmReplace = new Element( 'div' ).setHTML( htmlContent );
			elmCom.replaceWith( elmReplace.getFirst() );
		}
		}
		catch( e )
		{
			this.error( 'replaceComHtml: ' + e );
		}
	},


	// -------------------------------------------------------------------------
	//
	// event loader
	//
	// -------------------------------------------------------------------------

	/**
	 * Tegister event for the event loader
	 *
	 * @param  	object	objParam
	 * @param	integer	intPriority	10=highest, 99=lowest, 30=default
	 * @param	object	objTimer
	 * @return 	void
	 */
	registerEventLoad: function( objParam, intPriority, objTimer )
	{
		NM_EventLoader.register( this.getName(), new NM_Event( 'obj'+this.getName(), 'onLoad', objParam, objTimer, intPriority ) );
	},

	/**
	 * The onLoad method will be executed from the EventLoader
	 * if registerEventLoad was used
	 *
	 * Wrapper for the javascript events:
	 * http: 	onDomready
	 * https: 	onLoad
	 *
	 * @return void
	 */
	onLoad: function()
	{
		this.warning( 'The onLoad method must be implemented in the child class!' );
	},



	// -------------------------------------------------------------------------
	//
	// json request
	//
	// -------------------------------------------------------------------------

	/**
	 * fire a json request
	 *
	 * @access	public
	 * @param 	NM_ComponentRequestJson objRequest
	 * @param 	object objParam (json, optional)
	 * @return 	void
	 */
	fireRequest: function( objRequest, objParam )
	{
		if( true == DMC_System.isInstanceOf( objRequest, NM_ComponentRequestJson ) )
		{
			try
			{
				var strRequestUrl = NM_REQUEST_PATH_JSON;
				if( true == objRequest.isJavaRequest() )
				{
					strRequestUrl = NM_REQUEST_PATH_JSON_JAVA;
				}

				//send Json request
				var JsonRequest = new Json.Remote( strRequestUrl+'?dmcb='+objRequest.getName(), {

					//on request > cbRequestOnWait
					onRequest: function() {

						this.cbRequestOnWait( objRequest, true );

					}.bind( this ),

					//on state change > cbRequestOnStateChange
					onStateChange: function() {

						this.cbRequestOnStateChange( objRequest );

					}.bind( this ),

					//on complete > cbRequestOnComplete or cbRequestOnError
					onComplete: function( objData ) {

						if( true == DMC_System.isObject( objData )
								&& true == $defined( objData.response )
									)
						{
							var objResponse = new NM_ComponentResponseJson( objData.response );
						}
						else
						{
							var objResponse = new NM_ComponentResponseJson();
							objResponse.addError( 'no valid response json object' );
						}

						if( false == objResponse.isError()
								&& objRequest.getName() != objResponse.getName()
									)
						{
							objResponse.addError( 'wrong component name' );
						}

						if( false == objResponse.isError() )
						{
							if( false == DMC_System.isObject( objParam ) )
							{
								objParam = {};
							}

							this.cbRequestOnComplete( objResponse, objRequest, objParam );
						}
						else
						{
							this.cbRequestOnError( objResponse );
						}

					}.bind( this ),

					//on success > cbRequestOnWait > cbRequestOnSuccess
					onSuccess: function() {

						this.cbRequestOnWait( objRequest, false );
						this.cbRequestOnSuccess( objRequest );

					}.bind( this ),

					//on failure > cbRequestOnFailure
					onFailure: function() {

						this.cbRequestOnFailure( objRequest );

					}.bind( this )

				} ).send( objRequest.toJson() );

			}
			catch( e )
			{
				this.error( 'fireRequest: an error occured ('+e+')' );
			}
		}
		else
		{
			this.warning( 'fireRequest: no valid request object' );
		}
	},

	/**
	 * Create a NM_ComponentRequestJson object
	 *
	 * @return NM_ComponentRequestJson
	 */
	createRequestJson: function()
	{
		var objRequest = new NM_ComponentRequestJson();
		objRequest.setName( this.getName() );
		return objRequest;
	},

	/**
	 * On state change callback for json request
	 *
	 * @param 	NM_ComponentRequestJson objRequest
	 * @return 	void
	 */
	cbRequestOnStateChange: function( objRequest )
	{
		this.info( 'cbRequestOnStateChange: please implent in child class' );
	},

	/**
	 * On wait callback for json request
	 *
	 * @param 	NM_ComponentRequestJson objRequest
	 * @param 	boolean blnStart (true = request start, false = request successed)
	 * @return 	void
	 */
	cbRequestOnWait: function( objRequest, blnStart )
	{
		this.info( 'cbRequestOnWait: please implent in child class' );
	},

	/**
	 * On complete callback for json requests
	 *
	 * @param 	NM_ComponentResponseJson objResponse
	 * @param 	NM_ComponentRequestJson objRequest
	 * @param 	object objParam
	 * @return 	void
	 */
	cbRequestOnComplete: function( objResponse, objRequest, objParam )
	{
		this.info( 'cbRequestOnComplete: please implent in child class' );
	},

	/**
	 * On error callback for json requests
	 *
	 * @param 	NM_ComponentResponseJson objResponse
	 * @return 	void
	 */
	cbRequestOnError: function( objResponse )
	{
		this.warning( 'cbRequestOnError: please implent in child class '+objResponse.getErrorList( true ) );
	},

	/**
	 * On success callback for json request
	 *
	 * @param 	NM_ComponentRequestJson objRequest
	 * @return 	void
	 */
	cbRequestOnSuccess: function( objRequest )
	{
		this.info( 'cbRequestOnSuccess: please implent in child class' );
	},

	/**
	 * On failure callback for json request
	 *
	 * @param 	NM_ComponentRequestJson objRequest
	 * @return 	void
	 */
	cbRequestOnFailure: function( objRequest )
	{
		this.info( 'cbRequestOnFailure: please implent in child class' );
	},


	// -------------------------------------------------------------------------
	//
	// dispatcher request
	//
	// -------------------------------------------------------------------------

	/**
	 * register a request event
	 *
	 * @param  	string strEvent
	 * @param	object objComRequest
	 * @return 	void
	 **/
	registerRequestDispatch: function( strEvent, objRequest )
	{
		//this.dir( 'registerRequestDispatch:' + this.getName(), objRequest );
		if( true == DMC_System.isInstanceOf( objRequest, NM_ComponentRequestDispatch ) )
		{
			if( objRequest.getCbObjectName() == '' )
			{
				objRequest.setCbObjectName( 'obj'+this.getName() );
			}
		}
		else
		{
			var objRequest = this.createRequestDispatch();
			objRequest.setCbObjectName( 'obj'+this.getName() );
		}

		objRequest.setEvent( strEvent );

		NM_RequestDispatcher.register( objRequest );
	},

	/**
	 * Create a NM_ComponentRequestJson object
	 *
	 * @return NM_ComponentRequestJson
	 */
	createRequestDispatch: function()
	{
		var objRequest = new NM_ComponentRequestDispatch();
		objRequest.setName( this.getName() );
		return objRequest;
	},

	/**
	 * Create a new NM_RequestDispatchEvent object
	 *
	 * @access protected
	 * @param  string strEvent
	 * @param  string strDispatcher
	 * @param  object objParam
	 * @return NM_RequestDispatchEvent objCaller
	 */
	createRequestDispatchEvent: function( strEvent,	strDispatcher, objParam )
	{
		var objDispReq = new NM_RequestDispatchRequest();
		objDispReq.setEvent( strEvent );
		objDispReq.setCaller( this._createRequestDispatchCaller() );
		objDispReq.setDispatcher( this._createRequestDispatcher( strDispatcher, objParam ) );

		return new NM_RequestDispatchEvent( objDispReq );
	},

	/**
	 * Create a new NM_RequestDispatchCaller object
	 *
	 * @access protected
	 * @return NM_RequestDispatchCaller objCaller
	 */
	_createRequestDispatchCaller: function()
	{
		var objCaller = new NM_RequestDispatchCaller();
		objCaller.setName( this.getName() );
		objCaller.setObject( 'obj'+this.getName() );
		objCaller.setMethodOnSuccess( 'cbDispatchOnSuccess' );
		objCaller.setMethodOnWait( 'cbDispatchOnWait' );
		objCaller.setMethodOnException( 'cbDispatchOnException' );
		objCaller.setMethodOnError( 'cbDispatchOnError' );
		return objCaller;
	},

	/**
	 * Create a new NM_RequestDispatchDispatcher object
	 *
	 * @access protected
	 * @param  string strDispatcher
	 * @param  object objParam
	 * @return NM_RequestDispatchDispatcher objCaller
	 */
	_createRequestDispatcher: function( strDispatcher, objParam )
	{
		var objDispatcher = new NM_RequestDispatchDispatcher();
		objDispatcher.setDispatcher( strDispatcher );
		objDispatcher.setUrl( NM_REQUEST_PATH_DISPATCH );

		if( true == $defined( objParam ) )
		{
			objDispatcher.setParam( objParam );
		}

		return objDispatcher;
	},

	/**
	 * callback for on success: called from the content dispatcher
	 *
	 * @param 	object objResData (Json object)
	 * @return 	void
	 **/
	cbDispatchOnSuccess: function( strEvent )
	{
		this.warning( 'The cbDispatchOnSuccess method must be implemented in the child class!' );
	},

	/**
	 * callback for on wait: called from the content dispatcher
	 *
	 * @param	string strEvent
	 * @param boolean blnStart (true=waiting start;false=waiting end)
	 * @return 	void
	 */
	cbDispatchOnWait: function( strEvent, blnStart )
	{
		this.warning( 'The cbDispatchOnWait method must be implemented in the child class!' );
	},

	/**
	 * callback for on exception: called from the content dispatcher
	 *
	 * @param	string strEvent
	 * @param 	object objParam (Json object)
	 * @return 	void
	 */
	cbDispatchOnException: function( strEvent, objParam )
	{
		this.warning( 'The cbDispatchOnException method must be implemented in the child class!' );
	},

	/**
	 * callback for on error: called from the content dispatcher
	 *
	 * @param	string strEvent
	 * @param 	object objParam (Json object)
	 * @return 	void
	 **/
	cbDispatchOnError: function( strEvent, objParam )
	{
		this.warning( 'The cbDispatchOnError method must be implemented in the child class!' );
	},

	/**
	 * callback for on complete: called from the content dispatcher
	 *
	 * @param 	object objResData (Json object)
	 * @return 	void
	 **/
	cbDispatchOnComplete: function( objResponse )
	{
		this.warning( 'The cbDispatchOnComplete method must be implemented in the child class!' );
	},

	/**
	 * on complete callback for request dipatching
	 *
	 * @param 	NM_ComponentResponseDispatch objResponse
	 * @return 	void
	 */
	cbRequestDispatchOnComplete: function( objResponse )
	{
		this.warning( 'The cbRequestDispatchOnComplete method must be implemented in the child class!' );
	},

	/**
	 * on error callback for request dipatching
	 *
	 * @param 	NM_ComponentResponseDispatch objResponse
	 * @return 	void
	 */
	cbRequestDispatchOnError: function( objResponse )
	{
		this.warning( 'The cbRequestDispatchOnError method must be implemented in the child class!' );
	},


	// -------------------------------------------------------------------------
	// console methods
	// -------------------------------------------------------------------------

	/**
	 * log
	 */
	log: function( strMsg )
	{
		if( true == NM_Console.isActive() )
		{
			NM_Console.log( new NM_ConsoleMsg( '[dmc] '+this.strComName, strMsg ) );
		}
	},

	/**
	 * info
	 */
	info: function( strMsg )
	{
		if( true == NM_Console.isActive() )
		{
			NM_Console.info( new NM_ConsoleMsg( '[dmc] '+this.strComName, strMsg ) );
		}
	},

	/**
	 * warning
	 */
	warning: function( strMsg )
	{
		if( true == NM_Console.isActive() )
		{
			NM_Console.warning( new NM_ConsoleMsg( '[dmc] '+this.strComName, strMsg ) );
		}
	},

	/**
	 * error
	 */
	error: function( strMsg )
	{
		if( true == NM_Console.isActive() )
		{
			NM_Console.error( new NM_ConsoleMsg( '[dmc] '+this.strComName, strMsg ) );
		}
	},

	/**
	 * dir
	 */
	dir: function( strMsg, objContent )
	{
		if( true == NM_Console.isActive() )
		{
			if( $type( strMsg ) == 'object' )
			{
				objContent = strMsg;
			}

			NM_Console.dir( new NM_ConsoleMsg( '[dmc] '+this.strComName, strMsg ), objContent );
		}
	},

	/**
	 * dirxml
	 */
	dirxml: function(  strMsg, elmData )
	{
		if( true == NM_Console.isActive() )
		{
			if( $type( strMsg ) == 'element' )
			{
				elmData = strMsg;
			}

			NM_Console.dirxml( new NM_ConsoleMsg( '[dmc] '+this.strComName, strMsg ), elmData );
		}
	},

	// -------------------------------------------------------------------------
	// type check methods
	// -------------------------------------------------------------------------

	/**
	 * isElement
	 */
	isElement: function( elmCheck )
	{
		return DMC_System.isElement( elmCheck );
	},

	/**
	 * isObject
	 */
	isObject: function( objCheck )
	{
		return DMC_System.isObject( objCheck );
	},

	/**
	 * isArray
	 */
	isArray: function( arrCheck )
	{
		return DMC_System.isArray( arrCheck );
	},

	/**
	 * isString
	 */
	isString: function( strCheck )
	{
		return DMC_System.isString( strCheck );
	},

	/**
	 * isInt
	 */
	isInteger: function( intCheck )
	{
		return DMC_System.isInteger( intCheck );
	},

	/**
	 * return a test tag name
	 *
	 * @param	string 	strName
	 * @param	boolean	blnClass
	 * @return  string
	 */
	getTestTag: function( strName, blnClass )
	{
		var strTagName = '';
		var strTestTag = '';

		strTagName = strName.charAt(0).toUpperCase() + strName.substr(1);

		strName	= ( strName != '' ) ? '_' + strTagName : '';
		strTestTag = 'test_' + this.getName() + strName;
		strTestTag = ( true == blnClass ) ? 'class="' + strTestTag + '"' : strTestTag;

		return strTestTag;
	}

});



/* -----------------------------------------------------------------------------

	REQUEST

   -------------------------------------------------------------------------- */


/**
 * Abstract class for component requests
 *
 * @author	Steffen Heinzelmann <shi@dmc.de>
 * @version	$Id: NM_Component.js 84734 2011-09-13 08:46:14Z sheinzelmann $
 */
var NM_ComponentRequestAbstract = new Class( {

	/**
	 * Component name
	 *
	 * @var string strComName
	 */
	strComName:	'',

	/**
	 * Request action for example "save" or "get"
	 *
	 * @var string strComName
	 */
	strAction: '',

	/**
	 * Request parameter object > NM_COMA::handleRequestJson( ... )
	 *
	 * @var object objRequest (json)
	 */
	objRequest: {},

	/**
	 * Backend component initializing parameter > NM_COMA::register( ... )
	 *
	 * @var object objInit (json)
	 */
	objInit: {},

	/**
	 * Backend component displaying parameter > NM_COMA::display( ... )
	 *
	 * @var object objDisplay (json)
	 */
	objDisplay: {},


	/* ---------------------------------------------------------------------- */

	/**
	 * Constructor
	 *
	 * It is very important to intialize all object properties!!!
	 *
	 * @access public
	 * @return void
	 */
	initialize: function()
	{
		this.setName();
		this.setAction();
		this.setRequest();
		this.setInitParam();
		this.setDisplayParam();
	},


	/* ---------------------------------------------------------------------- */

	/**
	 * Set the component name
	 *
	 * @param string strName
	 * @return void
	 */
	setName: function( strName )
	{
		if( true == DMC_System.isString( strName ) )
		{
			this.strComName = strName;
		}
		else
		{
			this.strComName = '';
		}
	},

	/**
	 * Return the component name
	 *
	 * @return string
	 */
	getName: function()
	{
		return this.strComName;
	},

	/**
	 * Set the action
	 *
	 * @param string strAction
	 * @return void
	 */
	setAction: function( strAction )
	{
		if( true == DMC_System.isString( strAction ) )
		{
			this.strAction = strAction;
		}
		else
		{
			this.strAction = '';
		}
	},

	/**
	 * Return the action name
	 *
	 * @return string
	 */
	getAction: function()
	{
		return this.strAction;
	},

	/**
	 * Set a request parameter object
	 *
	 * @param object objRequest (json)
	 * @return void
	 */
	setRequest: function( objRequest )
	{
		if( true == DMC_System.isObject( objRequest ) )
		{
			this.objRequest = objRequest;
		}
		else
		{
			this.objRequest = {};
		}
	},

	/**
	 * Add a request parameter
	 *
	 * @param string strKey
	 * @param  mixed mixValue
	 * @return void
	 */
	addRequestParam: function( strKey, mixValue )
	{
		this.objRequest[ strKey ] = mixValue;
	},

	/**
	 * Return the request parameter object
	 *
	 * @return object (json)
	 */
	getRequest: function()
	{
		return this.objRequest;
	},

	/**
	 * Set a component initializing (register) object
	 *
	 * @param object objInit (json)
	 * @return void
	 */
	setInitParam: function( objInit )
	{
		if( true == DMC_System.isObject( objInit ) )
		{
			this.objInit = objInit;
		}
		else
		{
			this.objInit = {};
		}
	},

	/**
	 * Add component initializing object parameter
	 *
	 * @param string strKey
	 * @param mixed mixValue
	 * @return void
	 */
	addInitParam: function( strKey, mixValue )
	{
		this.objInit[ strKey ] = mixValue;
	},

	/**
	 * Return the component initializing parameter object
	 *
	 * @return object
	 */
	getInitParam: function()
	{
		return this.objInit ;
	},

	/**
	 * Set a component displaying parameter object
	 *
	 * @param object objDisplay
	 * @return void
	 */
	setDisplayParam: function( objDisplay )
	{
		if( true == DMC_System.isObject( objDisplay ) )
		{
			this.objDisplay = objDisplay;
		}
		else
		{
			this.objDisplay = {};
		}
	},

	/**
	 * Add component displaying object parameter
	 *
	 * @param string strKey
	 * @param mixed mixValue
	 * @return void
	 */
	addDisplayParam: function( strKey, mixValue )
	{
		this.objDisplay[ strKey ] = mixValue;
	},

	/**
	 * Return the component displaying parameter object
	 *
	 * @return object
	 */
	getDisplayParam: function()
	{
		return this.objDisplay;
	},

	/**
	 * Convert the object properties in a json object
	 *
	 * @access public
	 * @return object
	 */
	toJson: function()
	{
		return {
			name: 		this.getName(),
			action:		this.getAction(),
			request:	this.getRequest(),
			init:		this.getInitParam(),
			display:	this.getDisplayParam()
		};
	},

	/**
	 * Initialize the object by a given Json data object
	 *
	 * @param 	object objData (Json object)
	 * @return 	void
	 */
	init: function( objData )
	{
		if( true == DMC_System.isObject( objData ) )
		{
			if( true == $defined( objData.name ) )
			{
				this.setName( objData.name );
			}

			if( true == $defined( objData.action ) )
			{
				this.setAction( objData.action );
			}

			if( true == $defined( objData.request ) )
			{
				this.setRequest( objData.request );
			}

			if( true == $defined( objData.init ) )
			{
				this.setInitParam( objData.init );
			}

			if( true == $defined( objData.display ) )
			{
				this.setDisplayParam( objData.display );
			}
		}

		//NM_Console.dir( new NM_ConsoleMsg( 'NM_ComponentRequestAbstract', 'init ' ), this );
	}

} );


/**
 * Class for json component requests
 *
 * @author	Steffen Heinzelmann <shi@dmc.de>
 * @version	$Id: NM_Component.js 84734 2011-09-13 08:46:14Z sheinzelmann $
 */
var NM_ComponentRequestJson = NM_ComponentRequestAbstract.extend( {

	/**
 	 * Flag for Java request
 	 *
 	 * @var boolean blnJavaRequest detection
 	 */
	blnJavaRequest: false,

	/**
	 * Constructor
	 *
	 * It is very important to intialize all object properties!!!
	 *
	 * @access public
	 * @return void
	 */
	initialize: function()
	{
		this.parent();
		this.setJavaRequest( false );
	},

	/**
	 * Set the request on a java backend url
	 * true = java url
	 *
	 * @access public
	 * @return void
	 */
	setJavaRequest: function( blnStatus )
	{
		this.blnJavaRequest = blnStatus;
	},

	/**
	 * Return true if the request is a java request
	 *
	 * @access public
	 * @return boolean
	 */
	isJavaRequest: function()
	{
		return this.blnJavaRequest;
	}

} );


/**
 * Class for dispatcher component requests
 *
 * @author	Steffen Heinzelmann <shi@dmc.de>
 * @version	$Id: NM_Component.js 84734 2011-09-13 08:46:14Z sheinzelmann $
 */
var NM_ComponentRequestDispatch = NM_ComponentRequestAbstract.extend( {

	/**
 	 * Registered dispatching event name
 	 *
 	 * @var string strEvent
 	 */
	strEvent: '',

	/**
 	 * Flag for dispatching component in the backend (true=yes)
 	 *
 	 * @var boolean blnComCall
 	 */
	blnComCall:	true, //flag for component call in backend

	/**
 	 * Backend execution order number for the comopnent request
 	 *
 	 * @var integer intExecOrder
 	 */
	intExecOrder: 0,

	/**
 	 * Callback javascript component object name
 	 *
 	 * @var string strCbObjectName
 	 */
	strCbObjectName:	'',


	/* ---------------------------------------------------------------------- */

	/**
	 * Constructor
	 *
	 * It is very important to intialize all object properties!!!
	 *
	 * @access public
	 * @return void
	 */
	initialize: function()
	{
		this.parent();
		this.setEvent( '' );
		this.setExecOrder( 99 );
		this.setComCall( true );
		this.setCbObjectName( '' );
	},


	/* ---------------------------------------------------------------------- */

	/**
	 * Set the dispatching event
	 *
	 * @access public
	 * @param  string strEvent
	 * @return void
	 */
	setEvent: function( strEvent )
	{
		if( true == DMC_System.isString( strEvent ) )
		{
			this.strEvent = strEvent;
		}
		else
		{
			this.strEvent = '';
		}
	},

	/**
	 * Return the registered dispatching event
	 *
	 * @access public
	 * @return string
	 */
	getEvent: function()
	{
		return this.strEvent;
	},

	/**
	 * Set the component object name
	 *
	 * @access public
	 * @param  string strObjName
	 * @return void
	 */
	setCbObjectName: function( strObjName )
	{
		if( true == DMC_System.isString( strObjName ) )
		{
			this.strCbObjectName = strObjName;
		}
		else
		{
			this.strCbObjectName = '';
		}
	},

	/**
	 * Return the component object name
	 *
	 * @access public
	 * @return string
	 */
	getCbObjectName: function()
	{
		return this.strCbObjectName;
	},

	/**
	 * Set the flag for backend component call
	 *
	 * @access public
	 * @param  boolean blnCall
	 * @return void
	 */
	setComCall: function( blnCall )
	{
		if( true == DMC_System.isBoolean( blnCall ) )
		{
			this.blnComCall = blnCall;
		}
		else
		{
			this.blnComCall = true;
		}
	},

	/**
	 * Return the flag for backend component call
	 *
	 * @access public
	 * @return boolean
	 */
	getComCall: function()
	{
		return this.blnComCall;
	},

	/**
	 * Set the execution order for backend component calls
	 *
	 * @access public
	 * @param  integer intOrder
	 * @return void
	 */
	setExecOrder: function( intOrder )
	{
		if( true == DMC_System.isInteger( intOrder ) )
		{
			this.intExecOrder = intOrder;
		}
		else
		{
			this.intExecOrder = 99;
		}
	},

	/**
	 * Return the execution order for backend component calls
	 *
	 * @access public
	 * @return integer
	 */
	getExecOrder: function()
	{
		return this.intExecOrder;
	},

	/**
	 * Convert the object properties in a json object
	 *
	 * @access public
	 * @return object
	 */
	toJson: function()
	{
		var objJson 			= this.parent();
		objJson.event 			= this.getEvent();
		objJson.cbObjectName	= this.getCbObjectName();
		objJson.comCall			= this.getComCall();
		objJson.execOrder		= this.getExecOrder();

		//NM_Console.dir( new NM_ConsoleMsg( 'NM_ComponentRequestDispatch', 'toJson ' ), objJson );

		return objJson;
	},

	/**
	 * Initialize the object by a given Json data object
	 *
	 * @param 	object objData (Json object)
	 * @return 	void
	 */
	init: function( objData )
	{
		if( true == DMC_System.isObject( objData ) )
		{
			this.parent( objData );

			if( true == $defined( objData.event ) )
			{
				this.setEvent( objData.event );
			}

			if( true == $defined( objData.cbObjectName ) )
			{
				this.setCbObjectName( objData.cbObjectName );
			}

			if( true == $defined( objData.comCall ) )
			{
				this.setComCall( objData.comCall );
			}

			if( true == $defined( objData.execOrder ) )
			{
				this.setExecOrder( objData.execOrder );
			}
		}
	}

} );



/* -----------------------------------------------------------------------------

	RESPONSE

	-------------------------------------------------------------------------- */

/**
 * Class for dispatcher component requests
 *
 * @author	Steffen Heinzelmann <shi@dmc.de>
 * @version	$Id: NM_Component.js 84734 2011-09-13 08:46:14Z sheinzelmann $
 */
var NM_ComponentResponseAbstract = new Class( {

	/**
	 * Component name
	 *
	 * @var string strComName
	 */
	strComName: '',

	/**
	 * Set the action
	 *
	 * @param string strAction
	 * @return void
	 */
	strAction: '',

	/**
	 * Error list
	 *
	 * @var array arrError
	 */
	arrError: [],

	/**
	 * Setting object
	 *
	 * @var object objSetting
	 */
	objSetting: {},

	/**
	 * Content object
	 *
	 * @var object objContent
	 */
	objContent:	{},


	/* ---------------------------------------------------------------------- */

	/**
	 * Constructor
	 *
	 * It is very important to intialize all object properties!!!
	 *
	 * @access public
	 * @return void
	 */
	initialize: function( objResponse )
	{
		//NM_Console.dir( new NM_ConsoleMsg( 'NM_ComponentResponseJson', 'initialize response object ' ), objResponse );

		this.setName();
		this.setAction();
		this.setSetting();
		this.setContent();
		this.setError();

		if( true == DMC_System.isObject( objResponse ) )
		{
			if( true == $defined( objResponse.name ) )
			{
				this.setName( objResponse.name );
			}

			if( true == $defined( objResponse.action ) )
			{
				this.setAction( objResponse.action );
			}

			if( true == $defined( objResponse.setting ) )
			{
				this.setSetting( objResponse.setting );
			}

			if( true == $defined( objResponse.content ) )
			{
				this.setContent( objResponse.content );
			}

			if( true == $defined( objResponse.error ) )
			{
				this.setError( objResponse.error );
			}
		}
	},


	/* ---------------------------------------------------------------------- */

	/**
	 * Set the component name
	 *
	 * @param string strName
	 * @return void
	 */
	setName: function( strComName )
	{
		if( true == DMC_System.isString( strComName ) )
		{
			this.strComName = strComName;
		}
		else
		{
			this.strComName = '';
		}
	},

	/**
	 * Return the component name
	 *
	 * @return string
	 */
	getName: function()
	{
		return this.strComName;
	},

	/**
	 * Set the action
	 *
	 * @param string strAction
	 * @return void
	 */
	setAction: function( strAction )
	{
		if( true == DMC_System.isString( strAction ) )
		{
			this.strAction = strAction;
		}
		else
		{
			this.strAction = '';
		}
	},

	/**
	 * Return the action name
	 *
	 * @return string
	 */
	getAction: function()
	{
		return this.strAction;
	},

	/**
	 * Set an error array
	 *
	 * @param  array arrError
	 * @return void
	 */
	setError: function( arrError )
	{
		if( true == DMC_System.isArray( arrError ) )
		{
			this.arrError = arrError;
		}
		else
		{
			this.arrError = [];
		}
	},

	/**
	 * Add an error message
	 *
	 * @param  string strMsg
	 * @return void
	 */
	addError: function( strMsg )
	{
		if( true == DMC_System.isString( strMsg )
				&& strMsg != ''
					)
		{
			this.arrError.push( strMsg );
		}
	},

	/**
	 * Return true if there is an error item in the error list
	 *
	 * @return boolean
	 */
	isError: function()
	{
		return ( this.arrError.length > 0 );
	},

	/**
	 * Return the error list as array or string
	 *
	 * @param  boolean blnJoin (optional)
	 * @return array|string
	 */
	getErrorList: function( blnJoin )
	{
		if( true == blnJoin )
		{
			return "\n- "+this.arrError.join( "\n- " );
		}
		else
		{
			return this.arrError;
		}
	},

	/**
	 * Set a content object
	 *
	 * @param  object objContent (json)
	 * @return void
	 */
	setContent: function( objContent )
	{
		if( true == DMC_System.isObject( objContent ) )
		{
			this.objContent = objContent;
		}
		else
		{
			this.objContent = {};
		}
	},

	/**
	 * Return a content paramter by a given key
	 *
	 * @param  string strKey
	 * @return mixed
	 */
	getContentParam: function( strKey )
	{
		if( true == $defined( this.objContent[ strKey ] ) )
		{
			return this.objContent[ strKey ];
		}
		else
		{
			return null;
		}
	},

	/**
	 * Return the content object or return a content paramter by a given key
	 *
	 * @param  string strKey (optional)
	 * @return mixed
	 */
	getContent: function( strKey )
	{
		if( true == $defined( strKey ) )
		{
			return this.getContentParam( strKey );
		}
		else
		{
			return this.objContent;
		}
	},

	/**
	 * Set a setting object
	 *
	 * @param  object objSetting (json)
	 * @return void
	 */
	setSetting: function( objSetting )
	{
		if( true == DMC_System.isObject( objSetting ) )
		{
			this.objSetting = objSetting;
		}
		else
		{
			this.objSetting = {};
		}
	},

	/**
	 * Return a setting paramter by a given key
	 *
	 * @param  string strKey
	 * @return mixed
	 */
	getSettingParam: function( strKey )
	{
		if( true == $defined( this.objSetting[ strKey ] ) )
		{
			return this.objSetting[ strKey ];
		}
		else
		{
			return null;
		}
	},

	/**
	 * Return the setting object or return a setting paramter by a given key
	 *
	 * @param  string strKey (optional)
	 * @return mixed
	 */
	getSetting: function( strKey )
	{
		if( true == $defined( strKey ) )
		{
			return this.getSettingParam( strKey );
		}
		else
		{
			return this.objSetting;
		}
	}

} );


/**
 * class for component response
 *
 * @author	Steffen Heinzelmann <shi@dmc.de>
 * @version	$Id: NM_Component.js 84734 2011-09-13 08:46:14Z sheinzelmann $
 */
var NM_ComponentResponseJson = NM_ComponentResponseAbstract.extend( {

	/**
	 * Constructor
	 *
	 * It is very important to intialize all object properties!!!
	 *
	 * @access 	public
	 * @param	object objResponse (json)
	 * @return 	void
	 */
	initialize: function( objResponse )
	{
		this.parent( objResponse );
	}

} );

/**
 * class for component response
 *
 * @author	Steffen Heinzelmann <shi@dmc.de>
 * @version	$Id: NM_Component.js 84734 2011-09-13 08:46:14Z sheinzelmann $
 */
var NM_ComponentResponseDispatch = NM_ComponentResponseAbstract.extend( {

	/**
	 * Dipsatching event
	 *
	 * @var string strEvent
	 */
	strEvent: '',


	/* ---------------------------------------------------------------------- */

	/**
	 * Constructor
	 *
	 * It is very important to intialize all object properties!!!
	 *
	 * @param	object objResponse (json)
	 * @return 	void
	 */
	initialize: function( objResponse )
	{
		this.setEvent();

		if( true == DMC_System.isObject( objResponse ) )
		{
			this.parent( objResponse );
			if( true == $defined( objResponse.event ) )
			{
				this.setEvent( objResponse.event );
			}
		}
	},


	/* ---------------------------------------------------------------------- */

	/**
	 * Set the dispatching event
	 *
	 * @param	string strEvent
	 * @return 	void
	 */
	setEvent: function( strEvent )
	{
		if( true == DMC_System.isString( strEvent ) )
		{
			this.strEvent = strEvent;
		}
		else
		{
			this.strEvent = '';
		}
	},

	/**
	 * Return the dispatching event
	 *
	 * @return 	string
	 */
	getEvent: function()
	{
		return this.strEvent;
	}

} );
