Is there a Actionscript/Flash equivalent to Java's GetDocumentBase() Method?
I'm trying to figure out if I can create events depending on what url the flash object was loaded from.
If the object is loaded at www.Happywifi.com show a happy face animation. If it is loaded at
www.Happywifi.com/question/ Show a question mark face.
I'm interested in flash, it seems like more detailed animations are possible with flash that what we are using in Java.
For the love of God please don't respond with "Why are you doing it that way!". The platform we are working with has a few constraints.
Have a look at the LoaderInfo class (check out the docs)
You could use either the url property or the loaderURL property. Like this:
trace(root.loaderInfo.loaderURL)
You should be able to use the LoaderInfo class which has the loaderURL property.
Something like:
stage.loaderInfo.loaderURL
Which will give you a string of the URL from where the file was loaded. Then you can do your additional processing.
Note that this is not the URL from which the page that was contains this object, but rather the actual URL of where the .swf file resides.
Using flash vars might be another solution to your problem if you can embed different objects on the page depending on what you want.
Related
Hi i am pretty new to Restlet, and generally building web servers. I need to support filtering like this:
http://deviceip:port/resource?id=id
So far i know how to return a json message when user invokes different resources, based on my web server state. I would attach it to router, and add class which handles that resource. But how can i return only one resource from collection based on id? What i need to change in my class which is responsible from handling of that resource. Also how can i attach this resource to router? Any help is welcome, if you can write some code snippet to help me, that would be great.
Thanks
So as i understand you can approach to this in two ways. One is explained by link above and another one is using query. So basically you font have to create another resource like in the answer from link above, instead you can just extract query with this.getQuery()
and than call method getFirstValue("id"), which will return entered id.
How can i get the page URL in single-approver-definition.xml in the e-mail template that is used to send an e-mail to the content creator once the reviewer approves or rejects the submission. The existing xml is as follows:
<template>
Your submission has been reviewed and the reviewer has applied the following:
${taskComments}.
</template>
I tried ${serviceContext.getAttribute("contentURL")} and it didn't work.
I want to be able to do - Your submission for ${pageURL} has been reviewed and the reviewier has applied the following: \n ${taskComments}.\n
Any suggestions will be appreciated.
I don't get what variable exactly you want to process in your notification. As I can only assume, you are using it for Web Contents and all interesting variables are stored in two places.
Workflow context variables - they are available directly. Few examples like:
${taskComments}
${entryType}
${userId}
${userName}
...
ServiceContext variables - they are available using $serviceContext. Few examples:
$serviceContext.getAttributes().get("version")
$serviceContext.getAttributes().get("articleId")
${serviceContext.getPortalURL()}
...
For all interesting variables check this url https://www.liferay.com/web/igor.beslic/blog/-/blogs/workflow-in-action-kaleo-workflow-context-variables Some could change already, however most of them is working fine for current version.
Content changes might be made on a page, they can also be triggered through Control Panel (or the API for that matter). When you're in a workflow, you typically don't have this context any more - if you find it somehow I'd not rely on it to be there. A workflow is unrelated to the UI and pages.
Also, an article might be submitted on one page, where it might be replaced/removed before it's even approved. In that case the link wouldn't help.
What might work is to check the concept behind "Web Content Display Pages" (if your article has them configured and you deal with web content). But the mechanics will vary depending on the actual content type you're dealing with. And content that goes through workflow might not be displayed on any page at all (e.g. when submitted through Control Panel) or on many different pages (either explicitly - Web Content Display - or implicitly - Asset Publisher).
#tomic basically provides pointers to what you have, I'm only reasoning why your initial problem is problematic to solve at best - it's not fully specifiable.
My question is pretty similar to How can I load a local file from embedded Rhino?.
Most of the suggestions I've have read suggested modifying java code, but I'm using Rhino that's embedded in vendor software (both Shibboleth and NetIQ IDM), so I don't have access to context in which Rhino exists (or the code that creates it), only the script engine that's been spawned in that context.
Corderer suggested doing something like...
eval("" + Packages.org.apache.commons.io.FileUtils.readFileToString(
new java.io.File("/the/local/root", "script.js");
));
...which works! Like Corderer, though, I was hoping for a less ugly solution (maybe actually being able to use load()). Is eval() the best / easiest option to do this?
Liam
Maybe I'm missing something but from what I understand, you just want to read a file on disk from within JavaScript. If so, you can do this:
var fileObj = new java.io.File("/the/local/root/somefile.txt");
This will basically give you access to a Java file object, which then you can manipulate to your heart's content. See the documentation for the java.io.File class to see what methods are available.
Edit: After further review of the question, it seems that you want to load a JavaScript source file from within JavaScript. If so, then you can use Rhino's built-in load command like so:
load("/the/local/root/script.js");
Years later, here's my take:
Create a Global object that has the missing load function.
g = new Packages.org.mozilla.javascript.tools.shell.Global(Packages.org.mozilla.javascript.Context.getCurrentContext());
this.load = g.load;
The g variable now holds the global object used in Rhino scripts.
I am trying to use the AssetManager class in LibGDX and I understand how it works but I am trying to implement a loading screen. I have followed the AssetManagerTest.java file here,
but I am having a hard time trying to figure out how to get it to work correctly. Can someone point me in the right direction? My goal is to load the assets (textures, sounds, fonts, ... etc) and update a bar with the percentage complete on the screen. I don't understand the ResolutionFileResolver and the Resolution[] in the link I provided. What are they for? My goal is to support a static class that can give me access to all of the assets I need in my game from any screen. Is there a preferred method to do this? Thanks.
After looking at the source for ResolutionFileResolver as well as the other 'resolvers', I think it's just a way of loading textures that best match the screen resolution, but the match is just based on filename patterns.
So in AssetManagerTest, he's got textures for screen sizes 320x480, 480x800, and 480x854. It looks like each group of textures should be in a directory called ".320480" or ".480800" or ".480854" (although the name can be anything you want, like "low", "high", and "wide" if those are your directories), and he specifies all this info when creating the array of resolvers on line 56 of the test.
The advantage of doing all this stuff is that when he calls manager.load(), he just picks out a filename like "data/animation.png". Then the resolver finds the pack of textures that most closely matches the current screen resolution, and loads that one.
I think the rest of the example should be pretty clear, at least for the basics of AssetManager. Create a manager, set the loader, call load(), call get() to use it, and then call unload() when done.
For updating a progress bar, you'll just need to do that manually after each call to load.
And using a static class for asset management is certainly one possibility. Another similar option is to just use a singleton. It has its haters, but I think in a simple project in a garbage collected environment it should be ok, although it's about the same as a public static.
Another option--maybe the best?--is to use a base class that has a static copy of your game globals, and then all other game classes inherit from it. This is the approach used in Replica Island. See the base class and the object registry. Replica Island is well commented and worth checking out for Android & Java games.
Is there a way of getting the websites absolute URL (http://www.domain.com/) using Java? because I've googled a bit but I only come across with having to make 2 or 3 classes to create that function =/
Update:
The thing is I am trying to create a crawler that will give me some information and among that I'd like to get the URL of the webpage it's getting the information from. I'm developing this in JAVA and what I meant to say was that I was wondering if there was some getUrl(); or any method like that to get me the Url, because I know it can be done but I've only done it writing a whole other class to retrieve the url and then inherit it and use it further...hope it made it clearer
I'm assuming you just want the domain from a JSP, however you may find you need the entire URL including the prefix, domain, path and parameters. The easiest way to get this quickly is to use the Request object and build it. Have a look here for more info:
http://www.exforsys.com/tutorials/jsp/jsp-request-object.html
Here is Sun's API on the HttpServletRequest interface:
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html
The question is not really clear, but I'll make the assumption that you are trying to get the path from within a Servlet.
String realPath = getServletConfig().getServletContext().getRealPath(relativePath);
Could you be more specific? Your question states:
Is there a way of getting the websites
absolute URL (http://www.domain.com/)
using Java?
By "the website" which website are you asking for? I can see multiple ways of interpreting your question:
Given a URL, if there a way to get the hostname portion of it?
Given a relative path, how do you get the full path?
Within the context of a Servlet, is there a way to get the name of the deployed server?
etc...