I need to create a custom Component with JSF 2.0 (not composite component), that is similar to a SelectManyCheckbox, but has a different UI. I try to do this by subclassing UISelectMany and creating a new custom Renderer.
What I don’t understand is, how is the input data on the client passed through the Component into the Bean. There must be a way to collect the http params from the POST, put it in a List and set the List in the Bean.
edited
What I already tried is similar to this:
public void decode(FacesContext context, UIComponent component) {
if ((context == null) || (component == null)) {
throw new NullPointerException();
}
MapComponent map = (MapComponent) component;
String key = getName(context, map);
String value = (String)context.getExternalContext().
getRequestParameterMap().get(key);
if (value != null)
map.setCurrent(value);
}
}
I can see in the debugger, that my http-params are fetched correctly. I can also see, that my custom Converter will be called after that. But the values do not reach the Bean. But I can see a unspecific validation error in the log.
After reading some tutorials on the net I still don’t understand how this works. There must be some glue-code, that takes the converted value and passes it to the setter in the Bean. Does anybody know how this works?
Thanks
Jan
This is normally to be done in
decode()method of theRendererclass. In case of Mojarra, it’s thecom.sun.faces.renderkit.html_basic.MenuRendererclass. Just download the source and peek in there how it’s to be done.Basically, you just grab the request parameter values associated with the component’s client ID as parameter name and then set it as submitted value by the
UIInput#setSubmittedValue().(of course you need to do some validation beforehand; again, check the original source code)