RE: Liferay form not getting submitted after clicking submit

Ragvendra Singh, modified 6 Years ago. New Member Posts: 2 Join Date: 7/29/19 Recent Posts
Hi Team,

I have created a form using aui:form tag. In form, i have several fields like URL, Hostname , Query operation, EMAIL address,etc. which are of type text.For every field , i have written  custom validation like URL should be valid, URL is mandatory.  Custom validation is written on almost every field in the form. Likewise i have some 25 fields. For few fields i have written server side validation using AJAX.When i click submit, form gets submitted intermittently. Sometimes page information is saved on server but sometimes page is stuck and nothing happens. I am using liferay 6.2 , tomcat 7 , Java 8.

Appreciate your help!
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hi Ragvendra,Code is always helpful with these kinds of questions and can also make finding the solution a little faster. If you can share it. please do. In the mean time, everything you describe sounds correct. My first reaction is that validation is failing sometimes, maybe the calls to the server, and so the form is not able to submit because it thinks there is a "failed" state when maybe there isn't? Without the code though, it's very hard to help. All I can say is that I have never heard of this from the perspective of it being a "Liferay" problem -- so almost certainly a bug in your implementation. 
thumbnail
Mohammed yasin, modified 6 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts
Hi, 
  Please share code snippet or error log if any
Ragvendra Singh, modified 6 Years ago. New Member Posts: 2 Join Date: 7/29/19 Recent Posts
Hi Andrew,

In my JSP code(example.jsp), I have a dropdown with three values (Webservice, Database, Email). When i select Webservice, 8 fields (name of the fields are URL, Header, Request, Response and so on)related to webservice will be rendered on the same page. I have written multiple validations function on every field of Webservice section. Likewise when i select Email from drop down, 6 fields(name of the fields are Hostname, SSL enabled, To, from, Subject) related to email will be displayed. I have written multiple validation functions for those field as well.

When i complete the information in the form and try to submit it. page is not submitted. Problem is when webservice is selected, validation function of Email and Database Operation is also getting invoked which should not happen.

=============================================================================

Below is a small code snippet of one of the function on field URL in WebService section. There are many functions like this on the same page.

                    <aui:validator name="custom" errorMessage="URL is not valid">
                           function (val, fieldNode, ruleValue)
                            {

                             var a=$('#<portlet:namespace />select_type').val();
                              var b=$('#<portlet:namespace />URL').val();
                              if(a=='WebService'){
                        
                              }
                              else{
                             
                              return true;
                              }
                            
                            
                            var res = new RegExp('^(https?:\\/\\/)?' + // protocol
        '((([a-zA-Z\\d]([a-zA-Z\\d-]{0,61}[a-zA-Z\\d])*\\.)+' + // sub-domain + domain name
        '[a-zA-Z]{2,13})' + // extension
        '|((\\d{1,3}\\.){3}\\d{1,3})' + // OR ip (v4) address
        '|localhost)' + // OR localhost
        '(\\:\\d{1,5})?' + // port
        '(\\/[a-zA-Z{}\\&\\d%_.~+-:@]*)*' + // path
        '(\\?[a-zA-Z{}\\&\\d%_.,~+-:@=;&]*)?' + // query string
        '(\\#[-a-zA-Z{}&\\d_]*)?$').test(val);
                            
                            if(res==true){
                           
                            return true;
                            }
                            else{
                            
                            return false;
                            }
                             
                            

                           }
                           </aui:validator>
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hi Ragvendra,

Thanks for sharing some of your code, and the additional details you unsurfaced. Without the full picture though, it's really hard to troubleshoot this with you. You said --
Problem is when webservice is selected, validation function of Email and Database Operation is also getting invoked which should not happen.
That sounds to me like a targetting issue (the selector for the node is too general) or something like that. Can you provide the full souce? maybe just attach the files to a reply?
Allen Chad, modified 6 Years ago. New Member Post: 1 Join Date: 8/22/19 Recent Posts
Well i have been facing a same issue..WIill be attaching my source code and some screenshots within a day.I hope u will help me here  
mygiftcardsite.com