Sharing from my Learning - Please share your comments / Questions in the blog comments area or email ggrajan@gmail.com
Sunday, April 15, 2012
Application Class
Steps to create application Class:
1. Create an application package.
2. Create an application class.
3. Code your class.
4. Test your code.
Using Application designer we can do step-1 and Step-2 above.
Step-3 might look something like this:
class MyClass
method GreetMe() Returns string;
end-class;
method GreetMe
Return "Hello " | %OperatorId;
end-method;
Step-4 Test the code:
import GREETERS:MyClass;
Local GREETERS:MyClass &greeter = create GREETERS:MyClass();
Local string &message = &greeter.GreetMe();
MessageBox(0, "", 0, 0, &message);
The first line of this listing imports the MyClass application class into the current PeopleCode module in a manner similar
to a PeopleCode Declare directive.
The second line creates a new instance of the MyClass class using the create keyword.
Inappropriate use of application Class:
1) Avoid using Runtime Context-Sensitive Variables such as %Component, %Portal, %Request, %Page, %Response.
2) Avoid Event-Based PeopleCode such as SavePostChange for Application Classes.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment