View previous topic :: View next topic |
Author |
Message |
jmoran
Joined: 10 Apr 2006 Posts: 16
|
Posted: Tue Apr 11, 2006 6:03 pm Post subject: Load Agendas from Backend using Java Servlets and Beans |
|
|
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 |
|
|
calendarxp Site Admin
Joined: 30 Jan 2005 Posts: 409
|
Posted: Tue Apr 11, 2006 6:33 pm Post subject: |
|
|
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 |
|
|
jmoran
Joined: 10 Apr 2006 Posts: 16
|
Posted: Tue Apr 11, 2006 7:44 pm Post subject: |
|
|
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 |
|
|
calendarxp Site Admin
Joined: 30 Jan 2005 Posts: 409
|
Posted: Tue Apr 11, 2006 8:30 pm Post subject: |
|
|
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 |
|
|
jmoran
Joined: 10 Apr 2006 Posts: 16
|
Posted: Tue Apr 11, 2006 8:32 pm Post subject: |
|
|
Thanks so much.
I got it (meaning I understand it)
Now I am going to try to code it
I'll post again if I run into any troubles.
Again thanks for the help
|
|
Back to top |
|
|
|