I am using the apex:inputField
to capture the values and and required="true"
to set some of the fields mandatory. However, for some buttons like cancel, I don't want it to check the required fields. If I am using apex:commandButton
I can use immediate="true"
to resolve this. However, since there are many things apex:commandButton
can't do I am using standard html and javascript. I find it hard to translate immediate="true"
as I saw no difference in the html when debugging. Any suggestions?
-
1Does this help? blog.jerryorr.com/2012/01/…– EricCommented Dec 1, 2014 at 0:37
-
In html-5 the formnovalidate=true is the equivalent w3schools.com/tags/att_button_formnovalidate.asp– EricCommented Dec 1, 2014 at 0:40
-
@Eric Thank you for the response. I haven't tried this thoroughly but I guess there is some difference. formNoValidate attribute is actually working on the client side and in my case, the page actually reloads before it populates error. So I am guessing it is happening at server side.– Lance ShiCommented Dec 1, 2014 at 3:53
-
1With pictures: JSF and the “immediate” Attribute – Command Components.– Keith CCommented Dec 1, 2014 at 9:22
2 Answers
There's no direct translation for the immediate attribute, because it only affects server-side validation. In essence, this attribute is evaluated early in the Visualforce transaction lifecycle, before any user-defined code can execute.
While there is a concept of client-side validation in html 5, there's no analogous concept in html 5 for server-side validation, because that's outside the scope of the language definition, and left to the developers of server-side execution, such as salesforce, to define those mechanisms.
As noted in the comments and @sfdcfox's answer, the "immediate" attribute affects server logic, and has no direct equivalent in HTML.
However, both actionFunction and commandButton support immediate=true. Have you tried calling an actionFunction (rather than just submitting the form) when you want the "immediate=true" support? Alternatively simulating a click event on a hidden commandButton? Either of those should have the effect you are looking for.
-
Thank you for that. I am actually using actionFunction. That will save me some time in implementing this. One thing I am concerned is whether we need to go to server side to verify the mandatory fields though. However, it doesn't seem to be too bad. Commented Dec 1, 2014 at 6:32