Friday, November 21, 2008

Intrenationalization in Jasper Reports

You need

1. Either compiled jrxml or jasper report

2. Add JRParameter locale parameter to desired one and populate the map.

3. Get the windows language pack installed in your system.

4. Publish report as html with api methods.

5. Now view report in desires languages by changing view-encoding- desired language in IE.

Still working with pdf, soon publish.
Cheers!
Ravinder

Tuesday, November 11, 2008

Developing JSF Custom Components

Well those of you who have used JSF components must be very happy with the reduction of UI efforts which were mostly struggling with html tags like , it was boring and it was like big pain.

But somewher some one is writing some piece of code so that we can use it...

Let's see what it take to write a custom component, in the example below we shall be writing a Look Up Component

Desc:

The Main Idea is to frame a Custom Component based on the existing Standard Components Input Text Field and Command Link. These two standard components look like a single component. The Functionality involved in this component is when you click the Command Link it should show a pop up window containing list of values. After selecting a value in the pop up window that selected value (or) values should come in to the Input Text Field.



1) LookupComponent.java

It provides the core functionality of the component. This class will implement the following method(s).
public String getFamily()
public Object saveState(FacesContext context)
public void restoreState(FacesContext context, Object state)



2) LookupComponentTag.java
It enables the execution of the UI Component from a JSP Page. This class will implement the following method(s).
public String getComponentType()
public String getRendererType()
public void setInputfield(String inputfield)
public void release()
protected void setProperties(UIComponent component)

3) LookupRenderer.java
It is used to add the existing standard components to a parent called component and renders them.
private void removeOldChildren(UIComponent component)
public void encodeBegin(FacesContext context, UIComponent component)
public void encodeChildren(FacesContext context, UIComponent component)
public boolean getRendersChildren()
public void encodeEnd()


4) faces-config.xml.
4.1) Specify elements in above xml with component name and corresponding class name.
4.2) Specify renderer elements


The getFamily() method of LookupComponent.java file associates the tag to give the control to the LookupRenderer.java file; it must be registered in faces-config.xml file. The getRendererType() method of LookupComponentTag.java file associates the tag which is used to identify the rendererType, so it must be registered in faces-config.xml file.


5) Lookup-taglib.tld
Specify component in tld with Tag name and correponding Tag class with attributes.

Now the component can be invoked in a JSP page like any other tag.


Thats all need to be done, n we r all set.

Cheers n Njoi!!!!

-R K Takshak

SOA India - 2008

SOA India 2008 is here again with the seminar with renowed techno evangelist like Paul Allen, Axel Angeli, Frank Mueller and Yasmine Limberger to name few.













contact anirbank@sda-asia.com or info@soaindia.com for Free Gate Pass*
website: http://www.soaindia.com/
*Only for individuals, for corporates fee ranges from 6K to 13K