Designing and Implementing Composite Applications : webMethods CAF and OpenCAF Development Help : Using Converters and Validators : Create a Custom Converter
Create a Custom Converter
You can create your own converter. However, creating a converter requires Java coding experience. The Composite Application Framework provides some initial code to get you started. A custom converter is valid only for the portlet in which it is created. If you plan to use a particular converter in many portlets, you should create your own library and load it through the project.
To create a custom converter
1. In the UI Development perspective, in an opened Composite Application Framework application, drag a view to the canvas to update.
2. In the design canvas, select the control getting a custom converter.
3. In the Property view, click the General tab, in the ID field, type a unique identifier for the converter, and click away from the view.
4. In the design canvas, right-click the control and then click Lifecycle > Custom Converter.
Composite Application Framework creates Java code in the managed bean and opens a Java editor to the location of the code. An example of converter code created for an input control is shown here:
public javax.faces.convert.Converter getInputID_converter()
{
return new javax.faces.convert.Converter()
{
/**
* Convert the input Object into a string.
*/
public String getAsString( javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component, java.lang.Object value)
{
// TODO: Convert the Object to a String here.
return value.toString();
}
/**
* Convert the input String into an Object.
*/
public Object getAsObject( javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component, java.lang.String value)
{
// TODO: Convert the String to an Object here.
return "New Object: "+ value;
}
};
}
5. After the TODO comments, add the Java code required for the converter.
Copyright © 2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback