Error: StalePageException occurred in the wicket framework

I am currently using Wicket version 6.20. Within a Wicket page, I have implemented an AbstractDefaultAjaxBehavior to capture mouse clicks and their x,y coordinates:

class CallFromJavaScript extends AbstractDefaultAjaxBehavior {

    private static final long serialVersionUID = -123956851227148114L;

    @Override
    public void renderHead(Component component, IHeaderResponse response) {
        super.renderHead(component, response);

        String callbackUrl = getCallbackUrl().toString();

        String javaScript = "$(document).ready(function()"
                + "{$(document).click(function(e) {"
                + "Wicket.Ajax.get({ u: '" + callbackUrl
                + "&x='+e.clientX+'&y='+e.clientY});});});";
        response.render(OnDomReadyHeaderItem.forScript(javaScript));

    }

    @Override
    protected void respond(final AjaxRequestTarget target) {
        Request request = RequestCycle.get().getRequest();
        x = Integer.parseInt(request.getRequestParameters()
                .getParameterValue("x").toString());
        y = Integer.parseInt(request.getRequestParameters()
                .getParameterValue("y").toString());

        //more code....

        }
    }
}

When I open the same page with one user (one session), everything functions correctly. However, when I open the page with a different user (separate session or computer), I encounter a StalepageException:

RequestCycleExtra/qtp848034544-122 - /wicket/wicket/page?2-.... WARN : - Handling the following exception org.apache.wicket.core.request.mapper.StalePageException: null

I have observed that when I click with computer A on the page, the java code enters the renderHead method. When I click with computer B, java again enters the renderHead method. This pattern alternates with each click between the two computers.

If I limit the page to only be opened with one computer (one session), the java code enters the renderHead method only once.

Any assistance would be greatly appreciated.

Answer №1

When opening the page on a second computer, is the URL being used specifically including the page ID? Page IDs are limited to the same session, so attempting to open the same page instance from a different session will not work. It is only possible to create a new instance of the same page class in a separate session.

Perhaps there should be more clarity provided in distinguishing between a page class and a page instance.

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

Prevent image upload until text is clicked on

When the user clicks on the mask image, a file upload dialog box is displayed. Once the user uploads an image, the text "Remove Image" is shown. Issue: Currently, users can upload another image before clicking on "Remove image". However, after clicking o ...

What steps are needed to craft a customized greeting on discord using the latest nodejs update?

I am facing an issue where the following code is not sending anything: client.on("guildMemberAdd", (member) => { const welcomeMessage = "Please give a warm welcome to <@${member.id}> <a:pepesimp:881812231208181790> as th ...

Ways to initiate SVG animations using Angular Component functions?

I am currently working on a project where I want to incorporate an animation that reflects the sorting process of an array of numbers. However, despite successfully sorting the numbers in the array, I am facing challenges with triggering the animations. I ...

The completion action is never carried out

I am currently facing an issue with one of my JavaScript functions. I have several $.ajax calls throughout my webpage followed by .done(), and they all seem to be functioning properly, except for one. Can anyone identify what could be causing the error? m ...

How can one use an ajax call to delete rows from a table and then add new rows in their

Hey everyone, I'm looking to make an AJAX call and when it's successful, I want to remove all existing elements in my table and replace them with new ones based on the returned data. This is the method I have for making the AJAX call: $(document ...

Does anyone know if it's feasible to return a value from PHP to an HTML form without relying on JavaScript?

Currently, I am in the process of learning how to create a basic web form. My goal is to develop an HTML web form that sends a number to PHP and then displays the number in another text field without refreshing the page. After doing some research online, ...

Retrieving data from a separate server using GWT on the client side

My dilemma involves a file called sample.xml residing on one web server, and I need to retrieve this file from a GWT application running on a separate server. Rather than making RPC calls to the GWT server to access the file through server-side proxy, I pr ...

Tips for obtaining the sources of every image on a webpage and consolidating them in a single section

My goal is to preload all images on a webpage into a single division before the page loads. For example, if there are 5 images on the page (eg1.png, eg2.jpg, eg3.bmp, eg4.jpg, eg5.png), I want them to be contained within a div with the id 'pre'. ...

Iterating through XML elements using a loop in jQuery

I am trying to figure out how to loop through XML data obtained from an ajax request using a for each loop. The code snippet below currently only grabs the id attribute of the first success element and logs it. Is there a way to modify this code so that i ...

Navigating CSV-derived JSON data in Flask and Javascript: Best Practices

My current goal is to read a CSV file on the backend using Python/Flask and then display its data as an HTML table with Javascript. I have simplified my task to just displaying JSON values passed from Python in the browser console, which will help me build ...

What is the reason that TypeScript does not automatically infer void & {} as the never type?

When TypeScript's void type is used in combination with other types through intersection, the outcomes vary. type A = void & {} // A becomes void & {} type B = void & '1' // B becomes never type C = void & 1 // C becomes never type D = void ...

How can I access a store getter in Vue after a dispatch action has finished?

I am currently utilizing Laravel 5.7 in combination with Vue2 and Vuex. While working on my project, I have encountered an issue where Vue is not returning a store value after the dispatch call completes. The workflow of my application is as follows: Wh ...

Using dynamic JavaScript appending with the location.href attribute and the ajax-cross-domain.com script for seamless integration

Once I assign this code to load the function on window.onload event: window.onload = initfunction; I am looking to add an AJAX cross domain script to the header: function initfunction() { var dh = document.getElementsByTagName('head')[0]; va ...

Example of Next.js Authentication - redirecting according to authentication status, encapsulating within other functionalities

I'm currently working on a project using next.js with authentication. The authentication is set up and working, but I'm having trouble displaying the data in my navbar. Originally, I was using firebase for authentication, but now I have it set u ...

Experiencing a problem with the JavaScript loading function

An error was logged in the console SyntaxError: unterminated string literal A piece of code is supposed to display a notification $(document).ready(function () { alertify.success("Success log message"); return false; }); Despite testing the cod ...

The IISNode website displays directory contents instead of launching the server.js file

Having trouble configuring IISNode to automatically serve the main server.js application file for my node application. Currently, when I navigate to http://localhost:80/ where my app is hosted, it just displays the folder contents instead of running the se ...

Creating XML files using Node.js

What are some effective methods for generating XML files? Are there tools similar to the Builder in Rails, or any other recommended approaches? Appreciate any insights! ...

Displaying Material UI textboxes in multiple columns for dynamically created forms using ReactJs from an array

I am working with an API to retrieve a list of cars, and I have come up with the following code snippet to generate labels and textboxes for editing the car codes. {!carQuery.loading && carDefinitions?.map((car: ICarType, idx: number ...

Why is my AngularJS application triggering two events with a single click?

<button id="voterListSearchButton" class="serachButton" ng-click="onSearchButton1Click()">find</button> This button allows users to search for specific information: $scope.onSearchButton1Click = function() { var partId = $("#partIdSearch" ...

The shared global variable or store feature is currently not functioning as expected in Vue JS

Currently, I am in the process of developing a Simple Web application using Vue JS for educational purposes. Although I am new to Vue JS and still learning the ropes, I have encountered an issue with sharing a state variable across all components. In my a ...