Search This Blog

Friday, July 16, 2010

Add Javascript to Ice Faces or Facelets

There are several ways to add JavaScript code to an ice faces page. One of which is explained here.The "Direct to Dom" (akaD2D) rendering of icefaces makes it difficult to add javascript or any other code to it.

Q. Where to add the code? .
Ans. The answer is to put the < script type="text/javascript"> just code after the < ice:root> between < html> < head> .add the javascript in the similar way as you add it in jsp/html. then close the tag and at the end before closing the root (i.e < /ice:root> ) add the < /html> tag.

Q. How to call an icefaces componet?
Ans. Use the formname:componentid format to use it in the javascript function.

Q. How to use the body onload thing without using body tag.
Ans. The answer lies in using the window event.

Here is an example which makes everything clear


< jsp:root version="2.0" f="http://java.sun.com/jsf/core" h="http://java.sun.com/jsf/html" ice="http://www.icesoft.com/icefaces/component" jsp="http://java.sun.com/JSP/Page">
< f:view>
< script type="text/javascript>
function setFocusOnLogin(){ document.getElementById("icefaces_formaname:icefaces_component_id").focus(); }//its used to call the icefaces component's focus event
window.attachEvent("onload", setFocusOnLogin);//like body onload , its called on page load < /script>
< ice:portlet>
< ice:form id="icefaces_formaname">
< ice:inputtext id="icefaces_component_id" size="10">
< /ice:inputtext>
< /ice:form>
< /ice:portlet>
< /f:view>
< /jsp:root>

Hope you get it. For any concerns feel free to post a comment.

Thursday, January 7, 2010

Liferay Portal Server

One of the leading portal server in the market is Liferay . Its based on java and its one of the most successful portal server evolved ever. I have been working with liferay since 4 years. All these years I have seen it to evolve from a seed to a tree. It supports all the major technologies in the market be it .net or java or grails. You name it Liferay supports it for you . The most important thing that liferay supports is the Ajax-ability. It makes the server more dynamic and robust. Many tecnhology majors have chosen liferay as a solution for their tech needs. Right now I am working on a SOA based project with liferay and icefaces.

www.liferay.com

My Blog List