They have given us some 24 forms and functionality different for user role and admin in these forms.
So its better if we call a xform from its parent form in an application.But when i started this i was a fresher i did everyform like hiding and showing option. For example ; if we need to create a new entry then i used to hide the column which displays all entries. After completion of new entry/delete entry i used to hide this new entry group so and so.
View this screen shot and i will showing u the design and javascript . You can understand easily.

For functioning of select box i have described in
Clcik here : How to create a select box
function Form_InitDone(eventObject) //done during loading of page
{
insertdetails.hide(); // insertdetails is the table id of inserting new details
var req=GetMstrBranchObjectsModel.getMethodRequest(); //setting on request of model
cordys.setNodeText(req,".//*[local-name()='fromBRANCH_CODE']","0","");
cordys.setNodeText(req,".//*[local-name()='toBRANCH_CODE']","zzzzzzzz","");
GetMstrBranchObjectsModel.reset();
}
function doGetMstrBranchObject(eventObject) //automated generated request firing by cordys
{
//Note: AUTO GENERATED code, do not edit manually!
WebForm.sendRequest(Find_GetMstrBranchObjectModelGroup);
}
function insert_Click(eventObject) //on insert is the id of button INSERT to insert new details
{
insertdetails.show(); //showing table which is hided
GetMstrBranchObjectModel.clear(); //it would clear all the data in the table
GetMstrBranchObjectModel.reset(); //it would reset the table or fire the request and get the data back
//setting request parameters to the model to get branch id
var reqbranchid=GetMstrBranchObjectsModel.getMethodRequest();
cordys.setNodeText(reqbranchid,".//*[local-name()='fromBRANCH_CODE']","0","");
cordys.setNodeText(reqbranchid,".//*[local-name()='toBRANCH_CODE']","zzzzzzzz","");
GetMstrBranchObjectsModel.reset();
//setting request parameters to the model to get branch name
var reqbrname=GetMstrBranchObjectsModel.getMethodRequest();
cordys.setNodeText(reqbrname,".//*[local-name()='fromBRANCH_NAME']","0","");
cordys.setNodeText(reqbrname,".//*[local-name()='toBRANCH_NAME']","zzzzzzzz","");
GetMstrBranchObjectsModel.reset();
//.create creats a new row in table
MSTR_BRANCHGroup1.create();
MSTR_BRANCHGroup1.hide();
Find_GetMstrBranchObjectModelGroup.hide();
//setting default value by 1 which is being replaced
branch_Create.setValue(1);
//setting create date to new date which is date on which they create
branch_Createdate.setValue(new Date());
/*
Syntax
Script controlID.initialize(oModelID [, sReference]);
parameter Description
oModelID: This parameter is optional. Object denotes the model from which the Select or List control is initialized. If not specified, the control is initialized with the model that is specified for pre-filling.
sReference :This is an optional parameter. String denotes the starting point for data reference from which the Select or List control is initialized. The starting point is generally the response present in a model. For Transactional models, the starting point is the business object. The default value is "*".
*/
stateid.initialize(GetMstrStateObjectsModel,"0");
}
function branch_code_BeforeFill(eventObject)
{
// this is for what to be shown in the select box before opening
var option_branch_code = {value:"0", description:"Show All"};
var option={value:"", description:"--Select--"};
//adding options to the select box control id
branch_code.addOption(option,false,0,false);
branch_code.addOption(option_branch_code,false,0,false);
}
function MSTR_BRANCHGroup1_xformsonrowclick(eventObject)
{
//these things like insertdetails table will be opened on click of row in a table of view details
insertdetails.show();
MSTR_BRANCHGroup1.hide();
Find_GetMstrBranchObjectModelGroup.hide();
branch_changeuser.setValue(1);
branch_changedate.setValue(new Date());
}
function save_Click(eventObject)
{
//save functionality
if(validateSave())
{
//model.synchronize saves the information related to that model in database by updating or inserting a new one
GetMstrBranchObjectModel.synchronize();
//the below .soapfaultoccured ...below code means if no cordys error has been thrown then it is saved
if(!GetMstrBranchObjectModel.soapFaultOccurred)
{
alert("New details have been saved");
}
}
Find_GetMstrBranchObjectModelGroup.show();
MSTR_BRANCHGroup1.show();
GetMstrBranchObjectModel.clear();
insertdetails.hide();
GetMstrBranchObjectsModel.reset();
branch_code.setValue("");
}
function validateSave()
{
/* if(false)
{
return false;
}*/
return true;
}
function cancel_Click(eventObject) // on click of cancel would not update the records and go back
{
GetMstrBranchObjectModel.clear();
Find_GetMstrBranchObjectModelGroup.show();
MSTR_BRANCHGroup1.show();
insertdetails.hide();
branch_code.setValue("");
}
function branch_code_Change(eventObject) // on change of select box we are setting teh nodetext value to the one selected by us
{
var val= eventObject.value;
cordys.setNodeText(GetMstrBranchObjectModel.getMethodRequest(),".//*[local-name() = 'BRANCH_CODE']",val,"");
GetMstrBranchObjectModel.reset();
}
//cordys throws errors in popup if duplicate entry tries to update or if the functionality fails its throwing an error
//which could not be understood to a normal user .so for that we are throwing alerts and make the process to continue further
function GetMstrBranchObjectModel_OnSOAPFault(eventObject)
{
if(eventObject.faultString == "The statement has been terminated.Violation of PRIMARY KEY constraint 'PK_MSTR_BRANCH_CODE'. Cannot insert duplicate key in object 'dbo.MSTR_BRANCH'.")
{
alert("Record Already Exists");
eventObject.showError = false; // this will not show cordys error and throw only alert we give
}
else if(eventObject.faultString == "Accessor is invalid.")
{
alert("Insert Some Record");
eventObject.showError = false;
}
else if(eventObject.faultString == "The statement has been terminated.Cannot insert the value NULL into column 'BRANCH_NAME', table 'EPM_DEV.dbo.MSTR_BRANCH'; column does not allow nulls. INSERT fails.")
{
alert("Cannot insert the value NULL into column 'BRANCH_NAME'");
eventObject.showError = false;
}
else if(eventObject.faultString == "The statement has been terminated.Cannot insert the value NULL into column 'BRANCH_CODE', table 'EPM_DEV.dbo.MSTR_BRANCH'; column does not allow nulls. INSERT fails.")
{
alert("Cannot insert the value NULL into column 'BRANCH_CODE'");
eventObject.showError = false;
}
}
//before fill of select box of branch code
function branchcode_BeforeFill(eventObject)
{
var option={value:"", description:"--Select--"};
branchcode.addOption(option,false,0,false);
}
//before fill of select box of branch name
function branchname_BeforeFill(eventObject)
{
var option={value:"", description:"--Select--"};
branchname.addOption(option,false,0,false);
}
//before fill of select box of stateid
function stateid_BeforeFill(eventObject)
{
var option={value:"", description:"--Select--"};
stateid.addOption(option,false,0,false);
}
//on change validflag id setting the values automatically on choosing 1 or 2
function validflag_Change(eventObject)
{
if(validflag.getValue()==2)
{
branch_enddate.setValue(new Date());
}
else if(validflag.getValue()==1)
{
branch_enddate.setValue("");
}
}
No comments:
Post a Comment