123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| BI and PM: prmt
- *| (C) Copyright IBM Corp. 2002, 2011
- *|
- *| US Government Users Restricted Rights - Use, duplication or
- *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *|
- *+------------------------------------------------------------------------+
- */
- /**
- @fileOverview Managing Prompts.
- @namespace cognos.Prompt
- */
- /**
- @constructor
- @class Prompting Parameter
- */
- cognos.Prompt.Parameter = function(sName)
- {
- this.m_aControls = [];
- this.m_aValues = [];
- this.m_sName = sName;
- };
- /**
- @param {cognos.Value[]} aValues Values to add to this parameter.
- @return {void}
- */
- cognos.Prompt.Parameter.prototype.addValues = function(aValues) { this.m_aValues = this.m_aValues.concat(aValues); };
- /**
- Clear all values for this parameter. Does not update the controls associated to this parameter.
- @return {void}
- */
- cognos.Prompt.Parameter.prototype.clearValues = function() { this.m_aValues = []; };
- /**
- @private
- @param {cognos.Prompt.Control} oControl
- @return {void}
- */
- cognos.Prompt.Parameter.prototype.f_addControl = function(oControl)
- {
- this.m_aControls.push( oControl );
- };
- /**
- Returns an array of all controls associated to this parameter.
- @return {cognos.Prompt.Control[]}
- */
- cognos.Prompt.Parameter.prototype.getControls = function() { return this.m_aControls; };
- /**
- Returns the parameter's name.
- @return {String}
- */
- cognos.Prompt.Parameter.prototype.getName = function() { return this.m_sName; };
- /**
- Returns all values for this parameter.
- @return {cognos.Value[]}
- */
- cognos.Prompt.Parameter.prototype.getValues = function()
- {
- var v_aValues = this.m_aValues;
- var v_aControls = this.getControls();
- for (var v_idx = 0; v_idx < v_aControls.length; v_idx++)
- {
- var v_oControl = v_aControls[v_idx];
- if ( v_oControl.isValid() )
- {
- v_aValues = v_aValues.concat(v_oControl.getValues());
- }
- }
- return v_aValues;
- };
- /**
- Returns all values for this parameter in XML form.
- @private
- @return {String}
- */
- cognos.Prompt.Parameter.prototype.getXML = function()
- {
- var v_aXML = ["<selectChoices>"];
- var v_aValues = this.getValues();
- for (var v_idx = 0; v_idx < v_aValues.length; v_idx++)
- {
- v_aXML.push( cognos.Value.toXML(v_aValues[v_idx]) );
- }
- v_aXML.push( "</selectChoices>" );
- return v_aXML.join(K_PRMT_sEMPTY);
- };
- /**
- Check if this parameter is satisfied.
- @private
- @return {boolean}
- */
- cognos.Prompt.Parameter.prototype.isValid = function()
- {
- return ( this.isRequired() && (this.getValues().length == 0) ? false : true );
- };
- /**
- Currently the <i>required</i> is handled by the controls.
- @private
- @return {boolean}
- */
- cognos.Prompt.Parameter.prototype.isRequired = function()
- {
- var v_bRequired = false;
- for (var v_idx = 0; v_idx < this.m_aControls.length; v_idx++)
- {
- v_bRequired = (v_bRequired || this.m_aControls[v_idx].isRequired());
- }
- return v_bRequired;
- };
|