cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Throttling user messages on screen

avillanueva
22-Sapphire II

Throttling user messages on screen

We've developed a customization that uses the lightbox (yellow message banner) that executes on the user's home tab to relay actionable information. Each time the page is refreshed, the message appears but would not like to throttle that message to be periodic. Some of our thoughts were:

  • Accessing the user's session creation and spacing out execution based on that time.
  • Accessing the user's login time and doing same thing.
  • Creating a singleton which keeps track of the user's last execution time limiting based on some timer.

For the last option, how would that work across multiple method servers? Would each MS having its own JVM, have its own copy of the singleton? Not a huge issue but is there a system wide solution?

Example solution would be to display a message no more than once every two hours.

Open to any other solutions.

ACCEPTED SOLUTION

Accepted Solutions
avillanueva
22-Sapphire II
(To:avillanueva)

Thanks to @jbailey  for the solution using a session variable. This addition to our JSP puts a timestamp when the last time the user was notified of our special alert message supplied by OpenTasks.getOpenTasks(). This is just a static class that returns values for some queries on late tasks. The messages are displayed in the standard banner at the top of the page and disappear after a few seconds. Subsequent refreshes of the page show nothing until the timer exceeds a certain number of hours since last execution. This way the users are not harassed non-stop, a more gentle poke in the side. Thanks to my intern Ben for this work.

<%
	//Get current timestamp
	Timestamp timestamp = new Timestamp(System.currentTimeMillis());
	String messageAlreadySent = (String) session.getAttribute("messageAlreadySent");
	PropertyResourceBundle properties=(PropertyResourceBundle)PropertyResourceBundle.getBundle("customization.openTasks.homeAssignments");
	int[] summary;
	
	if(messageAlreadySent == null){
		wt.org.WTPrincipal user = wt.session.SessionHelper.getPrincipal();
		summary = OpenTasks.getOpenTasks(user);
		session.setAttribute("messageAlreadySent", timestamp.toString());
	}else{
		Timestamp lastMessage = Timestamp.valueOf(messageAlreadySent);
		long delay = (long)(Double.parseDouble(properties.getString("delay")) * 60 * 60 * 1000);
		lastMessage.setTime(lastMessage.getTime() + delay);
		
		if(lastMessage.compareTo(timestamp) < 0){
			wt.org.WTPrincipal user = wt.session.SessionHelper.getPrincipal();
			summary = OpenTasks.getOpenTasks(user);
			session.setAttribute("messageAlreadySent", timestamp.toString());
		}else{
			int[] temp = {0,0,0};
			summary = temp;
			session.setAttribute("messageAlreadySent", messageAlreadySent);
		}
	}
%>

  

View solution in original post

4 REPLIES 4

On my banners I create a session variable to store whether or not the banner has been seen (when they acknowledge a security warning by clicking a button).

 

Might you be able to set a timer in the session that looks if they clicked the button in the last xxx minutes?

avillanueva
22-Sapphire II
(To:jbailey)

Do you have an example of the session variable?

I will email

avillanueva
22-Sapphire II
(To:avillanueva)

Thanks to @jbailey  for the solution using a session variable. This addition to our JSP puts a timestamp when the last time the user was notified of our special alert message supplied by OpenTasks.getOpenTasks(). This is just a static class that returns values for some queries on late tasks. The messages are displayed in the standard banner at the top of the page and disappear after a few seconds. Subsequent refreshes of the page show nothing until the timer exceeds a certain number of hours since last execution. This way the users are not harassed non-stop, a more gentle poke in the side. Thanks to my intern Ben for this work.

<%
	//Get current timestamp
	Timestamp timestamp = new Timestamp(System.currentTimeMillis());
	String messageAlreadySent = (String) session.getAttribute("messageAlreadySent");
	PropertyResourceBundle properties=(PropertyResourceBundle)PropertyResourceBundle.getBundle("customization.openTasks.homeAssignments");
	int[] summary;
	
	if(messageAlreadySent == null){
		wt.org.WTPrincipal user = wt.session.SessionHelper.getPrincipal();
		summary = OpenTasks.getOpenTasks(user);
		session.setAttribute("messageAlreadySent", timestamp.toString());
	}else{
		Timestamp lastMessage = Timestamp.valueOf(messageAlreadySent);
		long delay = (long)(Double.parseDouble(properties.getString("delay")) * 60 * 60 * 1000);
		lastMessage.setTime(lastMessage.getTime() + delay);
		
		if(lastMessage.compareTo(timestamp) < 0){
			wt.org.WTPrincipal user = wt.session.SessionHelper.getPrincipal();
			summary = OpenTasks.getOpenTasks(user);
			session.setAttribute("messageAlreadySent", timestamp.toString());
		}else{
			int[] temp = {0,0,0};
			summary = temp;
			session.setAttribute("messageAlreadySent", messageAlreadySent);
		}
	}
%>

  

Announcements

Top Tags