• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1437
  • Last Modified:

APEX: Tabular Form Validation on click or tab

Instead of pressing update every time i change the values of a field, I would like an update to happen everytime i TAB out of the field or click the next field..


is this possible? if so can someone point me in the right direction
0
futureDBA
Asked:
futureDBA
  • 10
  • 8
1 Solution
 
gatorvipCommented:
You can do this via JavaScript or Dynamic Actions, but in either case you'd have to associate the event with your field(s). If you have multiple fields to which you'd want to apply this behavior, you'd probably want to modify the field template.

In either case, you'd associate the event with a PL/SQL process.
0
 
futureDBAAuthor Commented:
can you please point me towards proper documentation to get somethng like this going.. another scenario that would work for me is a report that auto updates every 2 or 3 seconds
0
 
futureDBAAuthor Commented:
Anyone?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
gatorvipCommented:
1) Javascript

You will have to add an event to the field's properties. Depending on what you want  to happen you may use onExit(), onClick(), onChange(), etc. You associate this event with a JS funtion, which you then define in the page (or region) header.

Then, in the region javascript function called above, you'll have something like this:

var request = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=<your_process>',0);

There are many links & examples for calling processes in JavaScript:
https://forums.oracle.com/forums/thread.jspa?threadID=380446
http://apex.oracle.com/pls/otn/f?p=11933:180
http://anthonyrayner.blogspot.com/2007/06/ajax-retrieval-using-javascript-object.html
http://www.dba-oracle.com/t_html_db_apex_ajax_application_express.htm

2) Dynamic Actions will be similar, but they're a new(er) concept
http://st-curriculum.oracle.com/obe/db/apex/r40/apexdynactions/apexdynactions_ll.htm
http://dgielis.blogspot.com/2010/01/apex-40-dynamic-actions-part-1.html

If you have many page items that you want to update, neither one of these methods is likely to be efficient. In that case, I would advise just having a single page process that performs the update (assuming the default APEX methods are not sufficient) and you just call the process via a page button.
0
 
futureDBAAuthor Commented:
I have understood that so far, and had already visited some of the links you posted. i appreciate it, I was trying with dynamic actions but I am doing something wrong,

I am interested in going the JS route, can you clarify one comment you made please.

"will have to add an event to the field's properties. Depending on what you want  to happen you may use onExit(), onClick(), onChange(), etc."

Where do i add an event to a fields properties...

Thanks in advance
0
 
gatorvipCommented:
Open your field properties, then in the Element section you'll see HTML Form Element Attributes. In there, add your event that calls a JS function.  For example:

onchange="call_js_function(this); "

Open in new window


or

onchange="call_js_function(); "

Open in new window


(depending on whether you want to pass the field as a parameter).
0
 
futureDBAAuthor Commented:
the problem is that i dont have a traditioanl form... i have a tabular form on a report, this does not have an element section at the field level
0
 
gatorvipCommented:
In that case, you should be able to open the column definition and call the function from Element Attributes. You will definitely need to pass the field as a parameter and probably a rowid or some other sort of key value.

It's not trivial, but not terribly difficult, either.
0
 
futureDBAAuthor Commented:
kind of is difficult when you have limited experience with calling dynamic actions with apex.. i will continue to work and see if i can figure it out on my own, everything i have done thus far has been a failure
0
 
futureDBAAuthor Commented:
when ever you have a chance, please look at my screen shot for a dynamic action and if you can see anything wrong that you can point out, id greatly appreciate it..

as of now, when i make a change and onfocus the field (whether through tab or click on next field)

the page submits but it does not update
0
 
futureDBAAuthor Commented:
0
 
gatorvipCommented:
My previous post was for the plain javascript action. For DAs it's also not too bad, you just need to assign class names to your columns. Take a look at these examples:
https://forums.oracle.com/forums/thread.jspa?threadID=2245343
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/devdays2012/apexp2_lab/apexp2_lab.html
https://forums.oracle.com/forums/thread.jspa?threadID=2317703
http://monkeyonoracle.blogspot.com/2010/07/dynamic-actions.html

The idea behind them is the same - an action within your tabular form will trigger some sort of event.
0
 
gatorvipCommented:
the page submits but it does not update

You don't want to submit the page, though. You want to call a page process that performs the update, unless I misunderstood the OP.  So create the page process, then call that in the DA.
0
 
futureDBAAuthor Commented:
can i call an existing button from a DA?

I already have a button that does the multi row updates, which is called from a process that was automatically created when the tabular form was created
0
 
gatorvipCommented:
yes, assign it a class name then call the class name in the DA (via the JQuery selector). See this post for an example
0
 
futureDBAAuthor Commented:
thanks, it's now semi working..

The problem that I am having now is that I am loosing focus on update.

so lets say i go to field 1 and make a change, when i press tab. it auto updates, but I cannot press tab again, I have to click on the following field to get focus again.
0
 
gatorvipCommented:
I believe the default behavior of Tab is to move to the next focusable field, so that makes sense. If you want to explicitly set the focus on a specific field, you might need to write that step. JQuery has a focus() funtion that you can use:

http://api.jquery.com/focus/
0
 
futureDBAAuthor Commented:
the thing is, im not using jquery at all.. with apex 4.1 you dont have to write a single line of code  be able to submit on change
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 10
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now