TROIKA.ASP - the MVC framework

SecretAction.js

Summary

Contains SecretAction class.

This is part of Troika.ASP Framework - web development MVC framework for ASP 3.0. Please visit www.troika-asp.com for more details.



Version: $Revision: 1.3 $

Author: Pavel Chuchev pav@troika-asp.com


Class Summary
SecretAction This is SecretAction class command implementation.

/**
* @fileoverview Contains <tt>SecretAction</tt> class.
*
* <p>
* This is part of Troika.ASP Framework - web development MVC framework for ASP 3.0.
* Please visit {@link http://www.troika-asp.com www.troika-asp.com} for more details.
* </p>
*
* @author Pavel Chuchev pav@troika-asp.com
* @version $Revision: 1.3 $
*/
SecretAction.prototype =  new Command();
SecretAction.prototype.constructor = SecretAction;
/**
* Initializes <tt>SecretAction</tt>.
*
* @return <tt>SecretAction</tt> object instance itself.
* @param {Config} config The instance of <tt>Config</tt> class
* @type SecretAction
*/
SecretAction.prototype.init = function (config) {

    Command.prototype.init.call(this, config);
    return this;
};

/**
* Constructs a new SecretAction class.
*
* @class This is <tt>SecretAction</tt> class command implementation.
*
* @constructor
* @base Command
* @param {Config} config The instance of Config class.
*/
function SecretAction(config) {

    if (arguments.length) {

        this.init(config);
    }
}

/**
* Saves secret info into the database.
*
* @param {Environment} environment The instance of <tt>Environment</tt> class.
* @param {SecretForm} secretForm The instance of <tt>SecretForm</tt> class- RequestContext.
* @return The instance of <tt>ResponseContext</tt> class
* @type ResponseContext
*/
SecretAction.prototype.execute = function (environment, secretForm) {

    function saveData(connStr, loginVO, secretForm) {

        var dao =  new LoginDAO(connStr);

        //copy all corresponding fields in bulk from form to VO object
        //in this case only one field will be copied - secretInfo
        loginVO.assign(secretForm);

        dao.update(loginVO);
    }

    function getLoginVO(connStr, loginId) {

        var dao =  new LoginDAO(connStr);
        return dao.findByLoginId(loginId);
    }

    function getMemberVO(connStr, memberId) {

        var dao =  new MemberDAO(connStr);
        return dao.findByMemberId(memberId);
    }

    var result =  new ResponseContext(this.findForward(secretForm, "success"));
    var connStr = this.getConnectionString("helloworld-db");
    var loginVO = getLoginVO(connStr, environment.session.get("loginId"));

    if (environment.request.get("submit")) {

        saveData(connStr, loginVO, secretForm);
    }

    result.models.put("loginVO", loginVO);
    result.models.put("memberVO", getMemberVO(connStr, environment.session.get("memberId")));

    return result;
};

TROIKA.ASP - the MVC framework

www.troika-asp.com
Documentation generated on Sun Jun 15 17:59:32 2008