Examples: Mobile Application Platform PeopleCode

This topic contains examples that illustrate using PeopleCode in the Mobile Application Platform.

Some of the example reference transactional data and application metadata.

Field or Control

Definition

Transactional Data

Data passed from the PeopleSoft document and can include things like customer ID, customer name, purchase order number, and so on.

Application Metadata

Metadata that determines how things are going to be rendered in the application – essentially layout metadata, like classes, page elements, and so on. Application metadata also defines the behavior of page controls.

This example shows a sample Mobile Application Platform application class.

In the example you’ll notice that the Map object does not get instantiated. Instead, the Map object is built based on the layout metadata, which is the layout itself.

The layout in this example is FlightCard. So the framework creates the Map object to pass into the event, and if the event method returns a Map object, then it simply returns it.

import PS_PT:Integration:IDocLayoutHandler;

class FlightCard implements PS_PT:Integration:IDocLayoutHandler
	method FlightCard();
	method OnInitEvent(&Map As Map) Returns Map;
	method OnUpdateEvent(&Map As Map) Returns Map;
	method OnSaveEvent(&Map As Map) Returns string;
	property integer SaveStatus;
end-class

/* constructor */
method FlightCard
end-method;

method OnInitEvent
	Local Compound &COM;
	Local Document &Document;
	
	&Document = &Map.GetDocument();
	&COM = &Document.DocumentElement;
	
	/* run business logic and return Map object */
	Return ⤅
end-method;

method OnUpdateEvent
	Local Compound &COM;
	Local Document &Document;
	
	&Document = &Map.GetDocument();
	&COM = &Document.DocumentElement;
	
	/* run business logic and return Map object */
	Return ⤅
end-method;

method OnSaveEvent
	Local Compound &COM;
	Local Document &Document;
	
	&Document = &Map.GetDocument();
	&COM = &Document.DocumentElement;
	
	/* run business logic */
	Return "Success";
end-method;

Local Compound &COM;
Local Document &Document;
   
 &Document = &Map.GetDocument();
 &COM = &Document.DocumentElement;
 &COM.GetPropertyByName("Pilot").Value = "data";

   
 Local Compound &COM;
 Local Document &Document;
 Local MapPage &Page;
 Local String &ClassName; 
 &Document = &Map.GetDocument();
 &COM = &Document.DocumentElement;
 &COM.GetPropertyByName("Pilot").Value = "data";

 &Page = &Map.GetPage(1);
   
 /* Read and write out Main Class Name */
 &ClassName = &Page.MainClassName;
 &Page.MainClassName = "input-wrapper";

Local Compound &COM;
Local Document &Document;
Local MapPage &Page;
Local MapElement ∈
Local string &ClassName, &LabelText;
   
&Document = &Map.GetDocument();
&COM = &Document.DocumentElement;
&COM.GetPropertyByName("Pilot").Value = "data";
   
&Page = &Map.GetPage(1);
   
/* Read and write out Main Class Name */
&ClassName = &Page.MainClassName;
&Page.MainClassName = "input-wrapper";
   
/* MapElement object via MapPage object */
&Element = &Page.GetElement("mapbutton_1");
&LabelText = &Element.LabelText;
&Element.LabelText = "Update";
   
/* MapElement object via Map object */
&Element = &Map.GetElement("mapbutton_1");
&LabelText = &Element.LabelText;
&Element.LabelText = "Update";

Local Compound &COM;
Local Document &Document;
Local MapPage &Page;
Local MapElement ∈
Local string &ClassName, &LabelText;
Local integer &Control;
   
&Document = &Map.GetDocument();
&COM = &Document.DocumentElement;
&COM.GetPropertyByName("Pilot").Value = "data";
   
&Page = &Map.GetPage(1);
   
/* MapElement object via MapPage object */
&Element = &Page.GetElement("mapbutton_1");
&LabelText = &Element.LabelText;
&Element.LabelText = "Update";
 
/* disable Button */  
&Control = &Element.Controls;
&Element.Controls = %MAP_Disable;

Local Compound &COM;
Local Document &Document;
Local MapPage &Page;
Local MapElement ∈
Local string &ClassName, &LabelText;
Local integer &Control;
   
&Document = &Map.GetDocument();
&COM = &Document.DocumentElement;
&COM.GetPropertyByName("Pilot").Value = "data";
   
&Page = &Map.GetPage(1);
   
/* Change JavaScript Event and Function*/
&Element = &Page.GetElement("mapbutton_1");
&Element.SetJavaScript("onclick", "changedata");

Local Compound &COM, &URICOM;
Local boolean &bRet;
Local Document &Document, &URIDocument, &Doc
   
&Document = &Map.GetDocument();
&COM = &Document.DocumentElement;
   
&URIDocument = &Map.GetURIDocument();
&URICOM = &URIDocument.DocumentElement;
   
&Doc = CreateDocument("MAP_LAYOUT", "FLIGHTCARD1_MAP", "v1");
&COM = &Doc.DocumentElement;
&COM.GetPropertyByName("PAGE_ID").Value = "INIT";
&COM.GetPropertyByName("LAYOUT_ID").Value = - 1;
   
&bRet = &Map.SetOvrdAJAXDocument(&Doc);
   
Return ⤅

&Doc = CreateDocument("MAP_LAYOUT", "FLIGHTCARD1_MAP", "v1");
&COM = &Doc.DocumentElement;
&COM.GetPropertyByName("PAGE_ID").Value = "INIT";
&COM.GetPropertyByName("LAYOUT_ID").Value = - 1;
&string = %IntBroker.GenLayoutHTML("FLIGHTCARD", 1, &Doc, “mapcont_start_2”);