Oracle APEX: Issues with doSubmit

282 Views Asked by At

I have a conditional hyperlink column in my IG:

SELECT CASE WHEN t1.active = 'No' 
            THEN t1.active
       ELSE
            '<a href="#" onClick="javascript:$s(''P1_SELECTED_ID'','''||t1.ID||''');doSubmit(''REQUEST1'');"><button>Run</button></a>' END IsActive,
       ID as ID
FROM Table1 t1

I cannot use regular Link column as not every row will have it so I have to generate it using HTML in my select statement.

I have a process on my page to be executed when that button in the grid is clicked that has a server-side condition Request=Value and a value is set to REQUEST1. Now the process never executes and when debugging I saw that the process is skipped because condition or authorization evaluates to FALSE. Does it have something to do with how I pass request value as an argument to doSubmit?

2

There are 2 best solutions below

0
On

I cannot use regular Link column as not every row will have it so I have to generate it using HTML in my select statement.

Couldn't you leave the link value empty in that case?

I added this new column to my query:

CASE IS_ACTIVE
    WHEN 'Y' THEN PROPERTY_NAME
    ELSE NULL
    END AS active_link,

Then I defined the link for my new active_link column with:

  • Type URL
  • URL: mailto:&ACTIVE_LINK.

Apex figured out that when my active_link column is NULL, don't show a link.

That seems a lot simpler than the alternatives above.

3
On

Here is a possible solution (on emp table) using css to for rendering and dynamic actions to set the value and submit the page. Functionality is that for all employees except manager a button is rendered (change it to a link if you want, but since it doesn't really link but submit maybe a button is more appropriate). For the manager some text is rendered in a span.

  • Create IG on emp table
  • Use following source query:
select EMPNO,
       ENAME,
       JOB,
       MGR,
       HIREDATE,
       SAL,
       COMM,
       DEPTNO,
       CASE WHEN MGR IS NULL THEN 'none' ELSE 'block' END AS DISPLAY_BUTTON,
       CASE WHEN MGR IS NULL THEN 'block' ELSE 'none' END AS DISPLAY_TEXT
  from EMP

Set columns DISPLAY_TEXT and DISPLAY_BUTTON as hidden

  • Add an additional column "Button" of type "HTML Expression" with Settings > HTML Expression:
<button style="display:&DISPLAY_BUTTON!ATTR." type="button" data-ename="&ENAME!ATTR." class="my-button-js t-Button t-Button--tiny t-Button--success">My Button</button>
<span style="display:&DISPLAY_TEXT!ATTR.">&ENAME!HTML.</span>

Info: this is the markup for a button and a span. Based on the value of the DISPLAY_BUTTON and DISPLAY_COLUMN columns only button or span will be shown. There is a class my-button-js to serve as jQuery selector and the data-ename is the dataset property containing the data for the row.

  • Create a page item P132_ENAME to hold the value being set on click of button.

  • Create a dynamic action on click

    • Event scope: Dynamic (needed to handle pagination or refresh of report)
    • Selection Type: jQuery Selector
    • jQuery Selector: .my-button-js
  • Action 1: Set Value

    • Set Type: Javascript Expression
    • Javascript Expression: this.triggeringElement.dataset['ename']
    • Selection Type "Item(s)"
    • Item(s): P132_ENAME
  • Action 2: Submit Page

    • Request/Button Name: REQUEST1