Thursday, September 17, 2009

Redirects for APEX Tabs instead of page submits

With APEX Tabs you may not want the page to be submitted each time the user clicks on a tab. If you look at the link for the tabs they look like: javascript:doSubmit('xxxx'); Where "xxx" is the name of the tab. "doSubmit" will submit the page and could trigger page computations, validations, and processes. If all you want to do is use the tabs as a form of navigation (i.e. when you click on a tab it redirects to another page) then this could cause some problems.

To avoid triggering Page Processing on tabs you can modify all the conditions on your Page Process (this could be very long) or change the link. They're multiple ways to change the links, here's a simple one using jQuery.

Here's a link to the demo: http://apex.oracle.com/pls/otn/f?p=20195:2500. Note, in the demo I don't trigger the javascript to change the link automatically so you can see what they look like before and after changing the links.

- Create an Application Process
Note: You may want to only apply this to certain pages depending on the use case

Name: AP_UNSUBMIT_TABS
Process Point: On Load: After Header

BEGIN
FOR x IN (SELECT tab_name,
tab_page,
'' tabinfo
FROM apex_application_tabs t
WHERE application_id = :app_id)
LOOP
HTP.p (x.tabinfo);
END LOOP;
END;


- Create a HTML region
Note: You'll need to install the jQuery JS file in Shared Components / Static Files




6 comments:

  1. Hi,
    I want to know how to replace the JS in APEX 4 (theme 2) tabs to URL based tabs, could you please let me know how to do it in more details.

    Thanks,
    Fadi.

    ReplyDelete
  2. Hi Fadi,

    You can use the same technique that I described above to apply to the APEX 4.0 theme 2 tabs. Of course you could develop a plugin to do this as well.

    Unfortunately I'm a bit tied up with other things to write out the full solution for you now.

    Martin

    ReplyDelete
  3. The demo doesn't work.

    ReplyDelete
  4. Since the time of writing this post, a lot has changed in APEX. Unfortunately I won't be supporting pre-APEX 4 blog posts as so much has changed since then.

    Martin

    ReplyDelete
  5. How can I pass parameter values from a tab page to another tab page?

    ReplyDelete
  6. Hi Shahadat,

    You'll probably want to submit the page instead of using tab redirects. By submitting the page the page items will be saved.

    Martin

    ReplyDelete