- On the WWW , deeplinking is making a hyperlink that points to a specific page or image on a website,instead of that website's main or home page , such links are called deeplinks.
[hyperlink:]- in a computing ,a hyperlink is a reference to a document that the reader can directly follow, or that is followed automatically.
- Websites which are built on web technolgies such as Adobe Flash and Ajax often do not support deep linking,this result in usability problems for people visiting such websites. ie..mean : visitors to these websites may be unable to save bookmarks to individualpages r states of the sites,web browser forward and back buttons may not work as expected, and use of the browsers refresh button may return the user to the initial page.
- However , this is not a fundamental limitations of these technologies, Well-know techniques, and libraries such as SWFAddress , History Keeper, and BrowserManager class, now exist that website creators using Flash or Ajax can use to provide deep linking to pages within their sites .
[BrowserManager:]- class use method's in HTML Wrapper's javascript to handle events,
update the browser addressbar, and call other methods.
BrowserManager is a singleton manager that acts as proxy between
the browser and the application
It provide access to the URL in the browser address bar simillar
to accessing the document.location property in JavaScript.
Events are dispatched when url property is changed Listeners
can then responed,alter the URL, and /or block others from
getting the event.
To use BrowserManager, you call the getInstance() method to
get the current instance of the manger, and call methods and
listen to events on that manger
it's Package : mx.mangers
Class : public class BrowserManger
Inheritance : Object
[ singleton pattern ? :]- It's a design pattern that is used to restrict
instaniation of a class to one object , if u create
class as singleton then no way to create more than
one instance, But u can get that single instance
in any number of classes, so all the classes will
share same properties and behaviour of that singleton
object.
Another class URLUtil, is provided to make it easier to parse the url as you need it in your application and write it back to the browser
it's package : mx.utils
Class : public Class URLUtil
Inheritance : Object
[URLUtil:]- The URLUtil class is a static class with methods for working
with full and relative URLs with in Flex
To use deeplinking , you write ActionScript that sets and gets portion of url to determine
which state the application is in.These portions are called fragments,and occur after the
pound sign'#'in the url.
in the following example view=1 is the fragment
eg : http://my.domain.com#view=1
If the user navigate to a new view in your application , you update URL and set view =2
in the url fragment. If user then click the back button ,the BrowserManger is notified of the event, and gives you a chance to change the application state in respond to URL fragment changing back to view=1.
You typically use the methods of the URLUtil class to parse the URL,
This URLUtil class provides methods for detecting server names, port numbers,
and protocol of a URL,In additonal you can use the objectToString() method to convert
an Action script object to a string that you then append to the end of a URL.
Alternatively , we can convert any number of name/value pairs on query string into object
by using URLUtil class's stringToObject(). this lets you then manipulate the fragment
more easily in your application logic.
[Fragment identifier :]- is a short string of characters that refer to
a resource that is subordinate to another primary
resource ,The primary resource is identified by a
URI(uniform resource identifier) and subordinate
resource is identified with fragment identifier.
Fragment identifier is defined by RFC 3986 as an optional
componet of URI refrence, and it must conform to a certain syntax.
Fragment identifier is saparated from rest of URI refrence by '#'.
This sapartor is not considerd part of fragment identifier.
NOTE:When using URL fragment for deeplinking , you actually want to keep the built in history
managment off , otherwise it will interfer with processing.
Follow this four steps in Flash Builder 4 to achieve Deeplinking using BrowserManger Class :
STEP1: start by declaring three variables
1) a refrence to the flex Browsermanger class -- > public var browMang:IBrowserManger;
2)a flag to signal that URL parsing is in progress--> private var isParsing:Boolean;
3) a variable to hold the title for the browser's title bar --> private var title:String;
STEP2: Now , you need to declare your states of your application if you haven't already,
and place a listner for the enterState event. When the state changes , a call
to upate URL will be made.
STEP3: When the application loads , with the help of creationComplete event
you will need to intialize the BrowserManger, and register two listeners,
one for when browser's URL changes and other for application's state changes,
Lastly u will use the callLater() method of UIComponent to parse the URL.
private function application_creationCompleteHandler():void
{
browMang = BrowserManger.getInstance();
browMang.init("","Home");
browMang.addEventListener(BrowserChangeEvent.BROWSER_URL_CHANGE,parseURL);
callLater(parseURL);
STEP4: now , write the code for parseURL() function , this function will be called whenever
the BROWSER_URL_CHANGE event fires.The function parse the URL, and if fragments are found, it will change the title and state of the application accordingly
private function parseURL(event,Event=null):void
{
isParsing = true;
var obj:Object = URLUtil.stringToObject(browMang.fragment);
if (obj.view==undefined)
obj.view="Home";
currentState = obj.view;
title = currentState;
browMang.setTitle(title);
isParsing=false;
}
STEP5: now, u need to do is to update The URL from application though, we will accomplish this
with the function updateURL .
private function updateURL():void
{
title = currentState;
var fragments:String = "";
var obj:Object = {};
if(currentState != "Home")
obj.view = currentState;
fragments = URLUtil.objectToString(obj);
browMang.setTitle(title);
browMang.setFragment(fragments);
}