Wednesday, April 28, 2010

ADF:Programatically adding Bookmark in FF3

FireFox has a limitation of creating Bookmarks using Javascript.Till FF2.X version, it used to open in Browser Side Bar.

Here is a piece of code in ADF you can use.

<af:commandbutton text="BookMark Me" id="cb1" actionlistener="#{DemoBean.invokeBookMark}" partialsubmit="true">

Managed Bean code
 private String FIREFOX_BOOKMARK_SCRIPT = " alert('in FF');\"UniversalXPConnect\"); \n" +
" var bmsvc = Components.classes[\";1\"].getService(Components.interfaces.nsINavBookmarksService); \n" +
" var ios = Components.classes[\";1\"].getService(Components.interfaces.nsIIOService); \n" +
" var uri = ios.newURI(url, null, null); \n" +
" var hpBookMarkId = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, uri, bmsvc.DEFAULT_INDEX, title); \n" +
" alert('hpBookMarkId='+hpBookMarkId);";

public void invokeBookMark(ActionEvent actionEvent) {
// Add event code here...

String title = "XXXX";
String url = "";
String script = "var title='" + title + "'; " + "var url='" + url + "'; " + BOOKMARK_JAVASCRIPT;

ExtendedRenderKitService service =

service.addScript(FacesContext.getCurrentInstance(), script);



However, for browser scripting security in FF 3,0, user have to do the following.I have updated the same in the bug.
This is a normal web world practice, nothing specific to JSF or ADF.

1)-In Firefox browser,in address location type "about:config" and reload the tab.
2)-It will prompt for a message.Say Yes.
3)-Out of the list of properties, search for "signed.applets.codebase_principal_support".
4)-Double click on the value "false" and it becomes true.

Close the browser and try clicking Bookmark Icon for the HelpPortal Topic.
Make sure you check the checkbox "Remember this decision", when FireFox will display this message.


Anonymous said...

Hi there! Quick question that's completely off topic. Do you know how to make your site mobile friendly? My web site looks weird when browsing from my apple iphone. I'm trying to find a theme or plugin that might be
able to resolve this problem. If you have any suggestions, please share.
Many thanks!

Stop by my site ... lug canada

Anonymous said...

I was wondering if you ever considered changing the page layout of your blog?
Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content
so people could connect with it better. Youve got an awful lot of text for only having 1 or
2 images. Maybe you could space it out better?

Here is my web-site :: victorinox ::

Anonymous said...

Hey! I know this is kinda off topic but I'd figured I'd ask.
Would you be interested in trading links or maybe guest
writing a blog article or vice-versa? My site discusses a lot of the same subjects as yours and I think we could greatly benefit from each other.
If you happen to be interested feel free to send me
an email. I look forward to hearing from you! Great blog by the way!

Also visit my web page - lug

Anonymous said...

╬Ľncore un post franchement captivant

Feel free too surf to my homepage - porno africaine