📄 objmod80.ssc
字号:
function CreateComponent(page) {
page.Trace(this.variableName + ".CreateComponent: Creating component '" + this.componentName + "' on server '" + this.serverName + "'");
// make sure server name is an URL
var serverName = this.serverName;
if (serverName.indexOf ("iiop:") == -1)
serverName = "iiop://" + serverName;
var userId = this.evaluateValue(this.userId);
var password = this.evaluateValue(this.password);
var newComponent = java.CreateComponent(this.componentName, serverName, userId, password, this.interfaceName);
if (newComponent == null)
{
var jagError = site.GetErrorInfo ();
page.Trace(this.variableName + ".CreateComponent: Error creating component '" + jagError + "'");
page.ReportError(this.variableName + ".CreateComponent", "Could not create component", jagError);
}
return newComponent;
}
// internal functions
this.evaluateValue = evaluateValue;
// set up functions
this.Initialize = Initialize;
this.Save = Save;
this.CreateComponent = CreateComponent;
// public variables
this.variableName = variableName;
this.serverName = serverName;
this.userId = userId;
this.password = password;
this.componentName = componentName;
// default to component name
if (arguments.length < 8 || interfaceName == "")
this.interfaceName = componentName;
else
this.interfaceName = interfaceName;
// make sure we have the interface name in the form that java object expects.
this.interfaceName = replaceDoubleColon(this.interfaceName);
this.lifetime = lifetime;
// default to variable name
if (sessionVarName == "")
this.sessionVarName = variableName;
else
this.sessionVarName = sessionVarName;
}
class PSPageParameterClass(variableName, initialValue)
{
function Initialize (page) {
var result;
var clientValue = psDocument.GetParamEx (this.variableName);
// if client passed value, use it
if (clientValue != null) {
result = clientValue;
this.valuePassed = true;
page.Trace(this.variableName + ".Initialize(Parm): got value from client (" + result + ")" );
// otherwise, if we have an initial value, use it
} else if(exists(this.initialValue)) {
result = this.initialValue;
page.Trace(this.variableName + ".Initialize(Parm): using initial value (" + result + ")" );
} else {
page.Trace(this.variableName + ".Initialize(Parm): leaving undefined" );
}
// if no initial value was specified, then we will return an undefined variable
return result;
}
// this assumes it is being called between <FORM> </FORM> tags for submit form
function GenerateClientFormFragment(page) {
psDocument.WriteLn(" <INPUT TYPE=\"hidden\" NAME=\"" + this.variableName + "\" VALUE=\"" + eval(this.variableName) + "\" >");
}
// set up function
this.Initialize = Initialize;
this.GenerateClientFormFragment = GenerateClientFormFragment;
// public variables
this.variableName = variableName;
this.valuePassed = false;
// if no initial value passed, don't create instance var
if (arguments.length >= 2)
this.initialValue = initialValue;
}
var CLIENT_NONE = 1;
var CLIENT_RO = 2;
var CLIENT_RW = 3;
class PSPageVariableClass (variableName, lifetime, clientAccess, initialValue, sessionVarName)
{
function Initialize (page) {
var result;
var bNoClientValue = true;
// client value always overrides other values
if (this.clientAccess == CLIENT_RW) {
result = psDocument.GetParamEx (this.variableName);
if (result != null) {
bNoClientValue = false;
page.Trace(this.variableName + ".Initialize(Var): got value from client (" + result + ")" );
} else {
page.Trace(this.variableName + ".Initialize(Var): did not get value from client" );
}
}
// if we didn't have a client value, then try other methods to initialize
if (bNoClientValue) {
// see if we should get value out of session
if (this.lifetime == LIFETIME_SESSION) {
// get value out of session
var sessValue = psSession.GetValue(this.sessionVarName);
if (sessValue != null) {
result = sessValue;
page.Trace(this.variableName + ".Initialize(Var): got value from session (" + result + ")" );
} else {
result = this.initialValue;
page.Trace(this.variableName + ".Initialize(Var): value not in session, using initial value (" + result + ")" );
}
} else { // page lifetime
// set to initial value
result = this.initialValue;
page.Trace(this.variableName + ".Initialize(Var): using initial value (" + result + ")" );
}
}
return result;
}
function Save (page, value) {
// only save session variables
if (this.lifetime == LIFETIME_SESSION)
psSession.SetValue(this.sessionVarName, value);
}
// this assumes it is being called between <SCRIPT> </SCRIPT> tags
function GenerateClientVariableDefinitionFragment(page) {
// if RO or RW, then generate client script variable
if (this.clientAccess != CLIENT_NONE) {
var serverValue = eval(this.variableName);
var line = " psPage." + this.variableName;
if (typeof serverValue != "undefined")
line += " = \"" + serverValue + "\"";
line += ";"
psDocument.WriteLn(line);
}
}
// this assumes it is being called between <FORM> </FORM> tags for submit form
function GenerateClientFormFragment(page) {
// if RW, then generate hidden form variable
if (this.clientAccess == CLIENT_RW) {
var line = " <INPUT TYPE=\"hidden\" NAME=\"" + this.variableName + "\" >";
psDocument.WriteLn(line);
}
}
// this assumes it is being called for the body of the OnSubmit() event
function GenerateClientOnSubmitFragment(page) {
// if RW, then move client value into form variable
if (this.clientAccess == CLIENT_RW) {
var line = " submitForm." + this.variableName + ".value = psPage." + this.variableName + ";";
psDocument.WriteLn(line);
}
}
// set up function
this.Initialize = Initialize;
this.Save = Save;
this.GenerateClientVariableDefinitionFragment = GenerateClientVariableDefinitionFragment;
this.GenerateClientFormFragment = GenerateClientFormFragment;
this.GenerateClientOnSubmitFragment = GenerateClientOnSubmitFragment;
// public variables
this.variableName = variableName;
this.lifetime = lifetime;
if (arguments.length < 3)
this.clientAccess = CLIENT_NONE;
else
this.clientAccess = clientAccess;
if (arguments.length >= 4)
this.initialValue = initialValue;
// default name
if (arguments.length < 5 || sessionVarName == "")
this.sessionVarName = variableName
else
this.sessionVarName = sessionVarName;
}
class PSFormControlClass(name, initialValue)
extends PSServerObjectWithEventsClass
{
// Default functions do nothing
function PerformAction (page) {
}
function BindToInput (page) {
}
function BindToComponent (page) {
if (this.bIsBound) {
var __temp = null; // this is used to allow session variables to not be defined yet
eval(this.getEvalString);
// deal with optional use of temp variable
if (__temp != null)
this.value = __temp;
psPage.Trace(this.name + ".BindToComponent('" + this.bindComponentName + "','" + this.bindAttribute + "'): new value '" + this.value + "'");
}
}
// this assumes it is being called between <SCRIPT> </SCRIPT> tags after form is complete!
function GenerateClientVariableDefinitionFragment(page) {
}
// this assumes it is being called between <FORM> </FORM> tags for submit form
function GenerateClientFormFragment(page) {
}
// this assumes it is being called for the body of the OnSubmit() event
function GenerateClientOnSubmitFragment(page) {
}
// by default, we just return ourselves
function Initialize (page) {
return this;
}
// this function returns the value wrapped in quotes for use in a VALUE attribute
function GetValueAttribute() {
// if we had an invalid value, send it back
if (this.invalidValue != null)
return '"' + this.invalidValue + '"';
else
return '"' + this.value + '"';
}
// this function returns DISABLED or "" depending on the enabled property
function GetDisabledAttribute() {
if (this.enabled)
return "";
else
return "DISABLED ";
}
// this is used to bind the value property to a jaguar component property
function SetBinding(componentName, bindAttribute) {
this.bIsBound = true;
this.bindComponentName = componentName;
this.bindAttribute = bindAttribute;
if (componentName == "<Page Variable>" || componentName == "<Page Parameter>") {
this.getEvalString = "this.value = " + bindAttribute + ";";
this.setEvalString = bindAttribute + " = this.value;";
} else if (componentName == "<Session Variable>") {
this.getEvalString = "__temp = psSession.GetValue(\"" + bindAttribute + "\")";
this.setEvalString = "psSession.SetValue(\"" + bindAttribute + "\", this.value);";
} else { // jaguar component
this.getEvalString = "this.value = " + componentName + ".get" + bindAttribute + "();";
this.setEvalString = componentName + ".set" + bindAttribute + "(this.value);";
}
}
// Default methods
this.PerformAction = PerformAction;
this.BindToInput = BindToInput;
this.GenerateClientVariableDefinitionFragment = GenerateClientVariableDefinitionFragment;
this.GenerateClientFormFragment = GenerateClientFormFragment;
this.GenerateClientOnSubmitFragment = GenerateClientOnSubmitFragment;
this.Initialize = Initialize;
// implemented methods
this.BindToComponent = BindToComponent;
this.GetValueAttribute = GetValueAttribute;
this.GetDisabledAttribute = GetDisabledAttribute;
this.SetBinding = SetBinding;
// default action functions
// public variables
this.name = name;
this.initialValue = initialValue;
this.invalidValue = null;
this.value = initialValue;
this.enabled = true;
this.visible = true;
// binding releated properties
this.bIsBound = false;
this.bindComponentName = null;
this.bindAttribute = null;
this.getEvalString = null;
this.setEvalString = null;
}
class PSLinkClass(name,destination)
extends PSFormControlClass(name, destination)
{
// this assumes it is being called between <SCRIPT> </SCRIPT> tags after form is complete!
function GenerateClientVariableDefinitionFragment(page) {
if (this.visible) {
// Generate client script variable access to form control
var line = " psPage." + this.name + " = psPage.dataForm." + this.name + ";";
psDocument.WriteLn(line);
}
}
// no data is sent back on a submit!
function GetHREFAttribute() {
var index, arg;
var seperatorChar = "?";
var destination = this.value;
// if there are already any args specified on destination
if (destination.indexOf("?") != -1)
// use proper seperator
seperatorChar = "&";
for (index = 0; index < this.args.length; index++) {
destination += seperatorChar + psParam(this.argNames[index], this.args[index].GetValue());
// switch seperator
seperatorChar = "&";
}
return '"' + destination + '"';
}
function addArg(name, source, value) {
var nextArgPos = this.argNames.length;
this.argNames[nextArgPos] = name;
this.args[nextArgPos] = new psDynamicValue(source, value);
psPage.Trace(this.name + ".addArg('" + name + "') at position: " + nextArgPos);
}
// overrides
this.GenerateClientVariableDefinitionFragment = GenerateClientVariableDefinitionFragment;
// my functions
this.GetHREFAttribute = GetHREFAttribute;
this.addArg = addArg;
this.args = new Array();
this.argNames = new Array();
}
class PSDataFieldClass(name, initialValue)
extends PSFormControlClass(name, initialValue)
{
function BindToInput (page) {
// check if value was passed
var newValue = psDocument.GetParamEx(this.name);
this.invalidValue = null;
if (newValue != null) {
// check if value was changed
if (newValue != this.value) {
// run Validate() event
var bValid = true;
if (this.checkForEvent("Validate", newValue)) {
psPage.TraceIndent();
bValid = evtdef(this.Validate(newValue));
psPage.TraceOutdent();
psPage.Trace("...returned " + bValid);
}
if (bValid) {
// assign new value
this.value = newValue;
// run ItemChanged() event
if (this.checkForEvent("ItemChanged")) {
psPage.TraceIndent();
this.ItemChanged();
psPage.TraceOutdent();
}
} else {
// run ValidationError() event
page.hadValidationError = true;
if (this.checkForEvent("ValidationError", newValue)) {
psPage.TraceIndent();
this.ValidationError(newValue);
psPage.TraceOutdent();
}
this.invalidValue = newValue;
}
} else {
page.Trace(this.name + ".BindToInput(DataField): value not changed");
}
// push data to component
if (this.bIsBound) {
page.Trace(this.name + ".BindToInput(DataField): pushing value to component '" + this.setEvalString + "'");
eval(this.setEvalString);
}
} else {
page.Trace(this.name + ".BindToInput(DataField): value not passed");
}
}
// this assumes it is being called between <SCRIPT> </SCRIPT> tags after form is complete!
function GenerateClientVariableDefinitionFragment(page) {
if (this.visible) {
// Generate client script variable access to form control
var line = " psPage." + this.name + " = psPage.dataForm." + this.name + ";";
psDocument.WriteLn(line);
}
}
// this assumes it is being called between <FORM> </FORM> tags for submit form
function GenerateClientFormFragment(page) {
// Generate hidden form variable
if (! this.readOnly && this.visible) {
var line = " <INPUT TYPE=\"hidden\" NAME=\"" + this.name + "\" >";
psDocument.WriteLn(line);
}
}
// this assumes it is being called for the body of the OnSubmit() event
function GenerateClientOnSubmitFragment(page) {
if (! this.readOnly && this.visible) {
var line = " submitForm." + this.name + ".value = psPage.dataForm." + this.name + ".value;";
psDocument.WriteLn(line);
}
}
// overrides of ancestor
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -