Posts

Showing posts from September, 2017

Trim Leading and Trailing spaces from InputText on tab out.

Image
Hi, Here I would like to explain one use case to remove Leading and Trailing spaces from input text. Use case: On tab out of input text box, leading and trailing spaces should be removed. To implement this use case I have written custom converter which will do this work. But I need to refresh my component inside the converter code in order to reflect the changes on tab out. There are many use ways to implement this. Below is my way. Create Custom Converter class by implementing javax.faces.convert.Converter import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import org.apache.myfaces.trinidad.context.RequestContext; public class TrimEndSpacesConverter implements Converter{     public TrimEndSpacesConverter() {         super();     }          public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String string)        {             if (string != null) {                 //