Showing posts with label Dynamic Actions. Show all posts
Showing posts with label Dynamic Actions. Show all posts

Monday, February 22, 2010

APEX 4.0: Dynamic Actions - Part 2

If you are interested in a Standard Dynamic Action in APEX 4.0, you should read this blog post.

In this post I'll cover how to create an Advanced Dynamic Action. 'Advanced' allows you to create more complex native dynamic actions such as 'Add Class' or 'Set Value' and also plug-in dynamic actions, that are installed in your application.

In this example I want to retrieve the department for a given employee.

In the Application Builder you find a new region (tree record) called "Dynamic Actions". Right click on that and click Create


In this post we select Advanced, as we want to create an Advanced Dynamic Action, that does more than just show/hide or enable/disable.


Give the dynamic action a meaningfull name e.g. Refresh Employee List

Tell the dynamic action when it needs to fire. In this case I want that something happens whenever I change from Employee (P25_EMPNO).


Select the action you want to do. In this example I want to set the value of an item (the department) for an employee. The value can be retrieved in a number of ways, but in this case I search the department with a SQL Statement.


Finally you tell the dynamic action what item it needs to update. What you want to update can also be a Region, a DOM object or a JQuery Selector.


Hit the Create button and you are good to go! Not a single line of Javascript to get this done!
You see the example in action here.

If you want to combine different actions in one dynamic action, that is possible too. You can add multiple actions when the condition is true or false. (See True/False Actions)


There are many Actions you can chose from. If you imported or created Dynamic Actions plugins, you find them in there too.


Dynamic Actions are VERY VERY powerful and have an unlimited amount of possibilities. Although the above is classified as an "Advanced Dynamic Action" it's still a fairly simple example. In Part 3 I'll show how to combine plugins with dynamic actions to be even more powerful!

The key reasons why I like Dynamic Actions so much:

  • it's a declarative way of creating more interactive websites
  • it allows people without Javascript experience to create more dynamic websites
  • it allows more experienced people to get the job done faster
  • the dynamic content is more structured and always in the same format
  • the dynamic content can be found at one place, directly in the App Builder (not searching in different javascript files anymore!)
  • the javascript is more maintainable (and possible more performant and more secure)

Tuesday, January 26, 2010

APEX 4.0: Dynamic Actions - Part 1

So what is all that about Dynamic Actions in APEX 4.0?

Basically, before we had to write a lot of javascript to get things happening on the client. E.g. you wanted to show or hide a field or a region depending other values on the page.

From APEX 4.0 onwards we can do a lot of these things declarative (through a wizard).
You have two types of Dynamic Actions: Standard and Advanced.


This post will have a closer look into the Standard Dynamic Action. (Advanced will be covered in Part 2)


You will need to specify the selection type of the page elements that define when the dynamic action will fire. You can chose out of: Item(s), Region, DOM Object and JQuery Selector.
Depending the type you chose you'll see different things to fill in e.g. the item(s) or region name, the condition and value when the dynamic action needs to fire.
Next you specify the event type for the dynamic action. In conjunction with the triggering elements define in the 'When' region, this is used to define the actual event on the page that will cause the dynamic action to trigger.

So in the above example I want to fire the dynamic action when my P5_SELECT equals to Y and it looks for it whenever I change the select list.


Next you define what you want to do. In my case I want to disable an item when the value of the select list is N and enable it again when the value is Y.

Finally I told the dynamic action what field it had to enable/disable. You see it live here.

If you go back into the App Builder and look at your page (Tree View) you see the Dynamic Action below (if you still use the Components View it's at the end as well and the screenshot looks like the very first picture on top of this post).

You can still edit the Dynamic Action and configure it further.

I like Dynamic Actions a lot, it will definitely speed up development as it's just build-in now. Not a single line of javascript you have to write. Obviously we now did only a simple thing and you still need to test things if they do what you expect... I tried to Enable/Disable a button, but that didn't work yet, but like the above example with an item it worked like I expected.