title: java.lang.NumberFormatException: For input string: "type"
body: <p>This is my code which executes two methods:</p>
  
  <pre><code>&lt;h:panelGroup&gt; &lt;br /&gt;&lt;br /&gt;  
      &lt;h:outputLabel id="yearLbl" value="Year:" /&gt;
      &lt;h:outputLabel id="selectType" /&gt;&lt;br /&gt;
      &lt;h:selectOneMenu id="type" value="#{clController.type}"&gt;
          &lt;f:selectItem itemValue="2013" itemLabel="2013" /&gt;
          &lt;f:selectItem itemValue="2012" itemLabel="2012" /&gt;
          &lt;f:selectItem itemValue="2011" itemLabel="2011" /&gt;
          &lt;f:selectItem itemValue="2010" itemLabel="2010" /&gt;
          &lt;f:selectItem itemValue="2009" itemLabel="2009" /&gt;
          &lt;f:selectItem itemValue="2008" itemLabel="2008" /&gt;
      &lt;/h:selectOneMenu&gt;
      &lt;h:commandButton type="submit" onclick="#{clController.getTotal(clController.type)}" action="#{clController.getPaymentByMonth(clController.type)}"  id="stateInfo"  value="Show Monthly "  &gt;              
      &lt;/h:commandButton&gt;
  &lt;/h:panelGroup&gt;
  </code></pre>
  
  <p>These are the functions called: </p>
  
  <pre><code>public DataModel getPaymentByMonth(String year) {            
      this.session = HibernateUtil.getSessionFactory().getCurrentSession();
  
      List&lt;CustomerPayment&gt; paymentList = null;
      try {
          org.hibernate.Transaction tx = session.beginTransaction();
          Query q = session.createQuery("from CustomerPayment where DATE like '%" + year + "'");
          paymentList = (List&lt;CustomerPayment&gt;) q.list();
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      return paymentDataModel = new ListDataModel(paymentList);    
  }
  
  public DataModel getTotal(String year) {
      this.session = HibernateUtil.getSessionFactory().getCurrentSession();
  
      List&lt;CustomerPayment&gt; total = null;
      try {
          org.hibernate.Transaction tx = session.beginTransaction();
          System.out.println(year);
          Query q = session.createQuery("select c.type, c.date, sum(c.amount) from CustomerPayment c  where c.date  LIKE '%"+year+"' group by c.type");
          System.out.println("select c.type, c.date, sum(c.amount) from CustomerPayment c  where c.date  LIKE '%"+year+"' group by c.type");
          total = (List&lt;CustomerPayment&gt;) q.list();
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      return totalDataTable = new ListDataModel(total);    
  }
  </code></pre>
  
  <p>The problem is that i get this error:</p>
  
  <pre><code>java.lang.NumberFormatException: For input string: "type"
  </code></pre>
  
  <p>The type means years but i gives error with that. When i print type into screen it prints for ex 2013 why i get this error?</p>
  
  <p>Full stack trace:</p>
  
  <pre><code>at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      at java.lang.Integer.parseInt(Integer.java:481)
      at java.lang.Integer.parseInt(Integer.java:514)
      at javax.el.ArrayELResolver.coerce(ArrayELResolver.java:166)
      at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:46)
      at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
      at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
      at org.apache.el.parser.AstValue.getValue(AstValue.java:183)
      at org.apache.el.parser.AstDeferredExpression.getValue(AstDeferredExpression.java:44)
      at org.apache.el.parser.AstCompositeExpression.getValue(AstCompositeExpression.java:50)
      at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
      at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
      at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
      at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
      at javax.faces.component.UIOutput.getValue(UIOutput.java:169)
      at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
      at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
      at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
      at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
      at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)
      at com.sun.faces.renderkit.html_basic.OutputLinkRenderer.encodeChildren(OutputLinkRenderer.java:124)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
      at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
      at com.sun.faces.renderkit.html_basic.TableRenderer.renderRow(TableRenderer.java:385)
      at com.sun.faces.renderkit.html_basic.TableRenderer.encodeChildren(TableRenderer.java:162)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
      at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
      at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
      at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
      at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:424)
      at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:679)
  </code></pre>