Double Triggering Problem Arises During Partial Refresh

My dojo button bar is connected to a csjs function that performs a partialrefreshget() on a datable control. The datasource for the datatable control is a view.

Within the this.keys property, I have implemented logic to check if the partialrefresh was initiated by examining the context.getSubmittedValue(). While testing this approach, I observed that the code snippet below is executed twice.

    <xp:this.keys><![CDATA[#{javascript:
var vec = new java.util.Vector()
vec.add("category");


if(context.getSubmittedValue()!=null){
    var x = context.getSubmittedValue().trim();

    print("--")
}

return vec;}]]></xp:this.keys>

The print statement is logged twice in the console, causing the logic to run twice as well. I am unsure why this duplication occurs and would appreciate any insights on how to address it. Should I be checking for submittedvalues in a different location?

Answer №1

Implementing a phase listener to track the evaluation of this.keys during the LifeCycle could provide valuable insights. It appears that this.keys may be evaluated multiple times, possibly during Render Response and Restore View phases. It is advisable to refrain from embedding application logic within property calculations, as it may unexpectedly trigger at various points in the application lifecycle.

Answer №2

Occasionally, I notice the submit button appearing multiple times on certain controls. It has been suggested that this could be a glitch in the JSP engine that has yet to be fixed.

To address this issue, my approach is to store the vec in a request scope variable once it has been calculated. I then implement a check before the calculation to retrieve the request scope variable, and if it exists, use that value instead of recalculating.

Answer №3

After some experimentation, I decided to abandon my own partial refresh method. The ExtLib Dojo toolbar includes an onclick event that is triggered when the submitvalue is set on a node. Within this onclick event, I added the following code:

Var v = context.getsubmittedvaleu();

If("action".equals(v)){
  // do stuff that changes the dataset.. 
}

The event handler is configured to partially refresh a datatable that receives the updated data. This approach is more streamlined compared to checking the submittedvalue in the datasource (as advised by Jeremy Hodge).

By doing it this way, the datasource is only refreshed once.


On a side note, I believe it would be beneficial to directly add such an event to the treenode(s), similar to how I would in standard Java Swing/AWT development by attaching a controllistener to a button.

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

The issue with getting a token from Next-auth on the server side persists

Currently, I am working on an application using Next.js and implementing authentication with NextAuth. However, I am encountering an issue with the getToken function not working properly on the server-side. I have double-checked my callbacks configuration ...

Is it possible to consolidate React and React-DOM into a unified library instead of having them separate?

Is it possible to combine React.JS and React-DOM.JS into a single library? In all the web applications I've encountered, we always have to import both libraries separately. Have there been any cases where either of these libraries can be used on its ...

tutorial on updating database status with ajax in Laravel

Currently, I am using Laravel in my project and I need to modify the patient's status when they schedule an appointment with a doctor. The patient can have one of three statuses: Accept, Waiting (automatically assigned when the patient selects a date ...

Unable to assign a boolean value to a data attribute using jQuery

I have a button on my page that has a special data attribute associated with it: <button id="manageEditContract" type="button" class="btn btn-default" data-is-allow-to-edit="@(Model.Contract.IsAllowToEdit)"> @(Model.Contract.IsAllowToEdit ? " ...

Enhance your bookmarking experience with Vue mixins that allow you to easily customize the color

Looking for a way to efficiently bookmark pages in my application, I have successfully implemented a feature where I can add pages by their name and URL into bookmarks. Upon clicking the bookmark button, it changes color to indicate that the page has been ...

Tips for monitoring input content "live"

Currently, I am in the process of developing a web form that includes a text field intended to receive numeric values. If the user enters non-numeric characters into this field, the form will not submit. However, there is no error message displayed to noti ...

Searching for a JavaScript button via aria-label and interacting with it using Python Selenium

I am currently utilizing Python Selenium to locate and interact with a specific javascript button on a webpage. The solutions provided in various forums do not suit my needs as the button I am targeting is unique. To begin, I will display an image of the p ...

Using the power of Javascript's jQuery library: the fantastic ".on()" Event Handler

I'm encountering an issue with the Jquery Event Handler ".on()". On my home page, I have a Favorite button on each post. If the post has not been favorited: li appears inactive Event 1 is triggered If the post has been favorited: li appears act ...

the order of initialization in angularjs directives with templateUrl

In my current scenario, I am faced with a situation where I need to broadcast an event from one controller and have another directive's controller receive the message. The problem arises because the event is sent immediately upon startup of the contro ...

Is there a way to change the color of a row in react jsx based on a condition from another row?

I am looking to highlight rows in red color based on a specific condition. If the ratio value in a column is greater than or equal to 0.96, I want to apply this styling. However, I'm unsure about where exactly to insert the necessary lines of code to ...

Terminate child process with specified user ID using the Forever-monitor

Whenever I need to create new child node processes, I use the following code: var forever = require('forever-monitor'); function startNodeProcess(envVariables, jsFileName, uid) { var child = new (forever.Monitor)(jsFileName, { ...

When it comes to HTML5 drag and drop functionality, only the dragstart event is triggered

I have successfully implemented HTML5 drag&drop using jQuery UI, but now I want to switch to using pure HTML5 API. Currently, only the dragstart event is firing for me. I am not able to catch the rest of the events. However, everything seems to be fun ...

Using Golang to encode JSON for parsing in JavaScript

I am working with a struct that looks like this: type User struct { Login string `json:",string"` PasswordNonce Nonce `json:",string"` PasswordHash HashValue `json:",string"` CreatedOn time.Time `json:",string"` Email ...

Having trouble integrating the circular progress bar into the movie card and getting it to align properly

Struggling to position my react circular bar for movie rating in the bottom corner of the movie card. The classes are not working as expected, even though I tried to replicate it from another website using React and SCSS while I'm utilizing Material-U ...

Refreshing the form fields and storing the information using AngularJS

I have successfully implemented a basic form using AngularJS. The issue I am facing is that even after the user enters their details and submits the form, the values remain in the input fields. My goal is to store the details of multiple fields in the con ...

Even after applying trim() function, PHP's return statement still adds spaces unnecessarily

My function is supposed to return a boolean, but for some reason, it is adding spaces at the beginning of the string. Even after using trim(), the spaces persist. What could be causing this unexpected behavior? PHP function checkFile($v){ $result = is_ ...

Accessing properties in JSON data with AngularJS

I am experiencing issues with accessing a JSON object returned from an $http call in my AngularJS app. I have provided the code snippet below, but it seems that nothing is being rendered on the HTML. Can anyone please assist me in identifying what I might ...

Refreshing a Django page without the need to reload the entire page

I am looking to implement a page refresh at specific intervals, such as every 10 seconds, without reloading the page. Currently, I am sending a GET request to an API. While my AJAX code successfully refreshes the page, it reloads all the divs each time cau ...

What is the best method for showcasing various content using a uniform accordion style in React?

What is the most efficient way to display various content within multiple accordions? view image description here This is the current approach I am taking in my project, where shipping information and delivery options will involve different textboxes, labe ...

Vue snapshot testing is encountering a failure with the error message "TypeError: Cannot read property of undefined"

Everything seems to be working fine with the component on the page without any errors. Storybook is also functioning well, but the problem lies in the unit test. import { mount } from '../../vue'; import { createLocalVue } from '@vue/test-u ...