Vaadin 23 change browser url based on button click in the application - vaadin

Based on the button click in Vaadin application, I'd like to change the browser URL value. I'd like to add some GET parameters to the URL. Please advise how to implement this with Vaadin 23.

I use the following code to update the browser url:
String baseUrl = RouteConfiguration.forSessionScope().getUrl(getClass());
String urlWithParameters = baseUrl + //add parameters here
getUI().get().getPage().getHistory().replaceState(null, urlWithParameters);

Related

how to dynamically change the url in ng2-uploader

I am using ng2-uploader in my angular2 application.
Here is my code:
options: Object = {
url: "http://localhost/APP/opsnd/api/index.php/mydkd/configured/?"+JSON.stringify(this.type)
};
What I did in the above code is that I appended a parameter which is changed dynamically and sent to the server along with the file.
Html:
input type="file" ngFileSelect [options]="options" (onUpload)="handleUpload($event)" (beforeUpload)="beforeUpload($event)">
The problem is, when I select a file, it is automatically loaded to the server using the default [option] url. So even if the parameters in the url changes, the default url is what is sent to the serve. How can I dynamically change the [options] so that it listens to changes in my component?
there is a setOptions() method where you can update your new URL like below,
this.uploader.setOptions({ url: newUrl });
Hope this helps!

window.location in Firefox and Chrome giving me two different returned strings for a Google Macro

My application is using Google Apps Script HTML Service. The URL for Apps Script looks like this:
https://script.google.com/macros/s/AKfycby2Zr2apAai2sIW6eiWTc8yNakGg5M9oLQkmhcz-IRqs22qoJhm/exec
In Firefox, this line of code:
window.daURL = window.location;
returns this:
https://script.google.com/macros/blank
Firefox puts in the word blank. Chrome gives me the entire URL.
What I've been doing, is getting the entire URL, then using Javascript string methods to parse the URL for whatever info I need to check for a Facebook login. The Facebook login appends info to the end of the URL beginning with a hash tag. If the hash tag is there, the code checks for and validates a Facebook login.
I need either the entire URL, or to be able to get an appended string after the /exec.
Chrome gives me the entire URL with window.location, but Firefox will not.
If I try:
window.daURL = window.location.pathname;
Firefox returns:
/macros/blank
If I try:
window.daURL = window.location.search;
I get nothing returned, even when a string is appended to the URL.
I can get a string appended to the URL with the Apps Scripts doGet(e) function:
e.parameter.theNameOfTheStringArg
E.g. www.URL.com?myArg=Something
Use: var getString = e.parameter.myArg
But I can't get a hashed appended value to the URL with doGet(e). I need to check for a hash in the URL.
I figured out that I can use window.location.href to check for the existence of the hash tag appended to the url. So I use window.onload to check for a hashtag in the url, and doGet(e) to check for string attachments to the URL. I need to run both.
<script>
//Script tag in first HTML file that always loads
window.onload=function(){
console.log("This onload did run");
//get the URL out of the browsers address bar
//the URL can have multiple different strings attached depending upon the situation.
//Any situation other than something with a hashtag is initiated in the back end.
window.daURLhash = window.location.hash;
console.log('daURLhash: ' + daURLhash);
window.urlHash = daURLhash.toString();
console.log('urlHash: ' + urlHash);
console.log("url: " + urlHash);
//If a certain situation, there will be a hashtag in the url string
if (urlHash != undefined && urlHash != null) {
if (urlHash.length > 0) {
window.hashExist = true;
console.log('hashExist: ' + hashExist);
};
};
if (window.hashExist === true) {
code here
</script>

History.js PushState in html 4 browser (IE) changes the url incorrectly

Im usnig History.js to push a url but in IE it appends the page name.
if my original url is :
http://www.mydomain.com/Home.aspx
and then I execute the following:
var url = window.location.protocol + '//' + window.location.host + '/Home.aspx?id=2&pl=4';
History.pushState(null, null, url)
In Chrome my url becomes : http://www.mydomain.com/Home.aspx?id=2&pl=4
In IE 8 my url becomes: http://www.mydomain.com/Home.aspx#Home.aspx?id=2&pl=4
If I paste the IE 8 url in chrom my code fails...
Firstly, what should the correct html 4 url look like and secondly, how do I fix it?
I believe you are not pushing a state properly, try reformatting the url you push e.g. History.pushState({data: 'home'}, null, '/Home/').
Or maybe you thought that pushing a state also sends a request to server like you did there with a query? It does not buddy.
Therefore, dont expect anything to work by pasting the state u pushed into other browsers. First, because other browsers have no history about your site and secondly you need to catch the statechange event with History.
e.g.
History.Adapter.bind(window, 'statechange',
function() {
if (History.getState().data.page === 'home') {
//do what u would like with current state
}
);

How to get absolute url from the relative url in java

I am having a page like mypage.com/a/b/somePage.html, and one of the anchors href attribute is something like "a/b/anotherPage.html".
When i try to get the absolute url from by creating a new url object with page url and href value, i am getting the absolute url as mypage.com/a/b/a/b/anotherPage.html.
This is causing problem for me, but some how the browsers are handling this properly.
Any out of box things available to solve this problem. ( I can always add an exception in the code to handle this differently, but i don't want to do this.)
Using java.net.URL
URL baseUrl = new URL("http:www.google.com/someFolder/");
URL url = new URL( baseURL , "../test.html");

How to remove an attachment using JIRA soap service

Reading the API I don't see any methods that can do this?
http://docs.atlassian.com/software/jira/docs/api/rpc-jira-plugin/latest/index.html?com/atlassian/jira/rpc/soap/JiraSoapService.html
Yes, it would need a custom SOAP plugin. Not too hard, just annoying that the method isn't there.
~Matt
SOAP doesn't support this, but you can do it via HTTP, e.g. (C#)
using (System.Net.WebClient client = new System.Net.WebClient())
{
string url = "http://jira-server/secure/DeleteAttachment.jspa?id=" +
issue.id + "&deleteAttachmentId=" + attachment_id;
client.Credentials = System.Net.CredentialCache.DefaultCredentials;
string response = client.DownloadString(url);
// do whatever validation/reporting with the response...
}
You can check the url from your web browser - has to be the deletion confirmation page, not the link from the initial delete button.

Resources