0

I have working struts1 dispatch action and a form having two submit buttons which have parameter and value which calls method name with value. Well there is no problem.

But when clicking on delete button, I want to confirm with bootstrap dialog.

$('.btnDelete').on('click', function(e){
        var $form=$(this).closest('form');
        e.preventDefault();
        $('#confirm').modal({ backdrop: 'static', keyboard: false })
        .one('click', '#delete', function (e) {
            var sectorId = $(this).parent().parent().children()[0].innerHTML;
            var input = document.createElement("input");
            input.setAttribute("type", "hidden");
            input.setAttribute("name", "sectorId");
            input.setAttribute("value", sectorId);
            document.getElementById("sectorForm").appendChild(input);
            $("#sectorForm").submit();
        });
    });

Here e.preventDefault() is needed to stop form submitting. And when a delete button is clicked from dialog a hidden parameter will be passed and form will submit. But sever shows below error message.

HTTP Status 500 - Request[/SectorManagement] does not contain handler parameter named 'action'. This may be caused by whitespace in the label text.

Please note that there is no problem when removing bootstrap dialog.

1
Contributor
1
Reply
41
Views
1 Year
Discussion Span
Last Post by prakash2813
0

The solution was to add one more add hidden parameter named action and value.

$('.btnDelete').on('click', function(e){
    var $form=$(this).closest('form');
    e.preventDefault();
    $('#confirm').modal({ backdrop: 'static', keyboard: false })
    .one('click', '#delete', function (e) {
        var sectorId = $(this).parent().parent().children()[0].innerHTML;
        var input = document.createElement("input");
        input.setAttribute("type", "hidden");
        input.setAttribute("name", "sectorId");
        input.setAttribute("value", sectorId);
        document.getElementById("sectorForm").appendChild(input);

        input = document.createElement("input");
        input.setAttribute("type", "hidden");
        input.setAttribute("name", "action");
        input.setAttribute("value", delete);
        document.getElementById("sectorForm").appendChild(input);
        $("#sectorForm").submit();
    });
});

I don't know but there can be better solution. Will wait for your answers.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.