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
{
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);
}
return query.getObjects();
}
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
| 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
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

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
-------------------

---------------
Here inside the data element the subele
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.
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
/*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
//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
{
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
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
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
for(var i=0;i < childnode_temp =" xmlGetTotalAmount.XMLDocument.documentElement.cloneNode(true);">
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
//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
}
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
//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<>
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
//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);
//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
Good and informative post.
ReplyDelete