This discussion is archived
7 Replies Latest reply: Jun 26, 2013 5:55 AM by TimMc RSS

On Demand ARF for simple form?

user1007 Newbie
Currently Being Moderated
I have a page with HTML region containing one LOV with list of table PKs,
and also a form region with items that are supposed to contain table data.
Apex 4.1;
What I need: when LOV value is changed the form region should fetch a data matching PK value in LOV.
Actually, it is a simple master-detail.
How this could be implemented?
What I have tried:
Created ARF process using wizard ; name: FORM_FETCH; Point: On Demand; I provided table name, PK item name and PK column;
I also created Dynamic action for my LOV 'on Change', with 2 Actions:
Set value and Execute java Script code.
First action sets PK item in form region to the value in LOV field;
Second action executes this code:
var get=new htmldb_Get(null,null, "APPLICATION_PROCESS=FORM_FETCH", &APP_PAGE_ID.);
var gReturn = get.get();
get=null;
When I run the page and change LOV value, I am getting strange error message in 'Alert' window:
sqlerrm:ORA-06550: line 1, column 8:
PLS-00103: Encountered the symbol "|" when expecting one of the
...(etc)

I found that this message is generated at the line
var gReturn = get.get();
It is also related to FORM_FETCH process, not the java script code above;
when I created another on demand process of PL/SQL type with simple 'htp.p('!')' code inside, named it 'TEST' and changed AJAX call above to "APPLICATION_PROCESS=TEST" everything runs perfectly.
But my ARF process was created through the wizard, and it does not contain any explicit code, so it cannot be that I made some typo in process creation.
Moreover, even if I enter some wrong table name or PK column name in FORM_FETCH process definition, I am still getting the same error message, which means it even does not try to start running the process.
Am I encountering some bug, or is there a limitation that ARF process cannot be called on demand?
And am I at least trying to achieve my goal in correct way or there is some better approach?

Edited by: user1007 on Apr 5, 2013 11:32 AM
  • 1. Re: On Demand ARF for simple form?
    Rossi Newbie
    Currently Being Moderated
    Hi

    What about do a dynamic action with a SQL Statement or PL/SQL function body with to fetch this datas on your field instead of an on demand process ?

    Edited by: Rossi on 05/04/2013 16:41
  • 2. Re: On Demand ARF for simple form?
    InoL Guru
    Currently Being Moderated
    I don't have an answer to your problem really. I tried something similar before, but couldn't exactly work it out (yet).
    or there is some better approach?
    I do have a suggestion (maybe not better, though). Instead of the form region, create a tabular form region and just fetch one row. This type of region can use partial page refresh when the LOV is changed. Here is an example with a tree, but this can be changed to an LOV instead.
    http://sqlcur.blogspot.com/2013/03/apex-tree-and-form-one-one-page.html
  • 3. Re: On Demand ARF for simple form?
    TimMc Newbie
    Currently Being Moderated

    The "On Demand" AJAX call appears to be failing because it expects the PROCESS_SOURCE of an Automated Row Fetch process to contain PL/SQL code and not whatever this is:

     

    F|#OWNER#:FORM_FETCH:P10_ID:ID

     

    The above PROCESS_SOURCE can be found in the tree view of Page 10 by hovering the FORM_FETCH AJAX Process or by running the following query:

     

    SELECT *
     FROM apex_application_page_proc
    WHERE process_point_code = 'ON_DEMAND' AND process_type_code = 'DML_FETCH_ROW';

     

    It'd be nice if someone could fix this... or if the code for interpreting the above ARF PROCESS_SOURCE could be exposed so that we can create an PL/SQL AJAX On Demand process that does the same thing without failing.

     

    Tim.

  • 4. Re: On Demand ARF for simple form?
    Tom Petrus Expert
    Currently Being Moderated

    The ARF simply doesn't work this way. Calling it on demand would never set the values of items on the client side. It sets the session state of the items during the render process, but that state is not retained. So even if you did run it through ondemand and it would work, you'd have nothing.

    Aside from that, why are you trying to do this? When I read your page setup I take it to be a master-detail form, where the master has a select list. Selecting something from the select list will show the master record data. Why not just use a submit/redirect to have the page rendered with what you need?

  • 5. Re: On Demand ARF for simple form?
    TimMc Newbie
    Currently Being Moderated

    It's a bit painful to have to switch between pages all the time. It'd be nice if pages were more responsive in APEX.

     

    For example:

    • Take an Interactive Report
    • Click "Edit" in one of the rows to show a region that allows you to edit that row.

     

    Even better:

    • Click edit and convert the row into a bunch of form fields.

     

    So ARF is the wrong tool for the job and should just be reserved for basic point-and-click pages...

     

    Tim.

  • 6. Re: On Demand ARF for simple form?
    Tom Petrus Expert
    Currently Being Moderated

    Yes, ARF is the wrong tool for this kind of job. It's not that there are no alternatives, but they will always involve javascript. I love me some javascript, but if someone is relatively new to apex and/or javascript then they should very simply not consider these as options unless they very well understand it will be a learning experience or experiment, not a 100% foolproof gateway to a solution.

    Having said that, I believe there are plenty of options of making apex pages more responsive, but of course it will always depend on requirements and the datamodel and architecture.

    You mention the edit of an IR row in a region. I have implemted this several times over now by using the modal page plugin. It is easy to implement, looks good, avoids the page switch, and allows you to leverage the apex architecture.

    As for that multirow editing, maybe in apex 5.0.

    Bascially though, you can make apex as responsive as you want, if by responsive you mean plenty of ajax. Just not so much out of the box. It'll cost you time and requires a good deal of skills in all technologies involved in my opinion. That's why I'd recommend to think twice about a solution or route you want to go down to. Don't try to break the mould where it makes no sense etc. I understand the concern, but then again that's just how it is at the moment. Be creative in your solutions, but don't push it unless you need/want to.

    No critique, just saying.

  • 7. Re: On Demand ARF for simple form?
    TimMc Newbie
    Currently Being Moderated

    I'm trying to stick with standard APEX features so that it's easier to support if/when other developers build upon the existing application. On the other hand, I don't want to compromise usability.

     

    I appreciate your input and feedback.

     

    I'll write a page process to return JSON for the form to use after clicking "Edit" and I'll get the users to decide between a modal popup and displaying a form above the IR.

     

    Tim.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points