How to submit the value in an inputtext field by setting autoSubmit to false - validation

I have an ADF form based on a VO and I need to check whether a particular field is null or not on click of a Submit button. For this, i set autoSubmit to true and get the value entered to a variable in my bean.On click of Submit button , i check if the variable is null or not and display error faces message if the variable is null. But how do i get the value entered in the form to a variable in the bean with autoSubmit set to false?

Why do you have it turned on in the first place? And why do you want to turn it off? Are you clear on it's functioning and why to use it?
Autosubmit is used to support Partial-Page Refresh.
If you don't need PPR, Just turn it off. The value will still be available once the submit button is pressed. Read about it here.
An input component that has its autosubmit property set to true also
performs a partial submit of the form. However, this time it doesn't
submit the entire form but only the component that triggers the submit
plus components referenced it in their PartialTriggers property.
Autosubmit is not required to access values entered into input components on the screen. Autosubmit submits only the field and also bypasses certain phases of the page processing lifecycle.
if you turn autosubmit off, the entire page - all the fields - is submitted and goes through the complete page processing lifecycle, so you have access to all input fields.
Docs here.

Related

p:messages with autoUpdate disappearsafter value change listener triggered

We have global p:messages defined in tempate with autoUpdate set to true.
This is the place where we are shwoing all the messages from included content.
On one of the pages we have panel with save button. User fill in some fields and after succesfull save we need to:
1. Display succes message
2. Fill in automaticly other fields on same page based on saved data
So in the bean we are adding FacesMessage , set data based on saved object and rerender those other fields.
Unfotunatly those fields have some value change listeners attachted to them. So we end up with two ajax requests. First from the save button and second from the value change listnerer defined on one of the auto filled fields. The result is that succes message appear for short amount of time (it dissapear after second ajax). How can we keep this message after second ajax without setting auto update on messages to false?
Thanks for any adivce.
P.S. We are using primefaces 3 so ignore autoUpdates is not an option :(

APEX: Call JavaScript function after validation but before processing

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.

Selected Dropdown value changes when validation fails-ASP.NET MVC

I am using MVC 3 with ASP.NET. I have a dropdown box and getting it populated from database. I am using validation on the View. If it fails the validation, I am displaying the same view with errors being caught in ViewDate.ModelState.AddModelError.
I am checking for the ViewData.Modelstate.IsValid property if true then execute the code else display the errors in the view.
It is diplaying the errors in the page, but the selected value in the drop down is getting reset when validation fails.
How do I make sure the seleceted drop down does not change when validation fails?
In the action that handles the form submission and validation, make sure you set the properties on your model object from the form before rendering the form view.
For example, in this question you can see how the Dinner object parameter in the Create action is reused when the View() is returned.
Set a breakpoint in the action handling the submission and check the property for the list of values. If it's null or empty reload it.
If your dropdownlist is being populated via javascript then it is possible that the property holding the list of values is empty on submission. This is common when using cascading dropdownlists such is the case with loading Province / State lists based off country. All cascading lists loaded after the model has been passed to the view must be reloaded using the selected value of for each dropdownlist in the controller action that is handling the submission.

ASP.NET MVC 3.0 - User Hammering Submit Button

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.

Can a CRM 3.0 PreCreate callout fill form fields in advance?

I just finished my first CRM callout, and it's working great, but it doesn't actually seem to take effect until the form that calls it is saved. It's a PreCreate deal that assigns a value to one of the attributes present on the form. Is there any way to get it to assign the new value and display it on the form as soon as you load it, or is this just the way it works?
You'd have to add some JavaScript to the onload event of the form and default any form fields that way. Callouts don't fire until after the save event happens, so they can't be used to default fields in the UI.

Resources