Sunday, November 30, 2008

Redirection Process

In Application Express, it's not obvious how you would redirect to another page if the requested one fails an assertion. You can do so quite easily by creating a conditional 'On Load - Before Header' page process like this...
Where 'XYZ' is the page you desire to redirect to and the condition is the assertion fail state.

If you would like to display a message on said page you can set a hidden page variable in the process using v('PXYZ_VAR') := 'my message';. Then have an 'After Header' process on that destination page which displays the contents of the page variable if it's not null (use an 'item not null' condition to determine this). Here's the code that will give you a nice Apex style message...
apex_application.g_print_success_message := :PXYZ_VAR;
:PXYZ_VAR := '';
Simple as that!

Update: More details can be found in this follow up post.

No comments: