on 01-21-2009 5:38 AM
Hi all,
I am getting this exception, java.lang.ClassCastException when I try to filter a date field in my table.
The filter works fine on other columns of the table which are not of type date.
I have created a simple-type called myDate which is of type date. The type of the date field in my table is bound to this type myDate.
Here is the full exception chain,
java.lang.ClassCastException
at com.sap.tc.webdynpro.progmodel.context.NodeElement.wdpGetString(NodeElement.java:629)
at com.sap.tc.webdynpro.progmodel.context.NodeElement.wdGetString(NodeElement.java:800)
at com.sap.tc.webdynpro.progmodel.context.AttributePointer.getString(AttributePointer.java:176)
at com.sap.tc.webdynpro.clientserver.data.DataContainer.getString(DataContainer.java:915)
at com.sap.tc.webdynpro.clientserver.uielib.standard.impl.TableColumn.getFilterValue(TableColumn.java:496)
at com.sap.tut.webdynpro.admin.FilterTable.prepareFilterValuesByAttribute(FilterTable.java:257)
at com.sap.tut.webdynpro.admin.FilterTable.filter(FilterTable.java:149)
at com.sap.tut.webdynpro.admin.AdministrationView.onActionFilter(AdministrationView.java:1133)
at com.sap.tut.webdynpro.admin.wdp.InternalAdministrationView.wdInvokeEventHandler(InternalAdministrationView.java:210)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doHandleActionEvent(WindowPhaseModel.java:420)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:132)
at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)
at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:143)
at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:321)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingPortal(ClientSession.java:733)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:668)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:250)
at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:150)
at com.sap.tc.webdynpro.clientserver.session.core.ApplicationHandle.doProcessing(ApplicationHandle.java:73)
at com.sap.tc.webdynpro.portal.pb.impl.AbstractApplicationProxy.sendDataAndProcessActionInternal(AbstractApplicationProxy.java:860)
at com.sap.tc.webdynpro.portal.pb.impl.localwd.LocalApplicationProxy.sendDataAndProcessAction(LocalApplicationProxy.java:77)
at com.sap.portal.pb.PageBuilder.updateApplications(PageBuilder.java:1255)
at com.sap.portal.pb.PageBuilder.SendDataAndProcessAction(PageBuilder.java:325)
at com.sap.portal.pb.PageBuilder$1.doPhase(PageBuilder.java:826)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processPhaseListener(WindowPhaseModel.java:755)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doPortalDispatch(WindowPhaseModel.java:717)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:136)
at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)
at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:143)
at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:321)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:713)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:666)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:250)
at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:150)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
Please help me solve this. Thanks in advance.
Regards
Kishan
check the data type of "myDate " and its destination where you are binding it both should be date type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kishan,
You need to change the node type to String else it will give you class cast exception.
Regards
Narendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kishan,
Are you still getting class cast exception?
Yes filter can be applied to this as we have just changed the type from date to String,
So i should work as per my knowledge.
Can you please explain what error you are getting now.
Regards
Narendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kishan,
if(colType[i-1].equalsIgnoreCase("ddic:com.sap.tut.wd.languages.myDate"))
String dateFormat="yyyyMMdd";// according to the date format you are using like 22-11-2009 should be dd-MM-yyyy
SimpleDateFormat dateformatYYYYMMDD = new SimpleDateFormat(dateFormat);
String date = dateformatYYYYMMDD.format( resultSet.getDate(colName[i-1]) ) ;
tableElement.setAttributeValue(colName[i-1],date);
please chcek if this works
Regards
Narendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Narendra,
I followed your instructions. But I have the following doubts,
1)
tableElement.setAttributeValue(colName[i-1],date);
As per this code given by you, won't I get a Type Mismatch exception since I am setting a String value to an attribute of type date.
2)Can a table-filter be applied to this date field created as instructed by you?
Regards
Kishan
Hi Kishan,
I think You need to first convert the date type to String and then you can apply the filter without the class cast exception..
below is the code you can use for converting date to String.
//pass the format of the date you are using
String dateFormat="yyyyMMdd";
SimpleDateFormat dateformatYYYYMMDD = new SimpleDateFormat(dateFormat);
String date = dateformatYYYYMMDD.format( dateNow ) ;
Hope this will help
Regards
Narendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Narendra,
Thanks for the quick reply.
Where do I need to add the code you mentioned?
I am setting the attribute of type date as below,
if(colType[i-1].equalsIgnoreCase("ddic:com.sap.tut.wd.languages.myDate"))
tableElement.setAttributeValue(colName[i-1],resultSet.getDate(colName[i-1]));
Regards
Kishan
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.