سؤال

Hi Experts,

I want to know if it is possible in Struts 1.x to display a confirmation dialog from Struts Action. In more detail :

I have Action Form,Action Class and importList.jsp file. When i click a button(on the main Jsp file) .. the current importList.jsp is displayed by setting the properties of Action Form. In this jsp file i have ok and cancel button. When i click OK button, on the basis of some condition i want to show the confirmation dialog saying yes or no, if the user clicks yes it will move forward, and on cancel.. it will move to main jsp file(not to importList.jsp file)

Any ideas ....

هل كانت مفيدة؟

المحلول

You can use javascript to get this done. Instead of "Yes/No" dialog you will get "Ok/Cancel" dialog box. You will have to replace "importList url" and "main page url" with your actual urls.

This may not be syntactically accurate but it's a start.

<head>
<script type="text/javascript">
    $(document).ready(function(){
        $('input[type=submit]').click(function(){
            var answer = confirm("You will be forwarded. ");
            if(answer){
                //your logic
                document.location.href="importList url";
            }else{
                //your logic
                document.location.href="main page url";
            }
        });
    });
</script>
</head>
<body>
    <input type="submit" value="Ok" />
</body>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top