I have a bean:
@ManagedBean(name = "bExam")
@SessionScoped
public class BExam implements Serializable
{
private List<Category> categories;
private List<Category> categoriesSelected;
public BExam() {
categories = CategoryDb.getAll(); // there is ok. Categories has filled right.
categoriesSelected = new ArrayList<>();
getters & setters...
}
There is converter:
@FacesConverter("categoryConverter")
public class CategoryConverter implements Converter<Category> {
@Override
public Category getAsObject(FacesContext fc, UIComponent uic, String string) {
...
}
@Override
public String getAsString(FacesContext fc, UIComponent uic, Category t) {
return String.valueOf(t.getId());
}
}
There is selectManyCheckbox:
<h:selectManyCheckbox id="categories" value="#{bExam.categoriesSelected}" converter="categoryConverter">
<f:selectItems
value="#{bExam.categories}"
var="category"
itemLabel="#{category.name}"
itemValue="#{category}"/>
</h:selectManyCheckbox>
And this is Category model:
public class Category implements Serializable
{
private int id;
private String name;
private int sortOrder;
private int categorySetId;
getters & setters...
}
Checkboxes are builds right. When i click on any of them, in getAsObject in string parameter i always get "on".

What's happening there? Why this string comes exactly? And how solve it?
This is the browser default value for a checked checkbox without value. This will be used when HTML
<input type="checkbox">doesn't have avalueattribute or it is empty.By default, JSF renders
getAsString()value there. So, it can happen when the actual converter returnsnullor an empty string ingetAsString(). It can also happen when the (default) HTMLRendererassociated with the<h:selectManyCheckbox>is being overridden in an incorrect manner, or is even corrupted (e.g. the default HTMLRendererassociated with<h:selectBooleanCheckbox>is in some way being used instead).The cause of the problem is not visible in the information provided so far, but your first step is putting a debug breakpoint in
getAsString()of the converter and explore the call stack which renderer called it, and inspect which value the converter returns.