Question
Laura Cavanaugh · Aug 15, 2016

Inheriteing a zen page from another custom zen page -- best practices

Hello,

Has anyone encountered or done this: inherit a zen page from another custom zen page?

e.g. EditPage extends %ZEN.Component.page

///base code, some abstract methods

Property id;

 

UserEditPage extends EditPage

//user edit code

Property id As %String [ZENURL = "ID];

 

 

I'd like to take advantage of the inheritance and put all the common methods in the parent page EditPage, but there's no %OnNew concept for the zen page, so I can't set properties for each child page when first creating it.  

Perhaps %OnBeforeCreatePage?  %OnAfterCreatePage? I don't see any examples of extending a custom page in the SAMPLES namespace.

 

Thanks,

Laura

 

What are the best practices for inheriting a page

0
0 272
Discussion (4)1
Log in or sign up to continue

I have always overridden %OnNew(); have you tried it?

Yes, but since "there's no %OnNew concept" for a class that extends from %Zen.Component.page, I can't use it.   looks like %OnCreatePage could be used.  Too late for me though.  The code is already written, so I have to work around some things.

hi Marco,

Looks like that's what we are doing.  We have at least 4 pages in the heirarchy, and the top page inherits from %ZEN.Compone.page.  I'm not sure why it works, but our XDATA is not overwritten by the child classes.  The parent pages have the logo and the menus, etc, that are on all the pages.  Each child class has its own XDATA stuff on it too.

 

I wanted one more level of page, that contained methods as well, that child pages would use.  These methods would be run on all events, but with the child page's properties, such as "page name", or "table name".  

 

So for example I wanted a parent page with data entry capabilities to edit dictionaries.  Each child page would contain the dictionary table name and its own Save method, but most of the other methods are the same.

 

Anyway, it's too late to re-write all the pages; I was just wondering what would be the best way in the future.