Saturday, September 24, 2016

The good news for those who still missed using Oracle Apex with mod_owa https://oss.oracle.com/projects/mod_owa/dist/documentation/modowa.htm is that it works with Apex 5.

Since Oracle Apex 5.0 was released, people who tried to use this one had troubles with static resources support:



This means that any static application or workspace resource can not be received by browser.

The point is that application and workspace static files now have friendly urls that allows browser caching. The form of url is "apex_location/r/workspace/static/version/file_name". This is why two new parameters was added in dads.conf for mod_plsql https://docs.oracle.com/cd/E59726_01/install.50/e39144/http_server.htm#HTMIG29263:

 PlsqlPathAlias r
 PlsqlPathAliasProcedure wwv_flow.resolve_friendly_url


where "r" is a prefix for static resources and wwv_flow.resolve_friendly_url is a procedure that translates  a friendly URL of APEX resource to corresponding API calls.

Although mod_owa doesn't implement such functionality, it is possible to use combination of OwaDocPath and OwaDocProc parameters (see last paragraph of https://oss.oracle.com/projects/mod_owa/dist/documentation/modowa.htm#_future).

The difference between mod_plsql PlsqlPathAliasProcedure parameter and mod_owa OwaDocProc parameter is that procedure from PlsqlPathAliasProcedure receives p_path argument containing resource url, but, unfortunately, mod_owa calls OwaDocProc procedure without any arguments.

The solution is to create own wrapper procedure that provides proper wwv_flow.resolve_friendly_url call.

Step 1. Creating wrapper procedure. I recommend create it in any user schema different from APEX or other system schemes:

create or replace procedure get_static_resource  is
  /*
  Simple wraps wwv_flow.resolve_friendly_url for using mod_owa with Apex 5
  */  
  l_location                varchar2(30)  := '/apex'; -- equals to apache "Location" parameter,
                                                      -- change it according mod_owa location
  l_static_resources_prefix varchar2(30)  :=  'r';    -- equals to OwaDocPath parameter,
                                                      -- do not change
  l_url varchar2(200);
 begin
  l_url := substr(
    sys.owa_util.get_cgi_env('REQUEST_URI'),
    length(l_location||'/'||l_static_resources_prefix) + 1
    );
  wwv_flow.resolve_friendly_url(l_url);
 end;

create public synonym get_static_resource for YOUR_SCHEME.get_static_resource;
grant execute on YOUR_SCHEME.get_static_resource to APEX_PUBLIC_USER;


Note: mod_owa documentation tells us that OwaDocProc procedure call have six parameters, but in practice I did not see any parameters.

Step 2. Edit mod_owa configuration file to add OwaDocPath and OwaDocProc parameters:

AddType text/xml xbl
AddType text/x-component htc
<Location /apex>
    Options  None
    SetHandler       owa_handler
    OwaUserid        APEX_PUBLIC_USER/**********
    OwaNLS   RUSSIAN_RUSSIA.AL32UTF8
    OwaDiag  COMMAND ARGS TIMING ERROR
    OwaLog   /var/log/apache2/mod_owa.log
    OwaPool  20

    # Add this two parameters for Apex 5 static support
    OwaDocPath      r
    OwaDocProc      get_static_resource

    OwaDocTable     WWV_FLOW_FILE_OBJECTS$ BLOB_CONTENT
    OwaUploadMax 10M
    OwaCharset "UTF-8"
    OwaCharsize 4
    order    deny,allow
    allow    from all
</Location>


Step 3. Restart Apache. That's all. 

Monday, July 4, 2016

How to increase inline dialog size in Oracle APEX Universal Theme

There are three predefined inline dialog sizes in UT.


Sometimes developer needs inline dialog with custom sizes, for example, large than largest of theme predefined. If you use Universal Theme,  the simplest way how to increase inline dialog is to add some css to inline dialog region definition:

In this example 800 is required dialog width in pixels, 540 - height respectively.

Monday, February 29, 2016

Sometimes it is necessary to make some actions when user picks region selector tab, for example, refresh data in reports etc.
Ok, if your Apex version is 5.0.2 and higher and you use Universal theme,  one of solutions is using custom "rdsregionchange" event handler. The advantage of this way is that you provide reaction on user choice even when it made by keyboard without any additional dynamic action or javascript code.

Saturday, January 17, 2015

A few words about session timeout.
If the logic of the application does not require frequent reloading (submitting) of the page (for example, all information manipulating and retrieving are made using AJAX calls),  and the session has expired, the latest available at the moment version of Apex (4.2.6) does not behave as we would like. Partial page refresh leaves no error messages, except one thing: updated regions are empty. Quick look at the apex.server implementation gives the answer why this happens. Session expiration errors has not yet processed. If you take a look
at the body of the response to the POST request to region refresh , you’ll see a message about an incorrect password /user name in the body of the response, but it is hard to do something with it. Application developers are trying to solve this problem by using a plugin from SkillBuilders or something like that, or try to override apex.server for handling an ajax request error. Using the plug­in master­detail, you can also encounter this problem. One of the possible solution is the creation of dynamic action, which are looking for an empty region after the report refresh, and when it happens, reloads the page, then the user is automatically redirected to the registration page. 
So, if you use classic reports on your page, you can do following:
  • Create dynamic action on page load with "Execute Javascript Code" true action
  • Add  "Execute Javascript Code" "True" action with code like
  •  That's all.
The main goal is to look for a moment when after ajax call report region become empty. When it happens, plugin simply reload page and then APEX engine redirect user to login page.
Plugin works in application which utilize 26 theme. Other themes may require changing of  js code or jQuery selector.
 
Oracle APEX dynamic action plugin "Master-detail for classic reports" released. CÐūmments, bug reports are welcome. Demo https://apex.oracle.com/pls/apex/f?p=16415