voyent
selectBooleanCheckBox doesn't convert?  XML
Forum Index -> Components
Author Message
Newlukai

Joined: 29/Nov/2006 00:00:00
Messages: 125
Offline


Hi,

I'm currently implementing a new feature for my app. For this I need some checkboxes. Those checkboxes represent flags of an entity bean. In this entity true is represented by "-1" and false by "0" (don't ask why, I don't know). I wrote a custom converter which does this conversion from "0", "-1" to "true", "false" and reverse. But it seems that the getAsObject() method is never invoked. If I use inputTexts it works fine.

What do you think about this?

Thanks in advance
Newlukai
Newlukai

Joined: 29/Nov/2006 00:00:00
Messages: 125
Offline


It seems to be a well-known JSF "bug" that the converter specified with a selectBooleanCheckbox isn't invoked while sending data from the client to the app. That means getAsObject is never called.

So I made a change to com.icesoft.faces.renderkit.dom_html_basic.CheckboxRenderer.getConvertedValue(). Would someone responsible for this please take a look at the changed code? I don't know much about the use cases this method is invoked, so I can't tell if it works in every case. ATM it works for me.

Code:
public Object getConvertedValue(FacesContext facesContext, UIComponent
             uiComponent, Object submittedValue) throws ConverterException {
 
         if (!(submittedValue instanceof String)) {
             throw new ConverterException(
                     "Expecting submittedValue to be String");
         }
 
         Object result = super.getConvertedValue(facesContext, uiComponent, submittedValue);
 
         if(result != null && !(result.equals(submittedValue))) {
         	return result;
       	}
 
       	return Boolean.valueOf((String) submittedValue);
     }
 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team