Query parameters order in AngularJS URL accessed from Flex - angular-ui

I have a web application written in AngularJS (version 1.0.8).
I'm using UI-Router (0.4.) to handle the state of that app.
I try to access the URL of the app from another Flex app (4.0).
In the Angular app, I have the URL:
http://localhost:8080/myApp/somePage?param01=aaa&param02=bbb
In Angular's module.config() of that app, I do something of this sort:
$stateProvider.state("somePage", {
url: "/somePage?param01&param02"
templateUrl: "view/somePage.html"
controller: "SomePageController"
});
Now in the Flex application, I have the following code:
var variables:URLVariables = new URLVariables();
variables.param01 = "aaa";
variables.param02 = "bbb";
var url = new URLRequest();
url.data = variables;
navigateToURL(url, "_self");
The problem is that when I press the button in the Flex app that navigates to the Angular app, I get this URL:
http://localhost:8080/myApp/somePage?param02=bbb&param01=aaa
In the URL's query parameters, param02 comes before param01.
Then, in Angular's ui-router, I guess, it is changed to the regular URL:
http://localhost:8080/myApp/somePage?param01=aaa&param02=bbb
My problem with this is with the browser navigation - when the user will click 'back', the browser won't navigate back to the URL of the Flex app, because there's another URL in history, where the query parameters were switched. The user will have to click 'back' twice...
Moreover, though this is an elaboration that's not necessary for the problem, so you can skip it if you'd like, the user can access that Angular app from more than 1 place (i.e. not only from the Flex app). When the user click 'Save' or 'Cancel' in the Angular app, it should be redirected to the originating page. I planned on doing it using the history.back() feature, but it's problematic due to the aforementioned phenomenon, of the URL with the query parameters switched.
Many thanks in advance,
Daniel

I solved my own problem, currently by changing the way I work with navigateToURL in Flex.
I now have something of this sort:
var queryParams:String = "param01=aaa&param02=bbb";
url.url += "?" + queryParams;
navigateToURL(url, "_self");
This way, when I use a string built by me, instead of the URLVariables class, I can control the order of the URL query params.
Unfortunately, I still don't know why the URL query params are ordered differently every time I use the function, when I do use the URLVariables class...

Related

how to open new tab in inertiaJs and vue 3

I want to open a file on a new tab but my inertia props are lost,
my approach on opening new tab is this
window.location.href = "/view/"+props.document.type+"/"+props.document.id, "_blank"
but the my inertia props are lost. It only returns a blank html page
Update: there was a missing return in OP's code.
If you open a new tab, you will have your SPA nuked. The idea is to persist it with something like cookies or alike. Give a try to that answer for a possible solution: https://stackoverflow.com/a/66872372/8816585
VueJS by default has no way to persist any state out of the box (it's client side code).

Using WebBrowser in ASP.Net Web Application

I am trying to use a WebBrowser in a .cs class in a Web Application - NOT A WINDOWS FORM app using (VS 2019).
I know it's a Windows Form app control, but it seems like I should be able to use it in a Web App.
Using WebBrowser in Web App does not have the .Url property, so I just use the .Navigate directly - this is where the code breaks.
I have tried many suggestions on the Net, but nothing seems to work - it looks like most of the examples uses a Web Page - I want to use the WebBrowser directly in code (.cs class).
private static void LoginViaUserAgentFlow()
{
Thread thread = new Thread(delegate ()
{
StringBuilder sb = new StringBuilder(String.Format("{0}/services/oauth2/authorize",
RHOutlook.chosenInstance.sfdcURL));
sb.Append("?response_type=token");
sb.Append(String.Format("&client_id={0}", RHOutlook.chosenInstance.clientId));
sb.Append(String.Format("&redirect_uri={0}", System.Web.HttpUtility.UrlEncode(RHOutlook.chosenInstance.redirectUri)));
WebBrowser webBrowserSFDCLogin = new WebBrowser();
//Here I can't use the .Url becaue it is not available - so I just use
//Navigate to get to the site
webBrowserSFDCLogin.Url = new Uri(sb.ToString());
//This is were it breaks, comes back with error when I navigate to the site.
webBrowserSFDCLogin.Navigate(sb.ToString());
//This code is never reached - failed at above code.
if (webBrowserSFDCLogin.LocationURL != null && webBrowserSFDCLogin.LocationURL.StartsWith(RHOutlook.chosenInstance.redirectUri))
{
//webBrowserSFDCLogin.ScriptErrorsSuppressed = true;
webBrowserSFDCLogin.Stop();
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
}
I expect to be able to navigate to the external website. If I can navigate to the site if I copy the url directly in a browser (say Chrome).
I tried using ; this gives me the Url property, but still get the error.
You really should stick to suggestions and examples.
What you are trying to do is to use class that is designed for Windows Application inside a Web Application.
Those two frameworks are similar like Earth and Mars. I am afraid you are not going to be able to grow a tree on Mars.

Load flash builder app from a URl

I have an browser based application built with Flash Builder (actually Flex 3.5) with a Java backend. The application works well. It has a default login page and users can always login and view products by typing the product id in an input field to display product and other info.
I will like to modify this application in such a way that a product page can be viewed by just including the product id in the url something like www.myserver.com/?product_id=1234577
I am completely at lost on how to implement this and not even sure if this is possible at all.
Yes, this is definitely possible.
The key details are from Pass url parameters to a swf (flash) movie:
Look at loaderInfo.parameters["product_id"] in your Flex code; as your application initializes, hook into your current logic that brings up info when you type in a product ID.
You may use this approach . You can pass parameters like (if embedded in jsp page)
var flashvarsWF = {};
flashvarsWF.product_id= '<%=productId%>';
And you can pass this flashvarsWF in
swfobject.embedSWF()
In flex main application(mxml), you can receive this as
var pId:String = this.parameters.productId;

Flex 4.6, AIR 3.5, desktop app, navigateToURL, _self

I have a desktop AIR app built with Flex 4.6 and Air 3.5. I use navigateToURL to launch a URL in the default browser, works fine:
var request : URLRequest = new URLRequest ( "http://localhost:8890/test.html" );
var urlVariables : URLVariables = new URLVariables ();
urlVariables['activity'] = "xyz.json";
request.data = urlVariables;
request.method = URLRequestMethod.GET;
navigateToURL(request, "_self");
The app lets the user construct some JSON content (xyz.json), then test it in a test rig (test.html).
The second and subsequent times I do this, I get a new tab (I'm using Chrome). What I want is for it to appear in the same tab as the last one. Note that I've used "_self". If I pass any string I get the same result.
Any help would be appreciated. Thanks.
I dont believe it is possible to force browser to reuse same tab - that would be browser behaviour, not AIR behaviour (ie: you would change the expected behaviour in browser settings; eg: always open content in new tab).
I believe from a desktop app when you invoke NavigateToURL() it will force a new window (container) to launch.
If you can you could create a separate 'receiver' page on the server to receive the data (invisible to the user) Then launch a 'viewer' page with NavigateToURL that would contain an ajax script to check and update the data received from the 'receiver' page.
I would check out URLLoader() Class. I use this many times for my web service scripts.

Custom URL issue in flex ios app

i am using custom url scheme in my flex iOS app and it’s working fine when i start my app from a web link..but the issue is when i start my app from start menu in iPad and move to webpage in safari.In page i click a button that redirects it to my app, at that time app call “preinitialize” method more than once..it wary every time, some time it’s 2,3,4 and different one each time..i don't know why it’s behaving like this..can i know the reason please its urgent..
thanks…any help will be appreciated.
Create a flag initialized and set it to true when preinitialize is called. All other calls to this method can be filtered out. Simple example:
private var initialized:Boolean = false;
public function preinitialize():void
{
if (initialized) return;
initialized = true;
}
Next step would be finding the real cause of the multiple calls, but for that we would need to see some code of your app.

Resources