Avoiding duplicate form submissions in Struts2: Managing Success Messages Display

Is there a way to prevent multiple form submissions in Struts2? I am currently utilizing tokenSession (TokenSessionStoreInterceptor) for this purpose. However, it seems that this interceptor only considers the first request and ignores subsequent submits. The issue I'm facing is that after a successful request execution, no action message is being displayed. For example, if an order is created successfully, the proper view is shown but without any confirmation message indicating that the order has been created. Any suggestions on how to address this?

Below is my configuration:

<action name="createOrder"
        class="com.example.OrdersAction" method="createOrder">
        <interceptor-ref name="storeStack" /> 
        <interceptor-ref name="tokenSession">
            <param name="includeMethods">createOrder</param>
        </interceptor-ref>
        <result type="tiles" name="input">createOrders</result>
        <result type="tiles" name="error">createOrders</result>
        <result name="create" type="redirectAction">order</result>
        <result name="createAndAdd" type="redirectAction">

         </result>
    </action>

Answer №1

Consider changing the sequence of your interceptors for better results.

<action name="createOrder" class="com.example.OrdersAction" method="createOrder">
        <interceptor-ref name="storeStack" />
        <interceptor-ref name="tokenSession">
            <param name="includeMethods">createOrder</param>
        </interceptor-ref>
        <result type="tiles" name="input">createOrders</result>
        <result type="tiles" name="error">createOrders</result>
        <result name="create" type="redirectAction">order</result>
        <result name="createAndAdd" type="redirectAction"></result>
</action>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps can I take to resolve the issue of encountering the error message "Module '@endb/sqlite' not found"?

Currently, I am facing a challenge while attempting to set up a database for my discord bot using node.js with sql/sqlite 3. I have installed the necessary dependencies such as 'endb', sql, and sqlite3 through npm install. However, upon completio ...

What could be the reason for the Express function Router() returning a value of undefined?

Currently, I am working with TypeScript and Express to develop an API that adheres to the principles of Clean Architecture. To organize my application, I have structured each route in separate folders and then imported them all into an index.ts file where ...

Is there an optimal method for transforming HTML to PostScript in Java?

Is there an optimal method in Java to convert HTML with CSS2 support into a PostScript file? ...

Is there a way to dim and deactivate a button after it has been clicked once?

Hello, I am attempting to disable and grey out a button after it has been clicked once in order to prevent the user from clicking it again until they refresh the page. I hope my question is clear enough and that you can understand me. Below is the HTML cod ...

Incorrect footer navigation on my Vuepress website

I'm in the process of developing a vuepress single page application for showcasing and providing downloads of my personal game projects. When it comes to website navigation, I am aiming to utilize the native sidebar exclusively. This sidebar will hav ...

What is causing some keyup values to not stay in the input field even when they are passed as parameters?

Currently facing an unusual issue related to processing time. The problem seems to be with a PIN input that consists of 4 inputs. You can observe the behavior in action on this stackblitz code snippet I have set up: https://stackblitz.com/edit/vue-fezgmd?f ...

Having trouble resolving the BooksAPI in my code, can anyone help?

I've been trying to troubleshoot this problem, but I can't seem to find a solution. I'm working on a web application for book reading that allows users to organize books they have read, want to read, and are currently reading. On the search ...

Using R to extract the citation of a scholarly article for export

I need R to: Visit THIS page. Choose "Bibtex" as the format and select "Citation and Abstract" for the "Export type". Click on "Submit" and save the citation file to a specific folder. Is this achievable with R? How can I accomplish this task without ...

Receive an object that is devoid of any content

I need help connecting Angular 2 to Express. I've successfully set up and tested the server endpoint using Postman (it seems that the content type needs to be x-www-form-urlencoded for it to work), but I'm unsure if there are any specific configu ...

Obtaining response object when encountering 401 error in AngularJS

I am currently working with Angular 1.6.4, Express 4.15.2, and express-session. My goal is to identify whether a user is unauthorized to access a specific route by checking for the existence of the req.session.user parameter. If the user is not authorized, ...

[Vue alert]: "Maximum" property or method is not declared in the instance but is being referenced during the rendering process

Here is my custom Vue component: Vue.component("product-list", { props: ["products", "maximum-price"], template: ` <div> <div class="row d-flex mb-3 align-items-center p-3 rounded-3 animate__animate ...

The Chrome 53 browser is currently experiencing issues with recognizing keyboard events

Utilizing the keyboard event for my dropdown control in angularjs with the following code. It worked flawlessly in chrome 49, but unfortunately, it doesn't seem to be functioning in chrome 53. I am unsure whether this issue lies within chrome 53 or if ...

Scrolling without limits - cylindrical webpage (CSS/JS)

Is it possible to create a page that infinitely scrolls from top to top without going straight back to the top, but instead showing the bottom content below after reaching it? Imagine being able to scroll up and see the bottom above the top like a 3D cylin ...

Inconsistent alignment and formatting of fields in Bootstrap jQuery form

I need assistance with creating a form that includes three input fields: first name, last name, and email. Additionally, I would like to provide users with the option to add more groups of input fields. Currently, the three fields and the button are displ ...

JavaScript still mentions a class that no longer exists

One of my elements has a class of .collapsed. When this element is clicked, a jQuery function is triggered to remove the .collapsed class and add the .expanded class instead. Even after the .collapsed class is removed, the function I have created continue ...

Troubleshooting server-side sorting issues with AJAX implementation, encountering problems with headers functionality

I'm encountering a problem: Some headers are not functioning properly to sort the table. For example, Brand and Model work as expected, but VehicleType only works once, and CarID and ReleaseDate never seem to work. Here is my index.php file: index. ...

Modify the text depending on the value chosen from the dropdown menu

Just a heads up: I struggle with javascript. I'm attempting to create a function that takes the selected value from a dropdown menu (which includes different themes for users to choose from), compares it against an array of allowed themes, and then d ...

Please enter a string and I will locate it within an array. If found, I will provide you with information about that string as a fact

I have a specific challenge I need help with. I have a pre-defined array that contains country names and corresponding facts about each country. What I am trying to achieve is to check if the user-inputted word matches any of the countries in my array, a ...

HTML integration of JavaScript not working as expected

My experience with separating files in HTML and JS has been positive - everything works smoothly when I link the JS file to the HTML. However, an issue arises when I decide to include the JS code directly within <script> tags in the HTML itself. The ...

Efficiently updating arrays within object arrays using MongoDB

I have the following data structure: { data: [ {pos:"0", moreData: ["a", "b"] }, {pos:"1", moreData: ["a", "c"] }, ]} I want to update this structure by adding a letter to moreData where pos ...