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

        Christophe FOIRET created issue -
        Hide
        Christophe FOIRET added a comment -

        Please, could you answer to my issue ?
        Thanks

        Show
        Christophe FOIRET added a comment - Please, could you answer to my issue ? Thanks
        Hide
        Bob Schellink added a comment -

        Hi Christophe,

        I can confirm this is a bug. Will be fixed for 1.5-M3

        Show
        Bob Schellink added a comment - Hi Christophe, I can confirm this is a bug. Will be fixed for 1.5-M3
        Bob Schellink made changes -
        Field Original Value New Value
        Fix Version/s 1.5 M3 [ 10030 ]
        Bob Schellink made changes -
        Assignee Malcolm Edgar [ medgar ] Bob Schellink [ sabob ]
        Hide
        Bob Schellink added a comment -

        fixed in trunk, will be available in 1.5-M3

        Show
        Bob Schellink added a comment - fixed in trunk, will be available in 1.5-M3
        Bob Schellink made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Henri Yandell made changes -
        Project Import Fri Mar 20 14:11:32 PDT 2009 [ 1237583492744 ]
        Hide
        Parth Joshi added a comment - - edited

        I am still getting the error in 2.3 release

        The code goes like this:

        public class EducationSelectDataProvider implements DataProvider<Option> {

        @Override
        public List<Option> getData() {
        List optionGroups1 = new ArrayList();

        List<Educationtypemaster> list = new GenericMasterDBHomeExtra<Educationtypemaster>(
        Educationtypemaster.class).getAll();
        for (Educationtypemaster educationtypemaster : list) {
        System.out.println(educationtypemaster.getEtname()+" ------ ");
        OptionGroup op=new OptionGroup(educationtypemaster.getEtname());
        // op.add(new Option(value));
        Set<Educationtitlemaster> educationtitlemasters = educationtypemaster.getEducationtitlemasters();
        for (Educationtitlemaster educationtitlemaster : educationtitlemasters)

        { System.out.println(educationtitlemaster.getId().getEname()); op.add(new Option(educationtitlemaster.getId().getEno(),educationtitlemaster.getId().getEname())); }

        optionGroups1.add(op);
        }
        return optionGroups1;
        }

        }

        Show
        Parth Joshi added a comment - - edited I am still getting the error in 2.3 release The code goes like this: public class EducationSelectDataProvider implements DataProvider<Option> { @Override public List<Option> getData() { List optionGroups1 = new ArrayList(); List<Educationtypemaster> list = new GenericMasterDBHomeExtra<Educationtypemaster>( Educationtypemaster.class).getAll(); for (Educationtypemaster educationtypemaster : list) { System.out.println(educationtypemaster.getEtname()+" ------ "); OptionGroup op=new OptionGroup(educationtypemaster.getEtname()); // op.add(new Option(value)); Set<Educationtitlemaster> educationtitlemasters = educationtypemaster.getEducationtitlemasters(); for (Educationtitlemaster educationtitlemaster : educationtitlemasters) { System.out.println(educationtitlemaster.getId().getEname()); op.add(new Option(educationtitlemaster.getId().getEno(),educationtitlemaster.getId().getEname())); } optionGroups1.add(op); } return optionGroups1; } }

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development