APEXblog.nl - Tips and Tricks

About This Blog:
I (Richard Weug) started this blog primary for myself to save all kinds of Apex tips and tricks in one place. To use it as a place to write down how I used some coding in my own projects, but also to copy and paste all kinds of articles I find on the Internet. (So I never have to wonder on what website did I read about??? When I see something interesting I collect the content so I have my own archive/knowlegde base.

View my profile on LinkedIn


Tips & Tricks


Refreshing a tabular form

Written by Richard Weug. Posted in Tips and Tricks

Today I encountered some difficulties refreshing a tabular form without submitting the entire page. The data displayed in my tabular form depends on the value of a select list (nothing more than a parent-child relation). If you don’t know where I am talking about, please check out following example.

I started off with the implementation of some JavaScript code to push the selected value into session state. This allows me to use the select list item in the WHERE clause of my tabular form source query. Altering the session state of an APEX select list item can be easily achieved by performing an AJAX call. An example – put the below code in the “Function and Global Variable Declaration” text area which can be found in the page attributes:

1 function setSessionState(pItem) {
2   var get = new htmldb_Get(null, &APP_ID., 'APPLICATION_PROCESS=dummy', &APP_PAGE_ID.);
3   get.add(pItem, $x(pItem).value);
4   gReturn = get.get();
5   get = null;
6 }

Make sure to add an onchange event to the select list item so that the above JavaScript function is being executed. To do so, fill in the “HTML Form Element Attributes” field: onchange=”setSessionState(this.id)”.

The next step is to create a dynamic action that fires whenever the value of the select list changes. This dynamic action includes one true action which refreshes the tabular form region. Have a look at the screenshots below to clarify any possible uncertainties.

the dynamic action settings

the dynamic action settings

the true action settings

the true action settings

Now, I thought that this would do the trick since I have used this technique before to refresh interactive and SQL reports. After a little test I noticed that my tabular form didn’t move a thing whenever I changed the value in my select list. What could have possibly gone wrong? I figured out that the session state of my select list item was being set correctly which implies that my dynamic action gets fired.

After some sniffing around, I ran across the tabular form attribute “Enable Partial Page Refresh” and its default value “No”. PPR allows you to refresh the report region when paginating forward and backward in your result set, without the need to refresh the entire page. This attribute must be enabled in order to successfully refresh a tabular form with a dynamic action. So simply changing the PPR attribute to “Yes” solved my issue here.

Original article was published on: http://apexplained.wordpress.com/2012/03/31/refreshing-a-tabular-form/