You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by "Parth Joshi (JIRA)" <ji...@apache.org> on 2012/07/31 10:38:35 UTC
[jira] [Comment Edited] (CLK-374) Class
java.lang.ClassCastException on a Select List with OptionGroup
[ https://issues.apache.org/jira/browse/CLK-374?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13425616#comment-13425616 ]
Parth Joshi edited comment on CLK-374 at 7/31/12 8:36 AM:
----------------------------------------------------------
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;
}
}
was (Author: joshiparthin):
I am still getting the error in 2.3 release
> Class java.lang.ClassCastException on a Select List with OptionGroup
> --------------------------------------------------------------------
>
> Key: CLK-374
> URL: https://issues.apache.org/jira/browse/CLK-374
> Project: Click
> Issue Type: Bug
> Components: core
> Affects Versions: 1.4.1
> Environment: Linux Apache mySQL Java
> Reporter: Christophe FOIRET
> Assignee: Bob Schellink
> Fix For: 1.5 M3
>
>
> 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);
>
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira