Thursday, February 26, 2009

Oracle Apex templates - not just for HTML

Have you ever considered using templates for generating something else besides HTML? You can use Apex templates to generate all sorts of things - XML, javascript and JSON to name a few. The tree panel shown gets all its data from a list template. See it in action, and the template details on my demo.

5 comments:

Anonymous said...

its very nice
http://apex.oracle.com/pls/otn/f?p=200801:1:3300030161566301::NO:::

link
is extjs opensource, you did grt job... can get its source code
please mail me chanchalsakarde@gmail.com

Claudio said...

Very useful example Mark, I take it for my apps! ;)

A little question...what about hiding child leaf, using the standard security ApEx functionality?

Mark Lancaster said...

Hi Claudio

Yes, as mentioned in the demo instructions:

The biggest advantage of using lists and list templates is that you can use the built-in Apex "Conditions" functionality to hide or show list items.
I use this in my workplace to "customise" the tree based on a users role based privileges.

A second advantage is the tree data is part of the Apex application export, which means I don't have to remember to migrate data in application tables.

Anonymous said...

Mark...

You mentioned above "I use this in my workplace to "customise" the tree based on a users role based privileges." about the built-in condition functionality of the lists to display or hide different items in the list.

I am attempting the same thing with my ExtJS menu generated from a JSON-templated list and each time I assign an authorization to a child entry of a parent, the entire menu disappears. When I remove the authorization, the menu displays properly. It seems this only happens when there is suppose to be children, but the authorization hides the children. I am on version 4.0.2 and welcome your comments.

Shane.

Mark Lancaster said...

Hi Shane

Two approaches can be used:

1. Add a hidden node in the branch template to ensure a branch always has at least 1 child node.

2. Add conditional logic on the branch, to only display if user has privileges to one or more authorized child nodes.

I've used both techniques, and tend to prefer the second. You can cache results in collections for the session if the authorizations don't dynamically change within a session.

The APEX team rewrote the list functionality in APEX 4.1, correcting some of their logic. You will need to revisit your templates when you upgrade.