validation - Changing the value of a f:selectItems to "" from a h:SelectOneMenu in JSF 2.15 causing problems -


according answer: validation error: value not valid

jsf default iterates values in f:selectitems check selected value in list initially.

currently have following

<select id="selectlist" size="1">     <option value="20" selected="selected">20</option>  <option value="50">50</option>  <option value="100">100</option> </select> 

if modify option 50

the mentioned validation jsf aplies.

however if modify option

<option value="">50</option> 

the validation not take places , in end servers ends crashing in contextawaretagvalueexpression.setvalue when tries set value of selectonemenu value

this happens when org.apache.el.parser.coerce_to_zero option set false, if option set true, validation takes places.

so question is, normal behavior? need org.apache.el.parser.coerce_to_zero option set false.

update:

this on myfaces jsf 2.1.5, apache tomcat 6.0.37, java 1.7.0_21

this current bean:  package com.test.bean;  import java.util.arraylist; import java.util.list;  import javax.faces.bean.managedbean; import javax.faces.bean.sessionscoped; import javax.faces.component.html.htmlselectonemenu; import javax.faces.event.valuechangeevent; import javax.faces.model.selectitem;  @managedbean @sessionscoped public class indexbean {     private int selectedvalue;     private int savevalue;      public void updatevalues(valuechangeevent ev){         try{             savevalue = integer.parseint(((htmlselectonemenu) ev.getcomponent()).getvalue().tostring());         } catch(exception ex){             return;         }     }      public list<selectitem> getrowsperpage(){         list<selectitem> rows = new arraylist<>();         rows.add(new selectitem(20,"20"));         rows.add(new selectitem(50,"50"));         return rows;     }      public int getselectedvalue() {         return selectedvalue;     }      public void setselectedvalue(int selectedvalue) {         this.selectedvalue = selectedvalue;     } } 

and xhtml page:

   <?xml version="1.0" encoding="iso-8859-1" ?>   <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"      xmlns:f="http://java.sun.com/jsf/core"      xmlns:h="http://java.sun.com/jsf/html"> <h:body> <f:view>     <h:form>         <h:selectonemenu value="#{indexbean.selectedvalue}" valuechangelistener="#{indexbean.updatevalues}" onchange="submit();">             <f:selectitems value="#{indexbean.rowsperpage}"></f:selectitems>         </h:selectonemenu>     </h:form> </f:view> </h:body> </html> 

initially updatevalues method throw nullpointerexception trying value of component, hence try catch, end following stack

sep 10, 2014 10:01:38 org.apache.catalina.core.standardwrappervalve invoke severe: servlet.service() servlet faces servlet threw exception java.lang.illegalargumentexception     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source)     @ java.lang.reflect.method.invoke(unknown source)     @ javax.el.beanelresolver.setvalue(beanelresolver.java:129)     @ javax.el.compositeelresolver.setvalue(compositeelresolver.java:69)     @ org.apache.myfaces.el.unified.resolver.facescompositeelresolver.setvalue(facescompositeelresolver.java:227)     @ org.apache.el.parser.astvalue.setvalue(astvalue.java:158)     @ org.apache.el.valueexpressionimpl.setvalue(valueexpressionimpl.java:249)     @ org.apache.myfaces.view.facelets.el.contextawaretagvalueexpression.setvalue(contextawaretagvalueexpression.java:153)     @ javax.faces.component.uiinput.updatemodel(uiinput.java:405)     @ javax.faces.component.uiinput.processupdates(uiinput.java:327)     @ javax.faces.component.uiform.processupdates(uiform.java:263)     @ javax.faces.component.uicomponentbase.processupdates(uicomponentbase.java:1372)     @ javax.faces.component.uicomponentbase.processupdates(uicomponentbase.java:1372)     @ javax.faces.component.uiviewroot._processupdatesdefault(uiviewroot.java:1338)     @ javax.faces.component.uiviewroot.access$600(uiviewroot.java:74)     @ javax.faces.component.uiviewroot$updatemodelphaseprocessor.process(uiviewroot.java:1453)     @ javax.faces.component.uiviewroot._process(uiviewroot.java:1299)     @ javax.faces.component.uiviewroot.processupdates(uiviewroot.java:799)     @ org.apache.myfaces.lifecycle.updatemodelvaluesexecutor.execute(updatemodelvaluesexecutor.java:38)     @ org.apache.myfaces.lifecycle.lifecycleimpl.executephase(lifecycleimpl.java:170)     @ org.apache.myfaces.lifecycle.lifecycleimpl.execute(lifecycleimpl.java:117)     @ javax.faces.webapp.facesservlet.service(facesservlet.java:197)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:290)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206)     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:233)     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:191)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:127)     @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:102)     @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:109)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:298)     @ org.apache.coyote.http11.http11processor.process(http11processor.java:859)     @ org.apache.coyote.http11.http11protocol$http11connectionhandler.process(http11protocol.java:588)     @ org.apache.tomcat.util.net.jioendpoint$worker.run(jioendpoint.java:489)     @ java.lang.thread.run(unknown source) 


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -