How to reload a jasper report repeatedly within every one minute - jasperserver

I use a jasper report as my dashboard on Jasper Server 6.4.2 version.on that report, I have to display current time with live updates without reloading the report manually.
I tried to schedule the report and set as output options as Overwrite Files and it's not worked.
Basically,I want to reload a report when it already opened and displayed withing every given time period repeatedly until I close the report. How can I do this?

Found a way by myself.
Go to ViewReport.jsp on jasper server installation files. (When a report loads,this page executes)
Then add below code for it.(Actually we use java script to do this.)
<script type="text/javascript">
var url = window.location.href; //take current tab url
var dash = 'http://localhost:8080/jasperserver/flow.html?_flowId=viewReportFlow&_flo...';
if(url == dash ){
setTimeout(function(){
window.location.reload(1);
}, 5000);
}
</script>
url is the current display report URL.
dash is the URL that we want to refresh. otherwise all the reports will be refresh within every 5 seconds.
5000 is time gap want to refresh.
restart the jasper server.
that's it..

Related

Google Sheets - How to jump to today's date when opening a table (via share link)

Thank you for your great posts!
I am looking for a code that will cause jumping automatically to the current date after opening a table in Google Sheets (via a share link). Your code (see below) works great if I am signed in. When I create a share link (with or without edit rights), the code does not work. I tried the link with different browsers (Chrome, Edge, Firefox) ... What could be the problem?
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getActiveSheet();
var data = sh.getDataRange().getValues();
var today = new Date().setHours(0,0,0,0);
for(var n=0;n<data[0].length;n++){
var date = new Date(data[0][n]).setHours(0,0,0,0);
if(date==today){break};
}
n++;
sh.getRange(1,n).activate();
}
Kind regards
Here the link to your code:
How to set background color for a row based on current date in Google Docs Spreadsheet?
The onOpen(e) function is a simple trigger that runs only if the user at the keyboard is signed in to their Google account and has edit access to the spreadsheet.
The simple triggers onOpen(e), onEdit(e) and onSelectionChange(e) will not run when a file is opened in read-only mode. The same is true with other kinds of scripts as well. In other words, if you share the file as "can view" or "can comment", no scripts or add-ons will be available.
To make it work, you will have to share the spreadsheet file as "can edit". Note that you you can still protect the spreadsheet through Data > Protected sheets and ranges.
See the jumpToToday_ script for an alternative that supports multiple sheets in the same spreadsheet file.
unfortunately, this won't work for you. by default, all non-signed users (and signed-in users which did not authorize scripts) are protected from "harmful" scripts which may be included with the spreadsheet. all scripts are treated as "harmful" by default including your onOpen script.

How to stop re submitting a form after clicking back button [duplicate]

This question already has answers here:
Prevent user from seeing previously visited secured page after logout
(7 answers)
Closed 6 years ago.
I have a JSP page with a form where you fill up certain details. On submitting the form i call a servlet which then updates details in a database after that i redirect to a page i display a confirmation message to the user.
The problem i have here is when the user clicks back he goes to the form page again where if he clicks a submit button, it creates a new record in the database.
Consider this similar to a shopping cart example where in this case he would buy the same item twice. But the only problem here is i cannot handle this in backend, i.e. the database can never know a redundant operation is taking place.
I need to handle this from the client side.Bit weird but i have to do it this way.
Basically when the user clicks the back button i don't want him to be able to go to the form page and may be just to some other page.
This is a typical HTML form issue, you can solve it through any one of following methods
1) Server side (page expiration): Since you've mentioned that the page refreshes and goes to the confirmation. You can set no-cache and add a page expiration time as -1 to the page you have that form.
So that when user presses the back button, he will see that the page has expired. He will be forced to load the page freshly. This is the behavior that I see in most banking websites.
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
2) Using turn Key method: When the form loads, you can generate a random key in session memory and also embed it as a hidden value in the page.
During form submission, check the submitted hidden key against the value in session. If exists, then add the entry to database otherwise you can reload the page with a fresh key for the user (who might have done that unintentionally).
In load balanced or web farms, consider persisting the turn key in Database against the current user.
3) Client Side (Not recommended) : You can restrict the user from using the browser back button by removing the page from the history. (One side effect is that it will remove the entire history for that browser tab/window)
history.pushState(null, null, document.title);
window.addEventListener('popstate', function () {
history.pushState(null, null, document.title);
});
If you need the same support for older browsers where push and pop states are not supported, you can use following snippet.
<script>
function preventBack() {
window.history.forward();
}
setTimeout("preventBack()", 0);
window.onunload = function() {
null
};
</script>
Before redirecting to the JSP page send these headers with the response from the controller so that the page is not stored in cache and the browser will always request a new page from the server.
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setDateHeader("Expires", 0);
So every time you go back to that page a new page will be requested from the server and will be displayed with the cleared input fields.
You could implement a PRG-Pattern (https://en.wikipedia.org/wiki/Post/Redirect/Get) using php.
Basically, after successfully submitting the form you redirect to a confirmation page which informs the user that their submission was successful/accepted/etc. and also set a variable which you can later use to check if said submission has been submitted yet.
When the user tries to reload said page or go back you can check the variable and display either the form again or the confirmation page based on if the submission has been submitted already.
I think following flow is the best:
Client submits data to server
Servlet processes it
It returns HTTP 303 redirect to client
Client redirects to success page
After this flow, refresh, back button will work properly.
For more information read Simple Post-Redirect-Get code example

protractor - how to enforce protractor to wait for REST call to return information to complete building page elements

New to testing with protractor, actually new to test automation in general so hopefully this is posted in the right place. Apologies if not, please advise.
I am trying to test elements on a pages which are only displayed after a response to REST call. The page in question has two TABS, I click on the non-active TAB, it goes active, loads the TAB framework, then a few seconds (depending on the information returned) later a Graphical timeline is built in the TAB based upon the information from the REST call.
My problem is how to make protractor wait for the REST call to be completed and the Timeline built before continuing to test the elements in the Timeline.
From various searches I am using the following code. I am just picking a single element on the Timeline to check for isPresent. I have also tried using browser.wait as opposed to ptor.getInstance however have the same problem that the wait is not waiting for the timeline to load fully. Any guidance would be much appreciated.
it('XXXXXX', function() {
var ptor = protractor.getInstance();
// Define element to wait for in the Timeline Graphic
var waitForElement = by.css('.timeline-time');
// Load the page
jobManagerPage.go();
// Click the inactive TAB to make active
jobManagerPage.eleDataVisTabLiTag.click();
// This is where I am expecting to wait for the element in the Timeline
// to be present before continuing
browser.wait(function() { return ptor.isElementPresent(waitForElement);
}, 8000);
// Test for the Timeline element to be present - this keeps failing !!!!!
expect(ptor.isElementPresent(waitForElement)).toBeTruthy();
});
One solution (though far from ideal) is to add an element to the DOM when you're loading, and remove it when done (or add/remove a CSS class, etc...). You may or may not have the opportunity to do that, depending on how your AJAX calls are being made.
I found this approach in an answer to this SO question: AngularJS + Protractor wait for all ajax calls to end / full page load, before running the tests

GWT panel fields data refresh delay on slow internet

I am using GWT 2.5.1.
In my GWT web app I have a ComplexPanel object which contains a set of fields(widgets). There are a suggested field (on panel) which gives me the opportunity to find object and info about it. Fields (10-15 of them) contain info about that object.
The problem is when user (client side) has a slow internet connection, fields on form are updated with a delay. And if in moment of delay user click 'Save' button (AsyncCallback), old data (which is not updated) posted to the server.
How it works:
1. Server receive callback from the form and start to processing the data.
2. Server refresh all the fields with new data and end the works.
3. Javascript updating the data on form using about 10 requests.
But: internet is slow and one part of data is refreshed and other no.
4. User click SAVE and mixed data goes to the server.
I need to know (from server side) when all the field are refreshed on client side and server can proceed with a next post request.
Thanks in any advice.
Perform a validation check on click of the save button. There are several things you can do as per your requirement. I have listed one way to validate it.
Set a flag before making the async call as false. For instance, isLoaded = false
Once you have all the fields just update it to true, i.e. isLoaded = true
On save button handler check for isLoaded flag. If false, prompt a message, else save.
Update:
You can count the number of response received. You know that you will get 10 response. So for every response received increment a counter. Activate save only if you have all 10 response recieved.
For a clean way to do this, use gwt-async-future.

Crystal Reports 10

I am using Crystal Reports 10. In the report I have two prompts.
How can I give this report to users such that they can enter the parameters on the web?
Thx in advance,
S.Gyazuddin
If you're using the stand alone crystal reports designer you will need to deploy the report to a web reporting tool such as Crystal Reports Server or Crystal Enterprise. Then allow your users to access it from there.
If you are using .Net then create an ASP.NET page and add a CrystalReportSource control to your report to the page. Then add a CrystalReportViewer control to the page that uses your report source and be sure the checkbox for Enable Report Parameter Prompting is checked. When they load the page it should prompt the user for the parameters.
Here is some code to get you started
ReportDocument rpt;
//set the datasource
rpt.SetDataSource(reportDataSet.Tables[0]);
ArrayList reportParameters; // you filled this arraylist with your values coming from aspx page
//set the parameters for mail report
for (int param = 0; param < reportParameters.Count; param++)
{
rpt.SetParameterValue(param, reportParameters[param]);
}