Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
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:
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.
Solved! Go to Solution.
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);
}
}
%>
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?
Do you have an example of the session variable?
I will email
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);
}
}
%>