I have a link in my JSP page, where the user uses it for downloading an Excel File. When the user clicks on the link, the controller goes to a java script function where I display a moving image(like progress bar) and then it will be redirected to Action Classes. After executing the java code, a pop up window appears asking the user to open/save the file.
As the page is not getting refreshed, the progress bar keeps on running and I am not able to hide it.
Does anyone have an idea how to resolve this using Javascript as I dont have much idea on Jquery.
Thanks in advance.
function generateRnDFootPrint(){
progressBar.showBar(); // progress bar appears
location.href='<%= contextPath %>/saveMTP.do?method=getRnDFootPrintReport&orgCode=<%=orgCode%>&orgId=<%=orgId%>';
}
Try the following....i just add a line at the end of the function:
function generateRnDFootPrint(){
progressBar.showBar(); // progress bar appears
location.href='<%= contextPath %>/saveMTP.do?method=getRnDFootPrintReport&orgCode=<%=orgCode%>&orgId=<%=orgId%>';
setTimeout(function(){progressBar.hideBar();},2000);
}
I hope it does the trick.....in the case it does not, then you should have a function that hide the bar and call it, like in the commented line ;)
Saludos.
What you can do is give an id to the download link
<a id="download-link" href="your_value_here">Download Link</a>
In JavaScript
var link=document.getElementById("download-link");
link.onclick=function(){
progressbar.hide();
}
And if you want jQuery version
$("#download-link").click(function(){
progressbar.hide();
});
Related
I have to navigate between my components and I use a custom button like this:
button.addClickListener(click -> {
UI.getCurrent().navigate(ClassToNavigate.class);
});
The url does refresh in the search bar but it only shows a black page, I've to hit F5 to see the component in my parent layout.
My only fix is to add:
UI.getCurrent().getPage().reload();
...which reloads the page after navigating to the URL, and that breaks the UX in my opinion, however... when using a BeforeEnterEvent on a class and using the method:
forwardTo(ClassToNavigate.class);
redirects perfectly... although I can't have BeforeEnterEvent for every menu button I have, I can't see why forwardTo() works perfectly and navigate() doesn't.
Is there a way to navigate without having to reload the page? And without using RouterLink which I can't because I'm already using a custom component.
Thanks in advance!
My main goal: When i click the link, a new browser window should be opened and displays the content of entire log file. And the window should not have an address bar and navigation buttons (Back, Forward).
Is there any approach to do this in Spring-MVC project?
Here is what i am doing now:
When i click the link, the controller will be called with a parameter logName.
Now the controller have access to get any kind of details of the log file like content, path, etc... I am setting all these details to an object and sending back to JSP.
Here i am not sure how to open a new window and display the content of the log file in that window.
Please suggest me an approach on this!!
It would be very helpful for me if you can share me with some examples...
Spring or JSP have nothing to do with it, the only way to force user's browser to open a link in a new tab is to use client-side Javascript. window.open() allows configuring the popup to hide certain interface elements (see all options in the documentation)
Your code would look something like:
<input type="button" value="Show Log" onclick="showLog(logName)">
function showLog(logName) {
var url = "/path-to-your-controller.html?logName=" + logName;
window.open(url, "LogPage", "toolbar=no,location=no,menubar=no");
}
However, I don't think using a customised browser popup is a good solution; it's been disappearing from the web for a reason. It would be more elegant to fetch raw data using AJAX and display it in a JS popup: it wouldn't interfere with user's page navigation (you tagged the question with jQuery, you could use jQuery UI for that).
What is more, I wouldn't be surprised if window.open wasn't supported by all browsers in the same way† - something to keep in mind if you're targeting a wider audience.
† seems that Chrome ignores location=no, for instance
i am using Galleria plugin for JavaScript i need show the image in full Screen modei have checked the APIand have a method.
.enterFullscreen( [callback] )
returns Galleria
This will set the gallery in fullscreen mode. It will temporary manipulate some document styles and blow up the gallery to cover the browser screen. Note that it will only fill the browser window, not the client screen (javascript can’t do that).
API
i am using ZK Framework responding to a button click using this code.
public void imageZoomer()
{
Clients.evalJavaScript("$('#galleria').data('galleria').enterFullscreen(function() {alert('full screen mode');})");
}
but nothing happens i have also try using
Clients.evalJavaScript("imageZoomer()");
and a javascript function like this
function imageZoomer()
{
alert('before');
$('#galleria').data('galleria').enterFullscreen(function(){alert('full screen mode');})
alert('after');
}
the above function is called but nothing happens but if a try this code on firebug console
$('#galleria').data('galleria').enterFullscreen(function(){alert('full screen mode');})
it works smoothly what i am doing wrong thanks a lot.
finally i could solved my issue using a xmhtml button in ZK and responding onClick event using JQuery i couldn't solve my issue using ZK button here is my code i hope i really helps somebody.
<div xmlns:h="xhtml">
<h:button onclick="$('#galleria').data('galleria').toggleFullscreen();">Full Screen. </h:button>
</div>
best regards..
Does anyone know of any javascript code that I can put on a radio button that will kick off a Spring WebFlow2 Transition event?
I am looking to kick off a transition to load values into a dropdown if the user clicks on a radio button... can someone please tell me if you seen this done.
In your situation I think you want to use Ajax to refresh only part of your page. What I use is a function in my global js file:
function ajaxWebFlowSubmitGet(divID,pars,view) {
new Ajax.Updater({success:divID},
view+"&date="+new Date().getTime(),
{ method:'get',
parameters:pars,
evalScripts:true,
onFailure:reportError,
requestHeaders: ['Accept','text/html;type=ajax']
});
}
which you can use then in your code with
ajaxWebFlowSubmitGet('dropdownListDiv','_eventId=eventID&fragments=dropDownFragment',${flowExecutionUrl});
just put that 'ajaxWebFlowSubmitGet' function in your page and call it from your radiobutton.
'dropdownListDiv' is the div you want to get updated
eventID is the name of the transition from your webflow you want to execute
dropDownFragment is the name of the fragment you want to receive as a response (and to be put in your 'dropdownListDiv')
My java webApp (struts2 and jQuery) has a jsp with a form:
<s:form id="theForm" action="stampaPosizioneFinanziaria" target="_new">
and a jQuery button:
<a id="stampaPerCliente">Stampa standard</a> // rendere by $('#tampaPerCliente').button();
On button click:
$('#stampaPerCliente').click(function(){ avviaStampa(0); });
...
function avviaStampa(tipoStampa) {
$('[name=tipoStampa]').val(tipoStampa); // I set a hidden field
$('#theForm').submit();
// tried document.forms[0].submit(); too, same behavior.
}
So, the new page opened (the form target is _new) calls an action that read the paramters form and displays a pdf.
Everything works fine BUT: on IE when I click the button first time it works, second time doesn't, third time does and so on.
The 'doesn't work' means the action has every input parameters null! I monitored the request and on IE there aren't request parameters! (even times, not odd times!)
It works fine on Chrome and FF.
Help please.
I solved using GET method for submission:
<s:form id="theForm" action="stampaPosizioneFinanziaria" target="_new" method="GET">
The POST method (default for struts2 s:form) caused this issue (?!!!?).