Wednesday, December 15, 2010

Upload and Download






//Drage Download and Upload buttons
//Refer cordys documentation for details regarding upload and download
//here it is stored in xmlstore and uploading is getting done in DB but unable to download
//when i upload a file i the download function is called automatically which is shown in a frame
//specify the frame id in on double click the downloader id and set the frame in which image to be loaded

var x;

function btnUpload_Click(eventObject) //on click of button
{

upload1.request = sampleUploadRequest.XMLDocument; //sending the request of xml document for upload
upload1.uploadFile(); //default functin to upload
var node = sampleUploadRequest.XMLDocument.documentElement;////xmlid.xmldocument;
var file_name = cordys.getNodeText(node,".//*[local-name()='upload']","","");
btnDownload_Click(eventObject);//calling default function of download to show it in frame
as when an image is uploaded it will show the image in frame after upload
}

function btnDownload_Click(eventObject)
{
var name1 = sampleDownLoadrequest.XMLDocument;//xmlid.request
cordys.setNodeText(name1,".//*[local-name()='GetXMLObject']/*[local-name()='key']",x, "");
//setting the filename in global variable x to get the download image
download1.searchPath = ""; //it will fetch the file name from tag in xml
download1.request = sampleDownLoadrequest.XMLDocument;
//var name =download1.fileName;// i tried butthis doesnt give the fileName so check afterbrowse function
download1.downloadFile();
alert("downloaded");
}
function upload1_onUpload(eventObject)
{
alert("Uploaded Successfully");//alert
}
function Form_InitDone(eventObject)
{
upload1.onAfterBrowse = Upload1_onAfterBrowse;//afterbrowse i am getting the filename here
btnDownload.hide();
}
function Upload1_onAfterBrowse(eventObject)
{
var fileNamePath=eventObject.fileValue;//here we will get the total value of file
var fileSp=fileNamePath.split("\\");//splitting the file where it has '\'
x=fileSp[fileSp.length-1];//taking the last part name which is being stored in xml and getting it
}

Wizardzzzzz





Wizards are mainly used for flexibility and act as a wizard for navigating pages which goes in a flow.

I will be throwing some light on how its done.
mAIN page script

function Form_InitDone(eventObject)
{
//this is the main wizard page where we are cloning the XML document shown in the figure
var wizreq = cordys.cloneXMLDocument(wizardXMLPages.XMLDocument);
ordersWizardLib.setWizardData(wizreq);//we are setting request to the wizard id=orderswizardlib
var ordersData = {}; //taking an empty array ordersdata to fill the page ids in xml
ordersData.wizardPagesArray = [];
ordersWizardLib.ordersData = ordersData; //wizardid.ordersdata(custom) will take the ordersdata it has
ordersWizardLib.start(); //wizard functionality starts Initializes the wizard. This method also pops up the wizard window //showing the first step of the wizard if the wizard is not already running. If the wizard is running, the focus is set to the //already running wizard.

}

//code snippet in div tags for wizard is shown and also a wizard.htm file is loaded for the functionality of wizard


empdetails:PAGE 1 SCRIPT

function Form_InitDone(eventObject)
{
//creating variable appwindow which shows the application window
/**The container object is automatically created by the framework when a new application has to be started. It offers a collection of methods that can be operated from it, which helps handling the container of the application as such. The container can be accessed through the application by the following format:
application.container. is READ-ONLY. Object that denotes the window object of the container which displays the application.**/

var appwindow = application.container.applicationWindow;
//childwizardlib is calling the appwindow of parent that is frame which is a child of grandparent that wizard UI which loads der.
var childordersWizardLib = appWindow.parent.parent.ordersWizardLib;
var childordersData = ordersWizardLib.ordersData;//getting this ordersData info from main claimwizard UI
if(ordersWizardLib) //if its present hiding and showing the button functionalities
{
childordersData.wizardPagesArray[application.container.applicationId] = appWindow; //matching the id of that application
childordersWizardLib.getWizardWindow().document.getElementById("btnFinish").style.visibility = "visible";
childordersWizardLib.getWizardWindow().document.getElementById("btnBack").style.visibility = "hidden";
childordersWizardLib.getWizardWindow().document.getElementById("btnNext").style.visibility = "visible";
}
window.parent.parent.document.getElementById("loading").style.display = "none";
}
//other functions can also be written
function btnNextShow()
{
var appWindow = application.container.applicationWindow;
var ordersWizardLib = appWindow.parent.parent.ordersWizardLib;
ordersWizardLib.getWizardWindow().document.getElementById("btnNext").style.visibility = "visible";
}
function btnNextHide()
{
var appWindow = application.container.applicationWindow;
var ordersWizardLib = appWindow.parent.parent.ordersWizardLib;
ordersWizardLib.getWizardWindow().document.getElementById("btnNext").style.visibility = "hidden";
}


PAGE 2 is also written in the same way.remind that steps given in the main page xml should be taken care of since these go in the same way as given in xml

function Form_InitDone(eventObject)
{
var appwindow = application.container.applicationWindow;
var childordersWizardLib = appWindow.parent.parent.ordersWizardLib;
var childclaimData = ordersWizardLib.ordersData;
if(ordersWizardLib)
{
childclaimData .wizardPagesArray[application.container.applicationId] = appWindow;
childordersWizardLib.getWizardWindow().document.getElementById("btnFinish").style.visibility = "visible";
childordersWizardLib.getWizardWindow().document.getElementById("btnBack").style.visibility = "visible";
childordersWizardLib.getWizardWindow().document.getElementById("btnNext").style.visibility = "visible";
}
window.parent.parent.document.getElementById("loading").style.display = "none";
}

function btnNextShow()
{
var appWindow = application.container.applicationWindow;
var ordersWizardLib = appWindow.parent.parent.ordersWizardLib;
ordersWizardLib.getWizardWindow().document.getElementById("btnNext").style.visibility = "visible";
}
function btnNextHide()
{
var appWindow = application.container.applicationWindow;
var ordersWizardLib = appWindow.parent.parent.ordersWizardLib;
ordersWizardLib.getWizardWindow().document.getElementById("btnNext").style.visibility = "hidden";
}
function onFinish(){
btnNextHide();
alert("Finished");
}

ARTIFACT VIEWER

Lets discuss something on Artifact Viewer now

This displays a list of artifacts. Artifact is a generic term that represents any entity such as task, object, service group, and service container.
This component has four modes in which to display the artifacts - Icon, List, Detail, and Tiles. You can select a display mode both during runtime and design-time.
The Artifact Viewer component supports the addition of behaviors specific to each artifact type. At runtime, only those options (behaviors) are available for an artifact that are specified for its respective artifact type. This is similar to the behavior of context-menus in Windows, where different context-menu options are displayed for different file types such as folders, .zip files, and .doc files.

I will be now describing the code i used for artifact viewer below :

//The code below refers to client-side plugin. For this, you need to extend type registration JavaScript class. The below code //comprises a JavaScript class where the ArtifactFactoryType JavaScript class is extended by ClaimArtifactFactory.

/** The below code means **/
//Here classname.prototype.methodname is given is equalling to a function which returns taskArtifact.
/* i am confused why prototype is used when i saw it for the first time. i will give u an example of use of it
for example there are names 'John' 'Leela' two words separed by a space.if we need to concat we do in javascript
var parents = ["John", "Leela"];
var children = ["Beckham", "Messi"];
var family = parents.concat(children);

here it is concatenating parents with children and it is calling as string.prototype.concat = function {//which returns concat operation}

or we can write like this .prototype.splitSpaces = function ()
{
// write code for split where spaces required
}
// so from here whenever u use splitSpaces method of type classname of that this would be executed it is as if u are writing //methods inside a class */

function ClaimArtifactFactory() // Here this class is extended by ArtifactFactoryType
{
}
ClaimArtifactFactory.prototype.getType = function () //use of protype explained above
{
/** this method returns type of an artifact **/
//getType is Mandatory.It Returns the type of an artifact.It Must be used to extend the ArtifactFactoryType class.
return "taskArtifact";
}
ClaimArtifactFactory.prototype.addArtifactBehavior = function (iApplicationDefinition)
//iApplicationDefinition type parameter is declared in addArtifactBehavior and it is being returned.
//addArtifactBehavior(applicationDefinition) method adds behavior for an artifact. You can extend the BaseArtifact functionality //the artifact.
/** this method helps to add behavior to each and every artifact **/
{
return new ClaimArtifact(iApplicationDefinition);
}
function ClaimArtifact(applicationDefinition )
{
this.applicationDefinition = applicationDefinition;
this.Artifact(this.applicationDefinition );
}

var user_DN; //creating global variable to use it at various places.
function Form_InitDone(eventObject)
{
////import ArtifactFactoryType into application
application.importType("wcp.library.util.Artifact");
application.importType("wcp.library.util.ArtifactFactoryType");
//extend ArtifactFactoryType
application.inherit(ClaimArtifactFactory, ArtifactFactoryType);
//extend ArtifactFactoryType
application.inherit(ClaimArtifact, Artifact);
var userObject=system.getUser();
user_DN = userObject.organizations[userObject.defaultOrganization].userDN;
//Task Model consists of Runtime webservice getTasksByUser
TaskModel.reset();
var user_name = system.getUser().name;
//Used to display Goodmorning/afternoon/evening in text field
var display = getTime();
if(display >=0 && display <12)rte1.setValue("GoodMorning"+" "+user_name);if(display>=12 && display <16)rte1.setValue("Good Afternoon"+" "+user_name);if(display>=16 && display <24)
rte1.setValue("Good Evening"+" "+user_name);
}
//So we will see all the tasks in the artifact viewer for a user
//this fires on request of model and sets the user_DN as user and checks which UI are attached to it




function TaskModel_OnRequest(eventObject)
{
var req = eventObject.request;
cordys.setNodeText(req,".//*[local-name()='User']",user_DN);
cordys.setNodeText(req,".//*[local-name()='Type']","UI_TASK"); // sets the UserInterface Task
var parameterNode=cordys.selectXMLNode(req,".//*[local-name()='Parameters']/*[local-name()='Parameter']");
//as seen in the image which is soap request we are setting parameter name and value below
parameterNode.setAttribute("name","showOnStartPage");
//setting value of "showonstartpage' for name attribute so that all the tasks related to user are visible
parameterNode.setAttribute("value","true");
//setting value of 'true' for value attribute
}
//this method is fired on response of the model
function TaskModel_OnResponse(eventObject)
{
//response from the taskmodel response we are selecting nodes
var resp = eventObject.response;
var respNodes=cordys.selectXMLNodes(resp,".//*[local-name()='tuple']");
for(var i=0;i
{
var idText = cordys.getNodeText(respNodes[i],".//*[local-name()='id']");
//removing childnodes not to display which are not needed else all these would be shown
if(idText=="cordys_notif_MyInboxTask" || idText=="cordys_notif_ManageParticipantPreferencesTask" || idText=="googlemap_key_manager")
{
respNodes[i].parentNode.removeChild(respNodes[i]);
}
}
//the frame to which to be needed to set is shown below
for(var i=0;i
{

cordys.setNodeText(respNodes[i],".//*[local-name()='frame']","cframe","");

}
//creating an new obj of type getArtifactFactoryType
var ClaimArtifactFactoryObj = claims_artifact.getArtifactFactoryType("ClaimArtifactFactory");
//artifactSchema -is used as schema is mandatory to generate html from the XML nodes passed.
if(system.isIE)
{
//this would be taken based on choice of xml schema to be taken wheter IE or not
ClaimArtifactFactoryObj.artifactSchema = cordys.cloneXMLDocument(artifactIESchema.XMLDocument.documentElement);
}
else
{
//used for multibrowsing code schema is shown below
ClaimArtifactFactoryObj.artifactSchema = artifactNonIESchema.XMLDocument.documentElement;
}
var taskNodes = cordys.selectXMLNodes(resp,".//*[local-name()='LaunchingInfo']")
ClaimArtifactFactoryObj.addArtifacts(taskNodes);
}
function log_out_Click(eventObject) //fires on logout click
{
if(confirm('Are you sure you want to logout?'))
location.href = "/cordys/samlartlogin1.html";
//window.replace(application.select(logout.XMLDocument.documentElement));

}

Tuesday, December 14, 2010

CREATING SIMPLE USER SCREENS

Hello , we are back now i am successfully into my second mini project which is used for internal purpose and all the javaservices and workspace is set ready.The basic thing we need to do is design the X-Form said by them , fetch data into the form from multiple databases. Giving options for the user to update form, create new form/to insert in data , giving admin rules to delete an entry and miscellaneous things are taken care of.

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("");
}

}

Sunday, December 12, 2010

MY FIRST PROJECT

Hi, I will be giving you an example or i would like to throw some light on what exactly i have done in my first Project.I will tell you about the method or the basic idea of the work i have done.
Replicating the same work here takes a lot of time but will try to xplain as much as possible to clear off with basics.

The basic things to be done is ofcourse Cordys Installation to be done.I think it took half a day when i first installed cordys in my system .

Configuring Eclipse is also done.

Loading DatabaseMetadata

Generating WebService App Package and Cordys automatically generates Java Default code and WebServices and SOAP Request would be fired when clicked on Test WebService Operation.These web services would be used in X-Forms or Business Process Models for making UserInterfaces or work with the project.

UserInterfaces are really handy and user friendly. Instead of writing a html code for creating forms,tables,input,output etc ., cordys provides all the icons as in like windows mode.That is the best part and the functionality the form to be done can be written in Javascript tab and XML tab which is present beighbour to Design Form.

For example if you want to have a select box:

Here you can create select box in cordys UI drag and drop and get the dropdown menu on webservice request or can be put static.

For a simple basic query, If you want the Show all execution element here inside the Javaskills select box shown to the left it can be done like this in cordys UI without much difficulty.

1.Drag and drop one select box . Give an id java_skills. If you are getting the select box elements from any service then you have a tab called Dataset when you double click on select box.So go there and choose a model(it is formed from webservice) from where do u need to get the elements or can be put static values.You have an option setting description and value in that select box.

2.Show all - This should show all the data when u select show all in java skills it should fetch all the skills .How do u do this? This is very simple.

Write a query in Java:

public static BusObjectIterator getJavaSkillsByCode(String Skill_Name)
{
String queryText = "select * from MSTR_JAVASKILL ";
String extra="";
if(!("0").equals(Skill_Name))
{
extra="where Skill_Name = :Skill_Name
";
}

QueryObject query = new QueryObject(queryText+" "+ extra);
if(!("0").equals(Skill_Name))
{
query.addParameter("Skill_Name", "MSTR_JAVASKILL.Skill_Name", QueryObject.PARAM_STRING, Skill_Name);
}

query.setResultClass(MSTR_JAVASKILL.class);
return query.getObjects();
}

In the above the select box value id is SKILL_NAME and it is written as above .You might be confused why i have written "if(!("0").equals(Skill_Name))"
because we have setted the value of show all element "0"(zero) in javascript tab of UI like this:

var option_java_skill= {value:"0", description:"Show All"};
java_skill.addOption
(option_java_skill,false,0,false);

Script oOption = ControlID.addOption(oOptionObject , bTransaction, iInsertBeforeIndex , bAllowDuplicates)

oOptionObject The option object that must be added to the Select and List control.
bTransaction Boolean which denotes whether the object has to be updated for transaction. The default value is true, which updates the data associated with the control. This also fires the onchange event for enumerated Select and List controls.
iInsertBeforeIndex Integer that denotes the index before adding the Select or List options.
bAllowDuplicates Boolean that denotes whether duplicate items are allowed in the list box. The default value is true. If this property is set to false, then the option object is added only if it is unique.


Here java_skill is the i
d of the select box.
This is how it is done.

I will be now giving the example of few things . I will carry on to other basic things realted to X-Forms now.


I have worked on nearly 8 Xforms of same functionality and type in my first project but for everyting we build a new xml and a new java service based on their criterion.Here i will be explaining how to build a table based on XML and how to fetch data based on the XML structure.

Lets go to X-Form Design Page:
This is how it look
s. The table contains five columns but we need those five columns to be filled from the request of another webservice where we will set the data to these columns .How do we do that ? Lets see Now.

The soap node request and response for the webservice looks like this . From here we are setting those things to column.Very simple.


First we are creating an xml structure i
n the Xform UserInterface like this:(You can create your own but for u r understanding i am giving an example)
-------------------















---------------

Here inside the data element the subele
ments present are the column names of our table.Since we are appending those values i m getting from request i am using the same names we get from soap reponse as reference to these column fields.

So from the figure double click on the table and set the reference as data(from xml whatever is present) since the data node would be repeating and we are cloning this data since the soap request consists of many data or if the table need to be filled with more than one row.

We assign this table attached to a dummy Model and put data in this dummy model fetched from other services and show it in the runtime.The dummy Model should be NonTransactional since it is not transactional like other webservices generated.

then lets go for the javascript part now:

JavaScript:(see the comments i am explaining what actually is done in the script)

-------------------------------------------------------------------
var total = 0; /* In this form i am creating a total field to calculate total at run time which is not present in the webservice
or soap response and appending that to the table we require ; a global variable is declared so that it can be used anywhere and in any function */
function Form_InitDone(eventObject) //This event is called at the page loading of the form
{
emp_name.se
tValue("user"); //default i am setting the value as user
/*if u want to get the username of the logged in person u can fetch it like this
var userDN = system.getUser().name; //that userDN u can send it to request the basic thing is u r setting for getting a response
*/
tblReports.hide(); // i am hiding the table on loading of page and will show on click of button.
}
function GetClaimsByUserModel_OnRequest(eventObject) //GetClaimsByUserModel is the model in which GetClaimsByUser Webservice is present and we are setting
//request for it .
{
cordys.setXMLNamespaces(eventObject.request,{"bagi":"htt
p://schemas.cordys.com/Claim_ApprovalDatabaseMetadata"});
//We are setting XMLNamespaces if we are using different filelocations with diff namespaces then specifying is necessary
cordys.setNodeText(eventObject.request,".//*[local-name() = 'Emp_Name']",emp_name.getValue(),"");
//setting the node in the request where local-name in te request xml is Emp_Name to emp_name.getValue() which fetches the value of that field
//and we get a response based on that request.
}

function button5_Click(eventObject) //button5 isthe id of the view table button in the form wich on click fires the model.
{
GetClaimsByUserModel.reset(); // .reset is a command to fire a model
}
function GetClaimsByUserModel_OnResponse(eventObje
ct)
{
prepareReport(eventObject.response);
//on response of this model we are displaying the table with report done with calculated total amount.Lets see the function
}
function prepareReport(responseNode)
{
//Here creating a variable dataNode where we are taking the clone of XML shown above so that every new data comes in stores in that clone
// document of XML instead of replacing the original one of XML document. Here xmlGetTotalAmount is the id given in teh above xml.Go to top to see
var dataNode = xmlGetTotalAmount.XMLDocument.documentElement.cloneNode(true);
//setting XMLNamespaces is not mandatory here sinc
e all have te same namespace and same data we are setting
cordys.setXMLNamespaces(dataNode,"http://schemas.cordys.com/Claim_ApprovalDatabaseMetadata");
//so here another variable is created to check how many data of the type above or how many reponses are coming in te SOAP re
sponse
var tupleNodes = cordys.selectXMLNodes(responseNode,".//*[local-name() = 'GetClaimsByUserResponse']/*[local-name() = 'tuple']/*[local-name()='old']","");
//here we get 11 repsonses in this example
var nooftuple = tupleNodes.length;
//executing for loop for these and appending 11 respones of data
into the table into respective fields
for(var i=0;i < childnode_temp =" xmlGetTotalAmount.XMLDocument.documentElement.cloneNode(true);">
here it is present and which one to clone from 'data' check xml above
var childNode = cordys.selectXMLNode(childNode_temp,".//*[local-name() = 'data']","");
//getting the value of different fields from SOAP REsponse
var claim_id = cordys.getNodeText(tupleNodes[i],".//*[local-name() = 'claim_total_amount']/*[local-name()='Claim_Id']","");
//getting the value of different fields from SOAP REsponse
var emp_name = cordys.getNodeText(tupleNodes[i],".//*[local-name() = 'claim_total_amount']/*[local-name()='Emp_Name']","");
//getting the value of different fields from SOAP REsponse
var claim_amount = cordys.getNodeText(tupleNodes[i],".//*[local-name() = 'claim_total_amount']/*[local-name()='Claim_TotalAmount']","");
//getting the value of different fields from SOAP REsponse
var status = cordys.getNodeText(tupleNodes[i],".//*[local-name() = 'claim_total_amount']/*[local-name()='Mngr_Stat
us']","");
//Here actually the first real node contains nothing in the xml so when we append shown below it will append to the empty node so we replace the
//first data with the emppty data in xml so that we dont get the xml default values given in xml ; so we are writing if i==0
if(i==0)
{
//setting node text to XML where localname in xml is Claim_Id
cordys.setNodeText(dataNode,".//*[local-name() = 'Claim_Id']",claim_id,"");
//similarly
cordys.setNodeText(dataNode,".//*[local-name() = 'Emp_Name']",emp_name,"");
//similarly
cordys.setNodeText(dataNode,".//*[local-name() = 'Claim_TotalAmount']",claim_amount,"");
//similarly

cordys.setNodeText(dataNode,".//*[local-name() = 'Mngr_Status']",status,"");
}

else

{
//similarly
cordys.setNodeText(childNode,".//*[local-name() = 'Claim_Id']",claim_id,"");
//similarly
cordys.setNodeText(childNode,".//*[local-name() = 'Emp_Name']",emp_name,"");
//similarly
cordys.setNodeText(childNode,".//*[local-name() = 'Claim_TotalAmount']",claim_amount,"");
//similarly

cordys.setNodeText(childNode,".//*[local-name() = 'Mngr_Status']",status,"");
//HERE we are appending this childNode to dataNode;dataNode initially contains empty default values from xml which is replaced from if i==o condition
//that is being appended by childNode everytime
cordys.appendXMLNode(childNode,dataNode);

}

}
//for creating total of all Claim_Amount column values ;just taking one column as example
for(var j=0;j<>
m response
var temp_total = cordys.getNodeText(tupleNodes[j],".//*[local-name() = 'claim_total_amount']/*[local-name()='Claim_TotalAmount']","");
total = total + parseInt(temp_total);
}
var childNode_temp = xmlGetTotalAmount.XMLDocument.documentElement.cloneNode(true);
//creating another node to get the last row name as TOTAL through script by not writing in xml
var finalNode
= cordys.selectXMLNode(childNode_temp,".//*[local-name() = 'data']","");
//setting the last row data quarter reference to TOTAL // here quarter is the reference to the first column wher u cn give sideheadings or anything as i have given //
//setting the node and value to it
cordys.setNodeText(finalNode,".//*[local-name() = 'quarter']","TOTAL","");

cordys.setNodeText(finalNode,".//*[local-name() = 'Claim_Id']","N/A","");

cordys.setNodeText(finalNode,".//*[local-name() = 'Emp_Name']","N/A","");
//setting the value of global variable total calcualted above
cordys.setNodeText(finalNode,".//*[local-name() = 'Claim_TotalAmount']",total,"");

cordys.setNodeText(finalNode,".//*[local-name() = 'Mngr_Status']","N/A","");
//again appending finalNode to dataNode
cordys.appendXMLNode(finalNode,dataNode);

//alert(dataNode.xml);
//so in this dummy model we are putting dataNode to which all the childnodes and finalnode has been appended
dummyModel.putData(dataNode,true);
//to show the table which is being hided in initdone // check the image below to see how results would be displayed.
tblReports.show();
}

_____________________________________________

















SO this is how i did in my first project .The basic idea is the above one which i have done.
I have done other layout issues and i did like quarter wise total and yearly totals of sales of amount and getting totals added in horizontal and vertical columns and miscellaneous features.
We will continue with next concept in the coming posts.The last row in the above image shows the Total

Friday, December 10, 2010

Starting With CORDYS

Hello,

This is overall a new experience which developed interest in me in the field of development with the help of CORDYS Product . I came into this approximately 6 months back which i didnot think of earlier when i was in engineering.But I have interest to do something new rather than everyone doing the same work everyday.

So i thought its better to have a documentation of my works done so that i can refer to doubts if i get in the future .So i thought of maintaining in a book.After a while i thought why cant i maintain it in a blog which would be useful not only to me but to the people who are feeling difficulty with the development based on cordys product.

I will be making documentation of my work done in the previous projects.I am giving a outline of the things here which i am going to discuss in the coming days.

1.RMIS Project
2.PMS Project
3.eMarine Project
4.SmartTraveller Project
5.Claims Approval
6.Use of Wizards and Artifact Viewer
7.Use of Uploader and Downloader
8.Microsoft SQL Server Database
9.PDF and EXCEL report generation.

Other things will be added to the above list.

Continue adding your scripts to the blog to make this really a useful blog to the everyone working on this platform.

TO BE CONTINUED . . .


PS:If you find any misconception in the things i am gonna say you are free to post so that both of us can learn the right things together.