📄 objmod80.ssc
字号:
this.BindToInput = BindToInput;
this.GenerateClientVariableDefinitionFragment = GenerateClientVariableDefinitionFragment;
this.GenerateClientFormFragment = GenerateClientFormFragment;
this.GenerateClientOnSubmitFragment = GenerateClientOnSubmitFragment;
this.readOnly = false;
}
class PSButtonClass(name, initialValue)
extends PSFormControlClass(name, initialValue)
{
// buttons are treated differently than other dataFields
function PerformAction (page) {
// run the ServerAction() event
if (this.checkForEvent("ServerAction")) {
psPage.TraceIndent();
this.ServerAction();
psPage.TraceOutdent();
}
}
function BindToInput (page) {
// check if we caused the action to occur
if (this.name == page.actionControlName) {
page.actionControl = this;
page.Trace(this.name + ".BindToInput(Button): caused submit");
} else {
page.Trace(this.name + ".BindToInput(Button): did not cause submit");
}
}
// override of ancestor methods
this.PerformAction = PerformAction;
this.BindToInput = BindToInput;
}
// an image is just a kind of button
class PSImageClass(name, initialValue)
extends PSButtonClass(name, initialValue)
{
}
class PSStaticTextClass(name, initialValue)
extends PSFormControlClass(name, initialValue)
{
// buttons are treated differently than other dataFields
function PerformAction (page) {
// run the ServerAction() event
if (this.checkForEvent("ServerAction")) {
psPage.TraceIndent();
this.ServerAction();
psPage.TraceOutdent();
}
}
function BindToInput (page) {
// check if we caused the action to occur
if (this.name == page.actionControlName) {
page.actionControl = this;
page.Trace(this.name + ".BindToInput(Static Text): caused submit");
}
}
// override of ancestor methods
this.PerformAction = PerformAction;
this.BindToInput = BindToInput;
}
class PSCheckBoxClass(name, defaultChecked)
extends PSDataFieldClass(name, defaultChecked)
{
// override of ancestors
function BindToInput (page) {
// check if value was passed
var newValue = psDocument.GetParamEx(this.name);
if (newValue != null) {
var newChecked = (newValue == "T");
// check if value was changed
if (newChecked != this.value) {
// assign new value
this.value = newChecked;
// run ItemChanged() event
if (this.checkForEvent("ItemChanged")) {
psPage.TraceIndent();
this.ItemChanged();
psPage.TraceOutdent();
}
} else {
page.Trace(this.name + ".BindToInput(CheckBox): value not changed");
}
// push data to component
if (this.bIsBound) {
page.Trace(this.name + ".BindToInput(CheckBox): pushing value to component '" + this.setEvalString + "'");
eval(this.setEvalString);
}
} else {
page.Trace(this.name + ".BindToInput(CheckBox): value not passed");
}
}
// we pass back the checked state of the checkbox, the value is ignored
function GenerateClientOnSubmitFragment(page) {
if (! this.readOnly && this.visible) {
var line = " submitForm." + this.name + ".value = (psPage.dataForm." + this.name + ".checked) ? \"T\" : \"F\";";
psDocument.WriteLn(line);
}
}
function GetCheckedAttribute() {
if (this.value)
return "CHECKED ";
else
return "";
}
// overrides of ancestor
this.BindToInput = BindToInput;
this.GenerateClientOnSubmitFragment = GenerateClientOnSubmitFragment;
// new method
this.GetCheckedAttribute = GetCheckedAttribute;
}
class PSRadioGroupClass(name, initialValue)
extends PSDataFieldClass(name, initialValue)
{
// override of ancestors
function BindToInput (page) {
// check if value was passed
var newValue = psDocument.GetParamEx(this.name);
if (newValue != null) {
// check if value was changed
if (newValue != this.value) {
// assign new value
this.value = newValue;
// run ItemChanged() event
if (this.checkForEvent("ItemChanged")) {
psPage.TraceIndent();
this.ItemChanged();
psPage.TraceOutdent();
}
} else {
page.Trace(this.name + ".BindToInput(Radio): value not changed");
}
// push data to component
if (this.bIsBound) {
page.Trace(this.name + ".BindToInput(Radio): pushing value to component '" + this.setEvalString + "'");
eval(this.setEvalString);
}
} else {
page.Trace(this.name + ".BindToInput(Radio): value not passed");
}
}
function GetCheckedAttribute(radioValue) {
if (this.value == radioValue)
return "CHECKED ";
else
return "";
}
// this assumes it is being called for the body of the OnSubmit() event
function GenerateClientOnSubmitFragment(page) {
if (! this.readOnly && this.visible) {
psDocument.WriteLn(" var radioGrp = psPage.dataForm." + this.name + ";");
psDocument.WriteLn(" // This check is to handle the case where only one radio button exists in the group");
psDocument.WriteLn(" if (radioGrp.checked)");
psDocument.WriteLn(" submitForm." + this.name + ".value = radioGrp.value;");
psDocument.WriteLn(" for (var i= 0; i < radioGrp.length; i++) {");
psDocument.WriteLn(" if (radioGrp[i].checked)");
psDocument.WriteLn(" submitForm." + this.name + ".value = radioGrp[i].value;");
psDocument.WriteLn(" }");
}
}
// overrides
this.BindToInput = BindToInput;
this.GenerateClientOnSubmitFragment = GenerateClientOnSubmitFragment;
// new method
this.GetCheckedAttribute = GetCheckedAttribute;
}
class PSTextClass(name, initialValue, bReadOnly)
extends PSDataFieldClass(name, initialValue)
{
if (arguments.length >= 3)
this.readOnly = bReadOnly;
}
class PSPasswordClass(name, initialValue)
extends PSTextClass(name, initialValue, false)
{
}
class PSDropDownListClass(name, initialValue)
extends PSDataFieldClass(name, initialValue)
{
// we pass back the value of the selected option
// TJC TODO - what about multi-select?
function GenerateClientOnSubmitFragment(page) {
if (! this.readOnly && this.visible) {
var line = " submitForm." + this.name + ".value = psPage.dataForm."
+ this.name + ".options[psPage.dataForm." + this.name + ".selectedIndex].value;";
psDocument.WriteLn(line);
}
}
function GetSelectedAttribute(optionValue) {
// Check if passed option should be selected
if (this.value == optionValue)
return "SELECTED";
else
return "";
}
// overrides of ancestor
this.GenerateClientOnSubmitFragment = GenerateClientOnSubmitFragment;
// new function
this.GetSelectedAttribute = GetSelectedAttribute;
}
class PSTextAreaClass(name, initialValue, bReadOnly)
extends PSTextClass(name, initialValue, bReadOnly)
{
}
MONTH_ARRAY = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
// these functions are used to convert dates into a string
// that the HTMLGenerator component can handle
function dateToString(dateValue) {
var result = MONTH_ARRAY[dateValue.getMonth()] + " " + dateValue.getDate() + "," + dateValue.getFullYear();
return result;
}
function dateTimeToString(dateValue) {
return dateToString(dateValue) + " " + timeToString(dateValue);
}
function timeToString(dateValue) {
var result = dateValue.getHours() + ":" + dateValue.getMinutes() + ":" +
dateValue.getSeconds() + ":" + dateValue.getMilliseconds();
return result;
}
// this is the HTML DataWindow for use with server side scripting
class PSWebDataWindowClass(name, bServerSideState, jaguarConnection, sourceLocation, dbParms, pageSize)
extends PSFormControlClass(name, null)
{
function PerformAction (page) {
// we assume that the context has already been restored by this time
var sAction = psDocument.GetParamEx(this.name + "_action");
if (sAction != null) {
page.Trace(this.name + ".PerformAction(DW): action '" + sAction + "'");
page.TraceIndent();
var bContinue = true;
if (this.checkForEvent("BeforeAction")) {
psPage.TraceIndent();
bContinue = evtdef(this.BeforeAction());
psPage.TraceOutdent();
psPage.Trace("...returned " + bContinue);
}
if (bContinue) {
page.Trace(this.name + ".PerformAction(DW): calling SetAction()");
rc = this.Component.SetAction (sAction, "");
page.TestCompError ("HTMLGenerator.SetAction");
if (rc >= 0) {
// if we succeeded and are connected to Jaguar and did an update,...
if (this.jaguarConnection && sAction == "Update") {
// the jaguar component will have gone back into the pool
// so we need to reset everyting
this.bSetObject = false;
this.connectToComponent();
} else if (sAction == "Retrieve") {
this.bDidRetrieve = true;
}
// don't display message if Action cancelled!
} else if (rc != -4) {
this.triggerOnDBError("PerformAction");
}
if (this.checkForEvent("AfterAction")) {
psPage.TraceIndent();
this.AfterAction();
psPage.TraceOutdent();
}
}
page.TraceOutdent();
} else {
page.Trace(this.name + ".PerformAction(DW): action not passed");
}
}
function BindToInput (page) {
// check if we caused the action to occur
if (this.name == page.actionControlName) {
page.actionControl = this;
page.Trace(this.name + ".BindToInput(DW): caused submit");
} else {
page.Trace(this.name + ".BindToInput(DW): did not cause submit");
}
// make sure we are connected (Which will do a reretrieve if necessary)
if (this.connectToComponent()) {
// if we are auto retrieving,
if (this.bAutomaticRetrieve) {
if (this.checkAutoRetrieveDependants()) {
page.Trace(this.name + ".BindToInput(DW): doing automatic retreival");
psPage.TraceIndent();
this.doRetrieve(this.autoArguments, true);
psPage.TraceOutdent();
} else
page.Trace(this.name + ".BindToInput(DW): dependents did not change, NOT doing automatic retreival");
}
// check if we need to restore state
var sContext = psDocument.GetParamEx(this.name + "_context");
if (sContext != null) {
page.Trace(this.name + ".BindToInput(DW): restoring context");
rc = this.Component.SetAction("",sContext);
if (rc < 0) {
var errorString = this.Component.GetLastErrorString();
page.TestCompError ("HTMLGenerator.GetLastErrorString");
page.Trace(this.name + ".BindToInput(DW): error restoring context (" + rc + ")");
page.Trace(this.name + ".BindToInput(DW): '" + errorString + "'");
page.ReportError (this.name + ".BindToInput", "Restore Context Failed", "(" + rc + ") " + errorString);
result = -1;
}
// run Validate() event
var bValid = true;
if (this.checkForEvent("Validate")) {
psPage.TraceIndent();
bValid = evtdef(this.Validate());
psPage.TraceOutdent();
psPage.Trace("...returned " + bValid);
}
if (! bValid) {
// run ValidationError() event
page.hadValidationError = true;
if (this.checkForEvent("ValidationError")) {
psPage.TraceIndent();
this.ValidationError();
psPage.TraceOutdent();
}
}
} else {
page.Trace(this.name + ".BindToInput(DW): context not passed");
}
}
}
function BindToComponent (page) {
// do automatic retrieve the first time page is accessed
if (page.firstTime && this.bAutomaticRetrieve && ! this.bDidRetrieve) {
page.Trace(this.name + ".BindToComponent(DW): doing automatic retreival");
page.TraceIndent();
this.doRetrieve(this.autoArguments, true);
page.TraceOutdent();
}
}
// this assumes it is being called between <SCRIPT> </SCRIPT> tags after form is complete!
function GenerateClientVariableDefinitionFragment(page) {
// if not generated sucessfully, then there will be no variable!!, so don't generate assignment
if (this.visible && this.bGeneratedSuccessfully) {
// WEBDW generation creates a client side variable with same name as control
psDocument.WriteLn(" psPage." + this.name + " = " + this.name + ";");
// make sure WEBDW can find its controls
psDocument.WriteLn(" " + this.name + ".dataForm = psPage.dataForm;");
}
}
// this assumes it is being called between <FORM> </FORM> tags for submit form
function GenerateClientFormFragment(page) {
if (this.visible) {
// Generate hidden form variables
var line = " <INPUT TYPE=\"hidden\" NAME=\"" + this.name + "_context\" VALUE=\"\" >";
psDocument.WriteLn(line);
var line = " <INPUT TYPE=\"hidden\" NAME=\"" + this.name + "_action\" VALUE=\"\" >";
psDocument.WriteLn(line);
}
}
// this assumes it is being called for the body of the OnSubmit() event
function GenerateClientOnSubmitFragment(page) {
if (this.visible) {
psDocument.WriteLn(" // check if Web DW caused submit");
psDocument.WriteLn(" if (psPage." + this.name + ".action != \"\") {");
psDocument.WriteLn(" submitForm." + this.name + "_action.value = psPage." + this.name + ".action;");
psDocument.WriteLn(" submitForm.__ActionControlName.value = \"" + this.name + "\";");
psDocument.WriteLn(" }");
psDocument.WriteLn(" submitForm." + this.name + "_context.value = psPage." + this.name + ".GetFullContext();");
}
}
function Initialize (page) {
// if not doing server side state, reinitialize
if (!this.bServerSideState) {
page.Trace(this.name + ".Initialize: server side state not saved");
page.TraceIndent();
this.bSetObject = false;
// TJCTODO - should we maybe leave ourselves connected to component?
this.Component = null;
// reinitialize component
this.connectToComponent();
page.TraceOutdent();
} else {
page.Trace(this.name + ".Initialize: server side
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -