I'm working on an Android app and trying to implement the following solution:
within an HtmlDrawable I have a set of elements with onClick events.
By clicking on these elements I want to communicate back to the Java code of the app using the "architectsdk://" url technique.
But I don't see any response in my ArchitectView.ArchitectUrlListener() implementation.
Another note: when I set onClick event of the HtmlDrawable itself then I successfully notified within the Java code.
So the question: is it possible to communicate back to Java code from an HtmlDrawable or I need to create each element separatly and places onclicks on them?
Thanks in advance.
I've got an answer on the Wikitude's forum:
In case if someone needs it:
HtmlDrawables live in a different context, you therefore cannot use
architectsdk to communication with native Android/iOS urlListener. I
recommend using HtmlDrawables onClick listener instead.
e.g. myHtmlDrawables.onClick = function() {
document.location="architectsdk://mydrawables?clicked=1"; return true;
}
Best regards
Related
I am working Loadrunner 12.55, and Using TrueClient Protocol to design script for my application.
I have been blocked in an issue, where for each iteration the script should click on random object in the list . Not able to achieve this through normal Parameterization provided by TrueClient.(It doesn't allow me to parameterize Action itself).
Below is the step configuration i tried but didn't work:
Click on PerfTest3
Roles: "javascript_link, focusable, element"
Name: PerfTest3
ID Method: JavaScript
JavaScript =
var linkList = document.getElementsByTagName("a");
random(linkList);
Logic to randomly click objects on the page needs to be written in javascript? Please assist me to solve this issue.
PFB screenshot for further understanding the problem.
Thanks in advance
As far as I see your solution to use JavaScript identification and to use the random method that is defined inside the JavaScript identification context is a good one. W
hen trying it myself it worked with your code as well but maybe in your case, this is a more complicated DOM hierarchy and in that case, you might want to use the evalXPath method instead of the getElementsByTagName method and change the simple “//a” to something more custom for your application:
var linkList = evalXPath("//a");
random(linkList);
you can also try to use Descriptors and change the identification to this:
Is it possible to create javascript elements like OpenStreetMap or jQuery inside a vaadin application?
Because vaadin websites are created by programming in java and letting the compiler autocreate the DOM and JavaScript out of it?
So, is it possible at all?
You can create such an integration with AbstractJavaScriptComponent
The basic idea here is to subclass this class, annotate with #JavaScript to pull in the needed JS libs. Then write at least a global function, that sets up your lib in the DOM (you will have a <div> at your disposal). Your component can hold state, the server side can call defined functions on the client (while sending e.g. state) and the client can call server functions (params passed as JSON).
The Wiki has an example how to include such a component
There are some easy and cheap solutions which are not the best in the long term, but they may be enough:
1)
If you just want to render some html you cant insert it as the value of a label and change its Content Mode to html.
https://vaadin.com/book/-/page/components.label.html
2)
If you just want to execute some javascript code after a ui event you can call Javascript.getCurrent().execute(javascriptCode).
https://vaadin.com/book/vaadin7/-/page/advanced.javascript.html
Notice that if you are trying to do some re-usable components, this is not the right answer
I have a strange problem. I have a custom JS file written and all of its functions work fine until I run any ADF's JS action. For example - I have an action which slide down a component and it's fine. But when I run a adf popup or Faces Error Message all of my custom JS are disabled. Where is the problem?
Thanks in advance
Since you ain't giving any details on your problem, I can give only common answer.
When using custom js, you should always keep in mind, that any ADF action may overwrite all or part of html code on the page.
You should always set property clientAttribute=true for component, if you accessing it via js. Use actionListener instead of regular js handlers on component if possible or each time component refreshes you should reinitilize all of your js hooks.
Good way to avoid problems is to do all you can via ADF JS framework.
Check with any js debugger(like firebug) whats going on the page during your action and act accodingly.
You can get more info in documentation.
I have a ASP.Net Repeater control with a Table inside it. Is it possible to run a JavaScript function directly AFTER I call MyRepeater.DataBind()? I've been trying different things, but nothing is triggering the JavaScript function.
Thanks
Databinding occurs on the server in a postback as part of the Page Lifecycle process. In other words, excluding partial-postbadks, at the time this happens any existing DOM in the browser is destroyed. A whole new page is constructed on the server and transmitted to the browser, so that a new DOM can be built and rendered.
What all that means is that you want to think in terms of running your javascript in the page's onload event. One way to make this happen is using the ClientScriptManager.
Javascript can be called from server side by using RegisterStartupScript and RegisterClientScriptBlock methods.
http://www.mindfiresolutions.com/Register-clientside-startup-script-from-serverside-code-286.php
No. The javascript isn't even going to render and run until the code-behind has executed and the page delivered to the client. So it won't matter if adding the script is the first thing you do in the code-behind or the last thing you do (or directly after the DataBind()).
When using the ClientScriptManager Class, look at your code behind and you'll see the dynamic javascript is added just before the ending </form> tag (although it still may be possible to accomplish what you want to do, just with a different approach).
Well I found a solution, not sure it's the cleanest way to do it, but for my application's context it works:
I ran the javascript code after a partial postback using: Sys.WebForms.PageRequestManager.getInstance().add_endRequest();
Again, not the cleanest but suits the needs I have.
Thanks for all your input
I want to add scripting functionality to my Adobe Flex application. I know it's possible to use the Browser control, and add the script packaged as a HTML file to the Browser control, and expose Flex objects. However I'd like to if it is possible to execute JavaScript without using the Browser control.
UPDATE: I guess my question hasn't been clear enough. I'll explain what I'm trying to do.
I want to make my application customizable using JavaScript ie., add scripting/plugins to my application dynamically.
I realize that it's possible to dynamically execute Javascript by inserting the JS code into the HTMLLoader control. I would like to know there is a direct way to execute JavaScript without inserting it into the HTMLLoader control.
If you are in a web application, then the following should work
var retval:int = ExternalInterface.call("myfunction", "arg1","arg2");
You can also use URLRequest to accomplish this
var req:URLRequest = new URLRequest("javascript:myfunction()");
navigateToURL(req,'_self');
If you are in a AIR application, something like this should work
var html:HTMLLoader = new HTMLLoader();
html.load(new URLRequest("...URL..."));
html.addEventListener(Event.COMPLETE, myeventhandler);
In the event handler you can do this.
html.window.document.location = "javascript:myfunction(arg1)";
If i understand what you want, you can add your Javascript code into your {nameOfApplication}.html which exists in bin-debug of your project.
Notice: with this method, the javascript code will be disappear always when you compile. It's about the HTML wrapper.