|
TROIKA.ASP - the MVC framework | ||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object | +--Command
This is Command class the base class for all user defined commands.
Defined in Command.js
| Constructor Summary | |
Command(<Config> config)
Constructs a new instance of Command class. |
|
| Method Summary | |
ResponseContext
|
execute(<Environment> environment, <RequestContext> requestCxt)
Performs business logic and returns responseContext |
Forward
|
findForward(<RequestContext> requestCxt, <String> forwardName)
Searches Command mappings from config.xml for Forward object and returns it if found. |
String
|
getConnectionString(<String> dbName)
Looks up database connection string from Config class and return it. |
Command
|
init(<Config> config)
Initializes Command. |
void
|
logError(<Object> error)
Logs error message to application log file. |
void
|
logInfo(<String> msg)
Logs info message to application log file. |
void
|
logWarn(<String> msg)
Logs warning message to application log file. |
| Constructor Detail |
Command(<Config> config)
config - The instance of Config class.
| Method Detail |
ResponseContext execute(<Environment> environment, <RequestContext> requestCxt)
environment - The instance of Environment class.
requestCxt - The instance of RequestContext class.
Forward findForward(<RequestContext> requestCxt, <String> forwardName)
For example we can this Command definition in config.xml:
<cmd-map action="secretAction">
<name>secretForm</name>
<type>SecretAction</type>
<forwards>
<forward name="success" redirect="false"
path="/views/secret.xsl"/>
</forwards>
</cmd-map>
In execute() method of the Command object we would call:
var forward = this.findForward(secretForm, "success"); //change the forward fields forward.redirect = true; forward.path = "/views/secret2.xsl";
requestCxt - The RequestContext instance.
forwardName - The name of the Forward declaration.
String getConnectionString(<String> dbName)
In our config.xml:
<db-connection name="helloworld-db"
conn-string="Driver={Microsoft Access Driver (*.mdb)};Dbq=${root}/WEB-INF/data/helloworld.mdb;"/>
var connStr = this.getConnectionString("helloworld-db");
dbName - The name of the database to lookup.
Command init(<Config> config)
config - The XSL template file to transform.
void logError(<Object> error)
Log file configuration is specified in config.xml:
<logger>
<file-name>${root}/WEB-INF/logs/application.log</file-name>
<max-size>1024</max-size>
<generations>2</generations>
<log-level>FILTER_INFO</log-level>
</logger>
The code like this:
this.logError("Error1");
this.logError(secretForm);
Will produce the output in application.log as follows:
[2007/03/23 10:15:27] {E} TRAN ID - 1174644927701-1 {E} Error1
[2007/03/23 10:15:27] {E} TRAN ID - 1174644927701-2 {E} action=secretAction |
error - The error object.
void logInfo(<String> msg)
Log file configuration is specified in config.xml:
<logger>
<file-name>${root}/WEB-INF/logs/application.log</file-name>
<max-size>1024</max-size>
<generations>2</generations>
<log-level>FILTER_INFO</log-level>
</logger>
The code like this:
//create an object dynamically
var obj2 = {};
obj2.prop1 = 100;
obj2.prop2 = "value2";
this.logInfo(obj2);
this.logInfo(obj2.toXML());
Will produce the output in application.log as follows:
[2007/03/23 10:15:27] {I} TRAN ID - 1174644927701-4 {I} {"prop1":100,"prop2":"value2"}
[2007/03/23 10:15:27] {I} TRAN ID - 1174644927701-5 {I}
msg - The info message.
void logWarn(<String> msg)
Log file configuration is specified in config.xml:
<logger>
<file-name>${root}/WEB-INF/logs/application.log</file-name>
<max-size>1024</max-size>
<generations>2</generations>
<log-level>FILTER_INFO</log-level>
</logger>
The code like this:
this.logWarn("Warning1");
[2007/03/23 10:15:27] {W} TRAN ID - 1174644927701-3 {W} Warning1
msg - The warning message.
|
TROIKA.ASP - the MVC framework | ||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |