2

I have a JSf form, I am tryin' to use jQuery Ui dialog plugin to submit the form. here's the code snippet.

function confirmSubmit() {
          $('#dialog').dialog('open');
          return false;
      }

    $('#dialog').dialog({
        autoOpen : false,
        width : 400,
        modal : true,
        resizable : false,
        buttons : {
            "Submit Form" : function() {
                 document.myForm.submit();
            },
            "Cancel" : function() {
                $(this).dialog("close");
            }
        }
    });
<h:form id="myForm"> 
<h:commandLink action="#{Bean.search}" type="submit" onclick="return confirmSubmit()"   id="search" styleClass="buttonSearch">
                 </h:commandLink>    

The "document.myForm.submit();" part in the dialog box isn't working i.e., no calls goes to the server and in the server console I see the error:

11:45:32,738 SEVERE [lifecycle] JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /PRT01/IMCM0101.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@ec333b]

The dialog box is appearing correctly but once i press the submit button "document.myForm.submit();" code is executed and the form is NOT submitted instead the above described error comes on the server console.

7
  • It's fixed now, some JSF parameters were missing. which jsf adds during form submissiom, I added them using jQuery $("a[id$='search']").click(function() { var input = $("<input>").attr("type", "hidden").attr("name", "myForm:search").val("myForm:search"); $('#myForm').append($(input)); $("p#dialog-email").html(titleVar); $('#dialog').dialog('open'); }); Commented Jun 1, 2011 at 9:05
  • What exception was thrown during phase execution? Please post its stacktrace. It contains the answer. Commented Jun 1, 2011 at 11:41
  • Hello BalusC, I have already posted the error that the server console was showing, I have also asnwered this question below, since in my form I have multiple command button each pointing to a different method of bean thus while doing "document.myForm.submit()", it wasn't taking the command button into consideration as i had done "onclick=return false;" as I wanted to submit the form using jQuery, thus i appended the required parameter "myform:search" using jQuery .append inside the form and now it works fine. It's something new which wasn't available on internet. Hope it helps other people. Commented Jun 2, 2011 at 11:22
  • You have not posted the exception. The error just tells Exception thrown during phase execution:. It is telling that an exception was been thrown. I was interested in which exception was been thrown. You should have read a bit back in the logs to find it. Commented Jun 2, 2011 at 11:24
  • I have just double checked but in the server log there is no exception trace just the above error, also on the UI the the complete page gets refreshed after i pressed the submit button on the jquery dialog box as required parameter "myForm:search" isn't passed in this request(saw the parameters using FireBug) until I deliberately add this "myForm:search" as hidden param using jquery only this the calls goes to the server(using eclipse debug mode i am monitoring the calls to the server). Commented Jun 2, 2011 at 11:53

2 Answers 2

3

as you return false; it won't submit actually.

To make dialog working

    $(document).ready(function() {
    var $dialog = $('<div></div>')
        .html('This dialog will show every time!')
        .dialog({
            autoOpen : false,
                            width : 400,
                            modal : true,
                            resizable : false,
                            buttons : {
                              "Submit Form" : function() {
                                       document.myForm.submit();
                               },
                               "Cancel" : function() {
                                       $(this).dialog("close");
                                }
                           }
                });


});

and then just call

 function confirmSubmit() {
      $dialog.dialog('open');
      return false;
  }
Sign up to request clarification or add additional context in comments.

4 Comments

Hello Jigar, the dialog is working I have the code <div id="dialog" title="Verify Form jQuery UI Style"> <p> <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 0 0;"></span> </p>Are you sure you want to <p id="dialog-email"></p> <p>To edit, click Cancel. <p> </div>
The problem is not about the dialog but the the form submission in the jsf using "document.myForm.submit();"
just try $("#myForm").submit();
it's giving the same error on the server 3:20:06,255 SEVERE [lifecycle] JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /PRT01/IMCM0101.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@162ad2c]
0

It's done, some JSF parameters were missing. which jsf adds during form submissiom, I added them using jQuery:

$("a[id$='search']").click(function() {
    var input = $("<input>").attr("type", "hidden").attr("name",   "myForm:search").val("myForm:search");
    $('#myForm').append($(input));
    $("p#dialog-email").html(titleVar);
    $('#dialog').dialog('open');
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.