jsf - h:selectManyCheckbox converter's getAsObject always retrieves "on" as submitted value -


i have bean:

@managedbean(name = "bexam") @sessionscoped public class bexam implements serializable {     private list<category> categories;     private list<category> categoriesselected;      public bexam() {          categories = categorydb.getall(); // there ok. categories has filled right.         categoriesselected = new arraylist<>();          getters & setters...  } 

there 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 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 category model:

public class category implements serializable {      private int id;      private string name;      private int sortorder;      private int categorysetid;       getters & setters... } 

checkboxes builds right. when click on of them, in getasobject in string parameter "on". enter image description here

what's happening there? why string comes exactly? , how solve it?

when click on of them, in getasobject in string parameter "on"

this browser default value checked checkbox without value. used when html <input type="checkbox"> doesn't have value attribute or empty.

by default, jsf renders getasstring() value there. so, can happen when actual converter returns null or empty string in getasstring(). can happen when (default) html renderer associated <h:selectmanycheckbox> being overridden in incorrect manner, or corrupted (e.g. default html renderer associated <h:selectbooleancheckbox> in way being used instead).

the cause of problem not visible in information provided far, first step putting debug breakpoint in getasstring() of converter , explore call stack renderer called it, , inspect value converter returns.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -