Click
  1. Click
  2. CLK-374

Class java.lang.ClassCastException on a Select List with OptionGroup

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4.1
    • Fix Version/s: 1.5 M3
    • Component/s: core
    • Labels:
      None
    • Environment:
      Linux Apache mySQL Java

      Description

      Hi,
      This error appears when i use in a form a Select List with Option Group
      It appears not at the first time, but at the second time

      Exception
      Class java.lang.ClassCastException
      Message net.sf.click.control.OptionGroup
      731: if (getValue().length() == 0)

      { 732: setErrorMessage("select-error"); 733: 734: }

      else {
      735: if (getOptionList().isEmpty())

      { 736: String msg = "Mandatory Select field " + getName() 737: + " has no options to validate the request against"; 738: throw new RuntimeException(msg); 739: }

      740:
      741: Option firstOption = (Option) getOptionList().get(0);
      742:
      743: if (firstOption.getValue().equals(getValue()))

      { 744: setErrorMessage("select-error"); 745: }

      746: }
      747: }
      748: }
      749: }
      750:
      751: // ------------------------------------------------------ Protected Methods

      java.lang.ClassCastException: net.sf.click.control.OptionGroup
      at net.sf.click.control.Select.validate(Select.java:741)
      at net.sf.click.control.Field.onProcess(Field.java:853)
      at net.sf.click.control.FieldSet.onProcess(FieldSet.java:536)
      at net.sf.click.control.Form.onProcess(Form.java:1718)
      at net.sf.click.ClickServlet.processPage(ClickServlet.java:555)
      at net.sf.click.ClickServlet.handleRequest(ClickServlet.java:356)
      at net.sf.click.ClickServlet.doPost(ClickServlet.java:306)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
      at java.lang.Thread.run(Unknown Source)

      Here is my source code :

      List localOptions = new ArrayList();
      Select localSelect = new Select("local.numLocal","Lieu de travail");

      List<Local> listCollege = new LocalDAO().findByCommuneAndType(communeSelect.getValue(),"Collège");
      List<Local> listSSD = new LocalDAO().findByCommuneAndType(communeSelect.getValue(),"SSD");
      List<Local> listPMI = new LocalDAO().findByCommuneAndType(communeSelect.getValue(),"PMI");
      List<Local> listCDDS = new LocalDAO().findByCommuneAndType(communeSelect.getValue(),"CDDS");
      List<Local> listCGVO = new LocalDAO().findByCommuneAndType(communeSelect.getValue(),"CGVO");

      if (!listCollege.isEmpty()) {
      OptionGroup college = new OptionGroup("Collège");
      for (Iterator iter = listCollege.iterator(); iter.hasNext()

      { Local element = (Local) iter.next(); college.add(new Option(element.getNumLocal(),element.getLibLocal())); }

      localOptions.add(college);
      }

      if (!listSSD.isEmpty()) {
      OptionGroup ssd = new OptionGroup("SSD");
      for (Iterator iter = listSSD.iterator(); iter.hasNext()

      { Local element = (Local) iter.next(); ssd.add(new Option(element.getNumLocal(),element.getLibLocal())); }

      localOptions.add(ssd);
      }

      if (!listPMI.isEmpty()) {
      OptionGroup pmi = new OptionGroup("PMI");
      for (Iterator iter = listPMI.iterator(); iter.hasNext()

      { Local element = (Local) iter.next(); pmi.add(new Option(element.getNumLocal(),element.getLibLocal())); }

      localOptions.add(pmi);
      }

      if (!listCDDS.isEmpty()) {
      OptionGroup cdds = new OptionGroup("CDDS");
      for (Iterator iter = listCDDS.iterator(); iter.hasNext()

      { Local element = (Local) iter.next(); cdds.add(new Option(element.getNumLocal(),element.getLibLocal())); }

      localOptions.add(cdds);
      }

      if (!listCGVO.isEmpty()) {
      OptionGroup cgvo = new OptionGroup("CGVO");
      for (Iterator iter = listCGVO.iterator(); iter.hasNext()

      { Local element = (Local) iter.next(); cgvo.add(new Option(element.getNumLocal(),element.getLibLocal())); }

      localOptions.add(cgvo);
      }
      localSelect.setOptionList(localOptions);
      localSelect.setRequired(true);

        Activity

          People

          • Assignee:
            Bob Schellink
            Reporter:
            Christophe FOIRET
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development