Question
Centene
US
Last activity: 17 Jul 2017 16:28 EDT
PDN or Pega Help sought re: Pages & Classes
Hi all,
I have taken SAE I & II and have really not gotten a grasp of what is going on in the "Pages & Classes" tab. I have tried searching PDN and Mesh, as well as the online help, but really am not quite getting it. Is there a better overall guide to understanding this tab and the concepts it is trying to present?
I'm quite comfortable with inheritance/polymorphism, instantiation of objects, etc, but I just don't know what is being done here. When I ask people it's a bit like 5 blind guys describing an elephant - I get a different answer each time.
Where I am stumped is:
- are we declaring "new" variables / objects / whatever that are to be of the specified class?
- if not, if we are just stating a reference to something (which implies it already exists), where does that come from - is it assumed to be on the Clipboard?
- is it something altogether different than either of these?
Thanks
***Updated by moderator: Marissa to close post***
This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Updated: 8 May 2015 9:13 EDT
Pegasystems
IN
Let me try and answer your questions
- The values in pages and classes are like defining variables of a certain class. They are not doing a "new”.
- If you need to do a new for those variables, you need to use the "Page-New” method in the activity (if its an activity).
- Otherwise, they are assumed to be references to pages in the clipboard in the current pega thread.
So it is more like references to objects of different types within your current class.
Pegasystems
US
Hi Jim,
Pages-and-classes merely describes some pages, it doesn’t create them, and it doesn’t define them.
One example would be if you were defining an activity and you were typing in the fields of a property-set step, and you typed
Mypage.
Note the dot at the end. Often when you type that dot, the system presents a list of possible properties so you can conveniently choose one.
But if “Mypage” isn’t mentioned in the pages-and-classes tab, then the system makes some assumptions about what the class of page Mypage is, which might be wrong (it tends to err on the side of too-generalized) .
If you specified in pages-and-classes, for example, that Mypage is of class “Code-Pega-List”, then when you press that dot during your property-set step, the system will know to present a list of properties from class Code-Pega-List. /Eric
Centene
US
Eric
Thanks much, and your answer brings up more questions (of course!). Is "MyPage" a new name that you can just make up, or is it the actual name of a property that is assumed to exist on the clipboard. And if we're just referencing clipboard properties, how does one test something like this? (In other words, to test it, i may not be in step 50 of the 30th stage or whatever of my overall process - how do I just set up data to run using this "MyPage" clipboard value?
Pegasystems
IN
I think "MyPage” can be made up if you want to create it. Like in Java you write
MyClass mypage;
Where MyClass is the class and mypage is the name of the variable of type MyClass.
As I said, you can use Page-New to instantiate it or if it is already instantiated in the Clipboard, then you could just use it.
Usually you would probably want to write a pre-activity to create this page or load this page using an Obj-Open from the database or populate it via a connector from an external source etc. so that the data is in the clipboard before it is used.
Centene
US
So, Rajiv, this is where the Pega terminology confuses me. When you say
"I think "MyPage” can be made up if you want to create iI think "MyPage” can be made up if you want to create it."
that's the opposite of the answer you earlier gave, where you said
"The values in pages and classes are like defining variables of a certain class. They are not doing a "new”."
So either we are or we are not creating a new variable here, or we're just referencing pre-existing clipboard properties. This is why I am confused. Does the Pages & Classes tab exist just to define references, data types, etc, to existing clipboard values, or to define new variables to use? Or both? And if both, how do you tell whether something is assumed to be on the clipboard at run time or not?
Pegasystems
IN
Sorry for the confusion.
Does the Pages & Classes tab exist just to define references, data types, etc, to existing clipboard values, or to define new variables to use? Or both? And if both, how do you tell whether something is assumed to be on the clipboard at run time or not?
It is both. Like in the OO world, defining the variable is not enough. How do you know in a method of the class whether the variable has been instantiated? You will check for "null" (mostly) or you will assume the constructor or some other method has done the initialization for you so that the method in the class can safely use that variable. When those assumptions break, in Java you end up with NullPointerException.
Coming the Pega platform world, it is the same. Mentioning something in the Pages and Classes means that the variable has been defined. You could explicitly instantiate it or you could assume that something else has populated it. You can check if this has already been instantiated using pageExists Rule-Utility-Function before actually referring to properties within it.
So the clipboard is like space (with the pega thread context) where all pages are available for use by different rules executing in that context. That is where it is different from standard OO.
Pegasystems Inc.
IN
Hi Jim/All, Good Morning!
with my recent(new) learning...
A page declared on Pages & Classes tab would create a new page though the page is not created via method "Pega-New" when the below environment variable is set in prConfig.xml file
<env name="compatibility/createmissingpages" value="true" />
Please share your thoughts/comments, Thank you!
psahukaru
Centene
US
Thanks Phani! Well, this is more of the "ask different people, get different answers". Your answer sounds like a "new" variable is being instantiated, others have said it's just referencing something already existing on the clipboard. Color me confused
Pegasystems Inc.
IN
as said earlier in the posts by Rajiv/Eric - declaring a page under Pages & Classes tab is used as reference to get the context and access to properties.
- example: A page 'temp_NewCustomer' is of class (MyCo-Data-Customer)
- Activity: CreateNewCustomer is created in class MyCo-Work
- Step #1 Page-New temp_NewCustomer [declare the page 'temp_NewCustomer' under Pages & Classes tab]
-
Step #2 Property-Set temp_NewCustomer (step page) we would get access to all the properties & inherited properties in class 'MyCo-Data-Customer --> Data-Party --> Data- --> @baseclass' though we create the activity in work class.
- so it will be .pyCity (MA)
Output: property 'pyCity' will have MA on clipboard page 'temp_NewCustomer'
please note ...
as said earlier in the posts by Rajiv/Eric - declaring a page under Pages & Classes tab is used as reference to get the context and access to properties.
- example: A page 'temp_NewCustomer' is of class (MyCo-Data-Customer)
- Activity: CreateNewCustomer is created in class MyCo-Work
- Step #1 Page-New temp_NewCustomer [declare the page 'temp_NewCustomer' under Pages & Classes tab]
-
Step #2 Property-Set temp_NewCustomer (step page) we would get access to all the properties & inherited properties in class 'MyCo-Data-Customer --> Data-Party --> Data- --> @baseclass' though we create the activity in work class.
- so it will be .pyCity (MA)
Output: property 'pyCity' will have MA on clipboard page 'temp_NewCustomer'
please note ...
- the declaration would help to get reference to properties during design time
- from Pega 7 - if a step page is not declared under Pages & Classes tab & referred in a step would throw design time error on saving the activity rule
- As a page without an absolute class would result in unknown errors.
- also refer: https://pdn.pega.com/release-notes?version=8431 [Some pages may no longer be classless]
Centene
US
Rajiv
Pardon my lack of knowledge here...
"Mentioning something in the Pages and Classes means that the variable has been defined. You could explicitly instantiate it or you could assume that something else has populated it."
If it's already populated, why do I need to mention it again in the Pages and Classes tab? I can understand if i am truly creating something new, why that is necessary. But if i am just referencing an existing Clipboard value, why do I need to go define it again in Pages & Classes?
Pegasystems
IN
Hi Jim,
You might want to refer back to Eric's comment of putting a dot after the name of the page in the rule to get a list of properties.
To clarify further, when you are creating / updating a rule, you are at design time. While crafting the rule, you are referring to to variables (clipboard pages) which you believe will exist when you actually execute the rule (runtime). Since these pages may not exist at design time in the clipboard, but you do need to refer to properties under that page, you define the type (PRPC class) for it in Pages and Classes tab so that within the rule you can refer to properties under it using the dot notation as Eric pointed out. If you don't associate a type, you are essentially saying I don't know the type of this page so default it to any type which means when you put a dot after the page name, you will not be able to get the list of properties because we can't resolve it to the correct type.
Citing an example from the Java world where you are using an IDE (like eclipse) to write a Java class.
When you create a class and define variables in that class, you use the "ctrl + space” to get the list of methods or variables for that class while writing the code within your method. At the time of writing the code, those objects don't exist in memory. But when you execute the code, you assume (either by instantiation or by passing via reference / value) that the variable is initialized for use.
-Rajiv
Centene
US
Thanks all, this has indeed been interesting. Based on Rajiv and Eric, it sounds like we are NOT instantiating new variables in the Pages & Classes tab?
Phani's quote reads,
"A page declared on Pages & Classes tab would create a new page though the page is not created via method "Pega-New" when the below environment variable is set in prConfig.xml file
<env name="compatibility/createmissingpages" value="true" />
"
So, this is why i am confused. I can certainly understand the concepts outlined, I just don't know which one actually is in place here.
Centene
US
Based on this article in the 7.1.6 help:
https://community.pega.com/sites/default/files/help_v71/procomhelpmain.htm
I am going with Rajiv Nistala and Eric Osman's description of "referencing already-existing-values". Thanks all!
Centene
US
Just when I thought I understood that Pages & Classes refer to an already-existing value on the clipboard, per Rajiv Nistala and Eric Osman, I come across this article which shows creating something called "Operator" in the Pages & Classes tab, and acting on it as if it were a new variable/value/whatever:
Any thoughts? Am I misreading this article?
https://pdn.pega.com/java-and-activities/introduction-to-activities
BNY Mellon
US
Here's what the document says:
"on the Pages & Classes tab, enter the name of a page that can hold the contents of the Operator ID record returned by the Obj-Open method."
By "can hold", what is meant here is "will hold". That's what's done in step 1 of the demonstrated activity.
To update Rajiv's answer above, you can also use methods like Obj-Open or Page-Copy to set the name of page, declared on the Pages & Classes tab. This is in keeping with the use of P&C similar to declarations in a traditional programming.
Pegasystems
IN
As Jon said, what you define in Pages and Classes are declarations which may have already been initialized previously or can be initialized using Rule-Method like Page-New, Obj-Open, Page-Copy etc. The clipboard unlike standard OO is not enclosed within the "class" but is a more global (restricted to current PRThread) space on which data has already been put by a previous rule or can be initialized by the current executing rule.
Centene
US
Thanks Rajiv - so it sounds like, when you say
"which may have already been initialized or can be initialized"
That it can be either an existing value or a new one you create - is that right?
Pegasystems
IN
Yes. You have defined a variable which can reference an existing page in the clipboard or you can define a variable and initialize it in the current rule execution.
Centene
US
So - coming from a "traditional" programming background - can you give me an example or equivalent? I have never seen something where, when you look at it, you don't know if it is referring to an already-existing variable, or if it is declaring a new instance. Pretty much any language I've seen has a very clear distinction between these two.
BNY Mellon
US
Jim,
You've hit the nail on its head here. This nail's been sticking out since the beginning.
Since Pages & Classes is intended for validation, it should include validation for you (the developer) to indicate where a page is created & removed:
- Created by [X] this [ ] Other activity ______________________
- Removed by [X] this [ ] Other activity ______________________
I guess this is less important these days with the reduced need for activities, but this would be giant help in doing effective code review exercises.
Jon
Centene
US
Thanks Jon Garfunkel
Jon
I stlil see the use of the Pages & Classes tab throughout v7 of Designer Studio, however -in defining Sections, and other places. So it's definitely an ongoing, current question
Pegasystems
US
>>> you don't know if it is referring to an already-existing variable, or if it is declaring a new instance
A specification in java saying “double average(double a, double b);” neither refers to already-existing method “average” nor declares method “average”. That specification says “if you call method average, give it two doubles as parameters, and it will return a double”. /Eric
Centene
US
That's what I'd call a reference - an interface definition is just a reference to a method, not the actual method itself. What it sounds like we're saying in pages & classes is both references and instantiations, hence my confusion
Pegasystems
US
>>> What it sounds like we're saying in pages & classes is both references and instantiations, hence my confusion
I’ve never seen the pages-and-classes tab do “instantiation”. Here are some situations in which I’ve used it:
1) I mentioned my operator-record in the pages-and-classes tab of my activity, and then did some read operations from my operator-record in the steps tab of the activity. In this situation, there’s no instantiation at all. The operator page already exists as a requestor-wide-available page, and is shown in the clipboard viewer.
2) I mentioned a page called “mypage” in the pages-and-classes tab of my activity, specifying that its class is one of my data classes. I then instantiate page “mypage” on one of my activity steps either by doing page-new if I am making a new data object, or by using obj-open if I am opening an existing data object into page “mypage”.
/Eric
Pegasystems
US
Uh oh. If I said already-existing-value, I apologize. (Where did I say that ?) The pages-and-classes declares what class such-and-such a page will be, when and if such-and-such page gets created. The pages-and-classes tab makes no inference of whether the page exists, and makes no inference whether the page will be created or not. /Eric
Centene
US
I may have misread your initial comment of
Pages-and-classes merely describes some pages, it doesn’t create them, and it doesn’t define them.
I took "doesn't create" to mean, "this is not creating a new instance, but merely referencing existing" when I posed the "which does this do - reference or instantiate?" question. Sorry if I mis-characterized your answer...thanks again
Pegasystems
US
Hi Jim,
My experience with pages-and-classes is that first, as I partially mentioned, it often assists with showing property name choices when you type either a page name or a non-scalar property name (i.e. an embedded page or page list), and then type a dot.
Secondly, there are times that I've gotten validation errors when I tried to save my activity and only by adding some of the embedded property names to pages-and-classes, was I allowed to successfully save the activity.
I suspect, although I've never proved, that the contents of the pages-and-classes tab would affect both of the above, but would not actually affect the generated java for the activity. Is this true ? One way to test examples is, on the activity rule form, click the coffee cup icon (or the java choice in the action dropdown for later Pega versions, which are you on again ?), and do that twice once with and once without pages-and-classes entries, to see whether the java is any different. /Eric
Pegasystems
US
Initially It's clear that "Pages & Classe"s help Pega limits what data to retrieve from memory AKA the clipboard.
However two uses of "Pages & Classes" start blurring the lines.
1) When an Activity creates an object / "Page", it's required to create an entry in the "Pages classes for that object where the standard would be to define a local variable.
2) Often report definitions contain entries with a class name and a blank page name.
Centene
US
Marc
Marc MouriesYou've definitely identified one of the more confusing areas. What on earth does the line with the blank page name mean? Is that similar to a traditional language's "using" statement?
Pegasystems
US
Regarding reports that have a class name but no page name in the pages-and-classes tab. I’m guessing that the lack of page name means “the primary page”. However, if it does, that needs to be documented ! (maybe it is already ?)
/Eric
BNY Mellon
US
re: "Initially It's clear that "Pages & Classe"s help Pega limits what data to retrieve from memory AKA the clipboard."
It's clear? to whom? What are you basing this on? The Pages & Classes are not represented in the generated Java -- unless you're creating a page with Page-New, and you didn't specify the classname in the method parameters, so it's pulled from P&C.