CalendarXP.net Support Forum Index CalendarXP.net Support
Most forums here are private and invisible to public.
 
 FAQFAQ   SearchSearch   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Load Agendas from Backend using Java Servlets and Beans

 
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> FlatCalendarXP Related
View previous topic :: View next topic  
Author Message
jmoran



Joined: 10 Apr 2006
Posts: 16

PostPosted: Tue Apr 11, 2006 6:03 pm    Post subject: Load Agendas from Backend using Java Servlets and Beans Reply with quote

Hi -

I utilize Java Servlets/JSP's for my website. I would like to load month to month basis using Servlets to query backend and fill up a JavaBean which I can than pass to the JSP. How do I integrate this technology. I see the tutorial/demo using DB connections in the JSP but I need to do all backend queries from Servlet.

Thanks so much!!
Back to top
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Tue Apr 11, 2006 6:33 pm    Post subject: Reply with quote

Well, you just need to change the fLoadScript() call in fLoadEvents() function to use an URL to your servlet instead of jsp. e.g.
Code:
function fLoadEvents(y,m) {
  if (fGetEvent(y,m,0)==null) {
    fAddEvent(y,m,0,"Loaded"); // mark the month as loaded
    fLoadScript("/getAgenda.do?year="+y+"&month="+m);
  }
}

Of course, your servlet "/getAgenda.do" should have code to retrieve the events data from backend db according to the month passed in and forward the data beans to a jsp page to render an agenda.js output.

NOTE: please don't forget to set the content-type header of your jsp. e.g.
Code:
<%@ page contentType="text/javascript" %>

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
jmoran



Joined: 10 Apr 2006
Posts: 16

PostPosted: Tue Apr 11, 2006 7:44 pm    Post subject: Reply with quote

okay so let me make sure I understand this. When I load page initially, i point to calendar.html which includes the iframe code (with or without the agenda file specified?)

<iframe name="gToday:mockup::gfFlat" id="gToday:mockup::gfFlat" src="../javascript/calendar/iflateng.htm" scrolling="no" frameborder="0"></iframe>

Then I change the fLoadScript to call my servlet and I forward where??? Back to calendar.html or back to the agenda file or back to a new jsp page??

Thanks for the help.
Back to top
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Tue Apr 11, 2006 8:30 pm    Post subject: Reply with quote

1st, it doesn't matter whether or not to use the agenda.js in iframe tag any more since we are going to load it dynamically later. I'd suggest you keep it but remove all fAddEvent() calls inside and only leave the fHoliday() function there.

2nd, use fLoadScript() to call your servlet and then in your server-side code forward to a JSP page that will generate javascripts content using the data beans provided by your servlet. e.g. Here is a quick example about what's inside this JSP page:
Code:
<%@ page contentType="text/javascript" %>
<% java.lang.ArrayList dataBeans = request.getAttribute("agendas"); %>
<% for (int i=0; i<dataBeans.size(); i++) { %>
fAddEvent(<%=((pkg.AgendaBean) dataBeans.get(i)).getYear() %>,
<%=((pkg.AgendaBean) dataBeans.get(i)).getMonth() %>,
<%=((pkg.AgendaBean) dataBeans.get(i)).getDate() %>,
...);
<% } %>

That's it. The generated content of this JSP page will go directly into the fLoadScript() instead of you browser.

Hope it helps.

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
jmoran



Joined: 10 Apr 2006
Posts: 16

PostPosted: Tue Apr 11, 2006 8:32 pm    Post subject: Reply with quote

Thanks so much.

I got it (meaning I understand it)
Now I am going to try to code it Smile

I'll post again if I run into any troubles.

Again thanks for the help
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> FlatCalendarXP Related All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Copyright 2003- Idemfactor Solutions, Inc. All rights reserved.
Powered by phpBB © 2001, 2005 phpBB Group