This dont work... :S
i have this now :
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
List result = session.createQuery("from Schedule").list();
session.getTransaction().commit();
for (Iterator it = result.iterator(); it.hasNext();) {
ScheduleEntry event = (ScheduleEntry) it.next();
System.out.println("***" + event.getDescription() + "***");
}
the list result have the values, but the cicle for doesnt work!!! why? i
think its correct!
this is very hard, i'm becoming desesparated... Anyone never put a data base
in schedule? :(
This is the errors:
java.lang.ClassCastException: org.apache.myfaces.examples.schedule.Schedule
cannot be cast to org.apache.myfaces.custom.schedule.model.ScheduleEntry
at
org.apache.myfaces.custom.schedule.model.SimpleScheduleModel.loadEntries(SimpleScheduleModel.java:229)
at
org.apache.myfaces.custom.schedule.model.AbstractScheduleModel.load(AbstractScheduleModel.java:443)
at
org.apache.myfaces.custom.schedule.model.AbstractScheduleModel.setMonth(AbstractScheduleModel.java:282)
at
org.apache.myfaces.custom.schedule.model.AbstractScheduleModel.setSelectedDate(AbstractScheduleModel.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.myfaces.el.PropertyResolverImpl.setProperty(PropertyResolverImpl.java:409)
at
org.apache.myfaces.el.PropertyResolverImpl.setValue(PropertyResolverImpl.java:176)
at
org.apache.myfaces.config.ManagedBeanBuilder.initializeProperties(ManagedBeanBuilder.java:189)
at
org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:55)
at
org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:314)
at
org.apache.myfaces.examples.accessedbeans.AccessTrackingVariableResolver.resolveVariable(AccessTrackingVariableResolver.java:46)
at
org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:570)
at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
at
org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:386)
at
org.apache.myfaces.config.impl.digester.elements.ManagedProperty.getRuntimeValue(ManagedProperty.java:130)
at
org.apache.myfaces.config.ManagedBeanBuilder.initializeProperties(ManagedBeanBuilder.java:170)
at
org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:55)
at
org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:314)
at
org.apache.myfaces.examples.accessedbeans.AccessTrackingVariableResolver.resolveVariable(AccessTrackingVariableResolver.java:46)
at
org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:570)
at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:140)
at
org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:386)
at
org.apache.myfaces.application.ApplicationImpl.createComponent(ApplicationImpl.java:427)
at
javax.faces.webapp.UIComponentTag.createComponentInstance(UIComponentTag.java:709)
at
javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:596)
at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:315)
at
org.apache.jsp.mes_jsp._jspx_meth_s_005fschedule_005f0(mes_jsp.java:381)
at org.apache.jsp.mes_jsp._jspx_meth_s_005fdiv_005f2(mes_jsp.java:338)
at org.apache.jsp.mes_jsp._jspx_meth_h_005fform_005f0(mes_jsp.java:164)
at org.apache.jsp.mes_jsp._jspx_meth_f_005fview_005f0(mes_jsp.java:120)
at org.apache.jsp.mes_jsp._jspService(mes_jsp.java:84)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)
at
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at
org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:419)
at
org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:211)
at
org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
at
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
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:870)
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:685)
at java.lang.Thread.run(Unknown Source)
Jurgen Lust-2 wrote:
>
> This line in your code is incorrect:
>
> scheduleItems.add(new SelectItem(scheduleResult.get(i).toString()));
>
> You should replace it with:
>
> ScheduleEntry entry = new ScheduleEntry();
> entry.setId(scheduleResult.get(i).getId());
> entry.setStartTime(scheduleResult.get(i).getStartTime());
> ...
> entries.add(entry);
>
> Jurgen
>
> Op woensdag 01-08-2007 om 11:25 uur [tijdzone -0700], schreef
> ignicolist:
>> Hi again, but i cant make it! :-((
>>
>>
>> i have this:
>>
>>
>> private ArrayList scheduleItems = new ArrayList();
>>
>> List scheduleResult = session.createQuery("select s.id, s.description,
>> s.comments, s.endTime, s.startTime, s.subtitle, s.title, s.isAllDay from
>> " +
>> "Schedule as s").list();
>>
>> session.getTransaction().commit();
>>
>> for(int i = 0; i < scheduleResult.size();i++){
>> scheduleItems.add(new
>> SelectItem(scheduleResult.get(i).toString()));
>>
>> entries.add(scheduleItems);
>> }
>>
>> why i cant make: entries.add(scheduleItems); ? how do you thik i must do
>> it? i am out of ideas!!
>>
>> the méthod loadEntries, load entries when one or more entries are
>> introduced
>> right? so how to make to load the entries that are in data base in the
>> start?
>>
>> tks for all.
>>
>>
>>
>>
>>
>> Jurgen Lust-2 wrote:
>> >
>> > Aha, I see your problem: you are returning a list of SelectItems, which
>> > is wrong: you need a list of ScheduleEntry. You can find the source of
>> > ScheduleEntry here:
>> >
>> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/ScheduleEntry.java?revision=472638&view=markup
>> >
>> > Make sure that the id property of each ScheduleEntry is unique. You can
>> > use the database primary key for this.
>> >
>> > Jurgen
>> >
>> > Op woensdag 01-08-2007 om 06:42 uur [tijdzone -0700], schreef
>> > ignicolist:
>> >> Hi, first of all tks for your patience to me.
>> >>
>> >> i have this in loadEntries:
>> >>
>> >> private ArrayList scheduleItems = new ArrayList();
>> >>
>> >> if(scheduleItems.size() >=1){
>> >> scheduleItems.clear();
>> >> }
>> >> if(scheduleItems.size() >= 1){
>> >> scheduleItems.clear();
>> >> }
>> >> Session session =
>> >> HibernateUtil.getSessionFactory().getCurrentSession();
>> >> session.beginTransaction();
>> >>
>> >> List scheduleResult = session.createQuery("select
>> s.cod_evento,
>> >> s.location, s.comments, s.end, s.start, s.title from " +
>> >> "AddSchedule as s").list();
>> >>
>> >> session.getTransaction().commit();
>> >>
>> >> for(int i = 0; i < scheduleResult.size();i++){
>> >> scheduleItems.add(new
>> >> SelectItem(scheduleResult.get(i).toString()));
>> >>
>> >>
>> >>
>> System.out.println("***"+((SelectItem)scheduleItems.get(i)).getLabel()+"***");
>> >>
>> >> }
>> >>
>> >> the scheduleItems actualy have values, the read from data base works,
>> so
>> >> why
>> >> i cant just return scheduleItems variable? because i do that and don´t
>> >> work.
>> >> because the actual return variable is also a ArrayList.
>> >>
>> >> I real need this working, and i dont find anything to help me, its
>> very
>> >> few
>> >> information about this case. So i real tks you for every explanation.
>> And
>> >> real good work you did to this component! =)
>> >>
>> >>
>> >>
>> >> Jurgen Lust-2 wrote:
>> >> >
>> >> > Hmm, I think the getCurrentSession() will fail, because normally
>> there
>> >> > is no hibernate session when you start a request. Also the
>> transaction
>> >> > stuff isn't required, since it is only a read operation.
>> >> >
>> >> > Jurgen
>> >> >
>> >> > Op woensdag 01-08-2007 om 03:00 uur [tijdzone -0700], schreef
>> >> > ignicolist:
>> >> >> Hi, this is my loadentries in SimplesScheduleModel.java, can i do
>> >> this?
>> >> >> Is
>> >> >> this correct? Because it give me error. I want to know if this is
>> the
>> >> >> correct thing to do.
>> >> >>
>> >> >>
>> >> >>
>> >> >> protected Collection loadEntries(Date startDate, Date endDate)
>> >> >> {
>> >> >>
>> >> >> Session session =
>> >> HibernateUtil.getSessionFactory().getCurrentSession();
>> >> >> session.beginTransaction();
>> >> >>
>> >> >> List scheduleResult = session.createQuery("select s.cod_id,
>> >> >> s.location, s.comments, s.end, s.start, s.title from " +
>> >> >> "AddSchedule as s").list();
>> >> >>
>> >> >> session.getTransaction().commit();
>> >> >>
>> >> >> for(int i = 0; i < scheduleResult.size();i++){
>> >> >> scheduleItems.add(new
>> >> >> SelectItem(scheduleResult.get(i).toString()));
>> >> >>
>> >> >>
>> >> >> }
>> >> >>
>> >> >> return scheduleItems;
>> >> >>
>> >> >> }
>> >> >>
>> >> >>
>> >> >> Tks for all.
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> Jurgen Lust-2 wrote:
>> >> >> >
>> >> >> > Hi,
>> >> >> >
>> >> >> > In order to use a database as the source for the schedule, you
>> need
>> >> to
>> >> >> > write
>> >> >> > an implementation of the
>> >> >> > org.apache.myfaces.custom.schedule.model.ScheduleModel interface.
>> >> You
>> >> >> can
>> >> >> > extend the class
>> >> >> > org.apache.myfaces.custom.schedule.model.AbstractScheduleModel
>> for
>> >> >> > convenience. Now you just need to implement the methods
>> >> >> > loadEntries(Date,Date) and loadDayAttributes(Date). In the first
>> >> >> method,
>> >> >> > you
>> >> >> > load the entries for the specified period of time from the
>> database.
>> >> >> >
>> >> >> > Jurgen
>> >> >> >
>> >> >> > 2007/7/31, ignicolist <[EMAIL PROTECTED]>:
>> >> >> >>
>> >> >> >>
>> >> >> >> Hi, i am making a project using myfaces schedule. and everything
>> is
>> >> >> >> working
>> >> >> >> fine, but my problem is how i coud make the the entries of
>> schedule
>> >> >> could
>> >> >> >> be
>> >> >> >> read by a database?
>> >> >> >>
>> >> >> >> And how to put the views day,week and moth using the same model?
>> >> >> Because
>> >> >> >> if
>> >> >> >> i use diferent models the entries in day view for example dont
>> >> apear
>> >> >> in
>> >> >> >> month view!
>> >> >> >> --
>> >> >> >> View this message in context:
>> >> >> >> http://www.nabble.com/Schedule-tomahawk-tf4192737.html#a11923285
>> >> >> >> Sent from the MyFaces - Users mailing list archive at
>> Nabble.com.
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >>
>> >> >
>> >> >
>> >>
>> >
>> >
>>
>
>
--
View this message in context:
http://www.nabble.com/Schedule-tomahawk-tf4192737.html#a11966230
Sent from the MyFaces - Users mailing list archive at Nabble.com.