I know that all validations get executed on Page Submit, but i have actions defined on page submit which i want to be executed first followed by the validations, ie decide the execution options for these dynamic actions to be executed first and then the validations, because right now my validations don't seem to work.My dynamic actions are defined in function and global declaration as $("#submit").click( function (){ })
Don't override events in Javascript. I forget, but you may interfere with how Apex handles them. What you want to do is:
Set your button's action to be Defined By Dynamic Action
Create a Click Dynamic Action on your button
Add a True event for whatever it is you're trying to do
Your final True event should be Submit, with an appropriate Request value
If your Validations are not executing correctly, turn on debugging mode and look in the debug log for why they're not working.
Related
I have an Oracle APEX page that has a dynamic action which hides some fields at page load time, that are then made visible via other dynamic actions as the user interacts with fields on the page.
If the user submits the page with validation errors, the page reloads and it appears the dynamic action is being executed again and fields which have been filled in and should now be visible are being hidden again.
I'm wondering if I can make the page load dynamic action conditional so that it executes only when the page is not being rendered as a result of a validation error?
Many thanks for any assistance!
It appears I've found the solution.
One of the conditions available for whether the dynamic action gets executed is "No Inline Validation Errors Displayed".
Selecting this for the dynamic action that hides controls at page load effectively forces it not to run when validation errors are encountered.
Thanks to anyone who gave this some thought! Also, if you have any other helpful hints on effective validation with dynamic actions, I would be very interested in seeing them.
I have a wicket page with a couple of TextFields that have different kind of validators. So far, validation is triggered via Ajax on the onChange event.
I also have a checkbox that defines which set of validation rules should be used for the TextFields.
If I click the checkbox and then input data into the TextFields, validation works just fine. But how do I handle the fact that already entered and validated data can suddenly become invalid if the checkbox is clicked afterwards? How do I trigger the validation and the redraw (to show the error notification) of the TextFields from within an AjaxEvent from the checkbox?
I tried to call myTextField.validate() but that didn't trigger any of my validators.
Since your validation is based on multiple components you should implement IFormValidator. Pass both checkbox and textfield in getDependentFormComponents() and change of either will trigger it.
Also if you are using checkbox to refresh some elements make sure to use AjaxCheckbox, that has onUpdate(AjaxRequestTarget) method.
You could attach an AjaxFormSubmitBehavior in the checkbox. This would submit the form and trigger validation each time the checkbox value is toggled.
Is it possible to have multiple actions for the action attribute of h:commandLink tag? I want to perform two actions while clicking on the link rendered by h:commandLink tag. An action needs to be performed in a Spring bean, and a pop up window displaying a certain webpage.
No, it is not possible to call two methods in action attribute. And I don't think this is major disadvantage. Encapsulate logic in one method in managed bean, and call those to actions from that method.
No, it's not possible to have multiple actions in a commandLink action. If you want to perform some logic and to display a pop up window just wrap your logic in a single method, and at the bottom add a FacesMessage to the the context. You can do an AJAX partial refresh of the h:messages component to show the message as a "pop up" without reloading the page.
I have been tasked with re-creating an old PL/SQL Web Toolkit front end in Application Express (Apex).
I would like to display a popup after the page is submitted and after computations and validations.
The page can be submitted by clicking a button OR by hitting enter.
I have googled and got a modal popup working (called by javascript) but I can't seem to call it at the right point. I can call it on submit (before the validations etc.) but not after the validations.
I have tried creating a branch to URL at the correct processing point and then have the URL set to:
javascript:openForm();
But then I get a page will not display error.
Can anyone out there explain how I could do this?
Apex Version: 4.0.2
Oracle 10g
I suppose what you want to do is to perform the validations, have values submitted to session state, but not execute further processes.
However, when you submit the page it is sent to the server; and everything you see in the page processing region will sequentially fire. There is no way to halfway through the processes call a javascript function, since basically you are not on the clientside anymore.
What you can do is to create a branch after your validations to the same page. Redirect to it but provide a REQUEST value, for example OPENFORM.
Create a dynamic action, firing on page load, with a true action that executes javascript and opens up your modal page. Then set the condition on your dynamic action to Request = Expression 1, providing the request value to Expression 1 (OPENFORM).
(Note that this is the Conditions region, and not the 'Condition' field of the 'When' region)
This should cause the page to be submitted, validated, then re-loaded but with a request value, and the dynamic action firing, opening your modal page.
Just a point of interest:
If you have actual processes on this page though, then be careful with the Enter key. Buttons by default submit to session with the request value set to their name, and thus making it possible to conditionally execute processes or branches. The enter key does not submit with a request value set i believe. So if your branch is conditional, the enter key might simply skip over it.
Even using the Post/Redirect/Get method, and including javascript to disable a button after it has been clicked, I am having a problem with users being able to just rapidly hammer a submit button and get multiple form posts in before server side validation can stop it.
Is there any way to stop this? I've even tried this method : how to implment click-once submit button in asp.net mvc 2?
And I've tried outright blocking the UI with jquery blockUI. I have BOTH client side and server side validation in place, and they work perfectly - but a user smashing the submit button twenty times in under a second just seems to keep breaking it.
Use javascript to wire the onclick event to disable the button.
If you are already doing that and you can still get multiple form posts, then the problem is a delay between the clicking of the button and the button being disabled, and you must be submitting the form multiple times during this delay.
To fix this, make the onclick event first make a call to stopPropagation() to stop the submit event. Then validate that the form is not in submission-blocked state. You can do this by creating a page-scoped javascript variable with a boolean value like can_submit. Test for can_submit being true before submitting the form. Set the can_submit = false when the button is disabled, so even if the button is not disabled fast enough, the form will not submit if the value has already been set to false.
In most cases I'd say that this isn't worth fixing - if a user is going to do something as silly as clicking submit 20 times they should expect to get an error.
The only real fix for this is to set up your action to only accept the same form once - add a hidden field that is set to a random value when the form is loaded. When the form is posted, save that value somewhere temporarily and if it is already there you have a duplicate request that shouldn't do anything.