Use of converters  XML
Forum Index -> General Help
Author Message

Joined: 12/May/2009 00:00:00
Messages: 37

I have a simple converter that I use to translate an ISO language code (e.g. "en", "fr") into its equivalent text in its own language (e.g. "English", "fran├žais"). Because the converter doesn't work on an object, it has a simple "@FacesConverter" annotation with no associated type.

The "getString" method returns the name of the language and the "getObject" method throws UnsupportedOperationException.

I have a form with an <ace:textEntry> component. When I submit the form, I get an exception thrown from the converter's getObject() method, even though that converter is not associated with the text entry component. I took a look at the code up the stack trace and it seems that the text entry component is looking at all registered components even though they're not associated with the object.

Is there a reason for this? I have had to disable this converter for now.

Joined: 02/Jan/2009 00:00:00
Messages: 151

Do u have a bit of Sample Code?

May the converter and its use?

Thanks and regards

Joined: 12/May/2009 00:00:00
Messages: 37

It's probably going to be too much to create a sample case, but here's the basic outline:

- create a converter annotated with @FacesConverter (no parameters)

- put "throw new UnsupportedOperationException()" into each method

- deploy to a web application that has an "ace:textEntry" component in a form

- submit the form

The problem code is in org.icefaces.ace.renderkit.InputRenderer starting at line 130:

 	public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException {
 		UIInput uiInput = (UIInput) component;
 		String value = (String) submittedValue;
 		Converter converter = uiInput.getConverter();
 		//first ask the converter
 		if(converter != null) {
 			return converter.getAsObject(context, uiInput, value);
 		//Try to guess
 		else {
             ValueExpression ve = uiInput.getValueExpression("value");
             if(ve != null) {
                 Class<?> valueType = ve.getType(context.getELContext());
                 Converter converterForType = context.getApplication().createConverter(valueType);
                 if(converterForType != null) {
                     return converterForType.getAsObject(context, uiInput, value);
 		return value;

The way the "else" clause is written, it will pick up any unqualified FacesConverter.
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team