View Full Version : datepicker
fra800
10-18-2006, 01:51 AM
Hello to everybody.I need help from you. I built the following application: I have a datepicker and some appointments coming from a database (to select the appointments I use a jsp page), which must be shown under the datepicker. This I made it without problem (that is the datepicker and the selection of data), but now I indicate the problem:
When I select a date from a datepicker, the application must show me the appointments (that represent the data from the database), that happen only in the date I selected (if there is no appointment in that date, the application doen not have to show me anything).
How can I do this? My teacher told me that I must implement the function of datepicker called "onselecteddate", but how? Thank you
jrrobles
10-18-2006, 10:15 AM
you need to check the lzx reference:
http://www.laszlosystems.com/lps-3.3/docs/reference/index.html
fra800
10-23-2006, 04:45 AM
Thank you very much for your reply. But I woul like to know if I must do in the jsp page the selection with condition on the attribute day. If the reply is yes, I post my jsp I created with a "select from where" query (where is the condition on the day), because it does not run.
Does Laszlo support a where condition, when I create a jsp page containing a select query? Hello and thanks a lot. Here is a part of code:
<%java.sql.Date Giorno = java.sql.Date.valueOf("giorno");
// DATABASE CONNECTION
Connection connection = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // 1
connection = DriverManager.getConnection("jdbc:odbc:contatti"); // 2
// QUERY PREPARATION AND EXECUTION
PreparedStatement pstmt = connection.prepareStatement("SELECT appointment.*, Tabella2.*, day.*, contatti.* FROM [day] INNER JOIN (contatti INNER JOIN (appointment INNER JOIN Tabella2 ON appointment.idcontact=Tabella2.idcontact) ON contatti.id=Tabella2.id) ON day.idgiorno=appointment.id_giorno WHERE (((day.giorno)=[?]))");
pstmt.setDate(1, Giorno);
ResultSet rs = pstmt.executeQuery();
%>
jrrobles
10-23-2006, 11:13 AM
Ok I understand now, and yes you need to create a jsp to give you a xml with the result of the query, (or workout in laszlo the xml searching on the xml nodes, but the easy way is to call the jsp) the query have to be done on the 'onselectdate' of the calendar.
<dataset name="searchDate" src="myjsp.jsp" />
<calendar>
<method event="onselectdate" args="selecteddate">
searchDate.setQueryParam('giorno',selecteddate);
searchDate.doRequest();
</method>
</calendar>
Thats just and idea, maybe someone have another solution.
fra800
10-24-2006, 07:14 AM
Thank you jrrobles. I inserted the code you gave me in the program, but can I use in Laszlo a "SELECT FROM WHERE" query, because the jsp file, I also inserted, in this thread does not run. Can the problem be the date management? Good bye
jrrobles
10-24-2006, 09:22 AM
I dont understand very well...
Laszlo cant conect to a database you need the jsp to do that work, knowing that the sql query must be done on the jsp (or php, or whatever you use to make the conversation with the database), you need:
1) a jsp to catch the vars your send to make the query. In your example I saw It was giorno
'select from apointments where date='+ giorno;
something like that. You must be careful with the vars datatypes. Laszlo sends and get strings only, so in your jsp you need to transform the var to Date, or if its a number to a integer,float, and so on.
2) on the laszlo you add the vars with the addparameters to the dataset and then make the dorequest to bring the result, that must give you what you need.
fra800
10-24-2006, 11:14 AM
Tank you, but you speak about "addparameters" at the end of your post:
"on the laszlo you add the vars with the addparameters to the dataset"
The is "addparameters" made with
dset.setQueryParam(), or not?. Hello
jrrobles
10-24-2006, 02:28 PM
yep thats what I mean sorry if it make you trouble
fra800
10-25-2006, 06:18 AM
Thank you very much, but I want to ask you this: when you say "in your jsp you need to transform the var to Date, or if its a number to a integer,float, and so on", do you skeak about casting, or not? Thank you and good-bye
jrrobles
10-25-2006, 01:48 PM
yes I mean that, sorry
fra800
11-06-2006, 06:08 AM
Thank you, jrobbles.
fra800
11-06-2006, 07:44 AM
I need your help again. I want to know this: if I change the type of the attribute "giorno" from date/time to string (but if it is a string, it is always a date: it is a date string), at client-side can I always write this, or not?:
searchDate.setQueryParam('giorno', selecteddate);
searchDate.doRequest();
And because of this change my jsp becomes:
String Giorno = request.getParameter("giorno");
PreparedStatement mystmt = connection.prepareStatement("SELECT appointment.*, day.* FROM [day] INNER JOIN appointment ON day.idgiorno = appointment.id_giorno WHERE giorno = ?");
pstmt.setString(1, Giorno);
and not pstmt.setDate.
I want to know another thing: if I have in this jsp String Giorno = request.getParameter("giorno");, can I use this statement also in another jsp file linked to this?
fra800
11-08-2006, 07:14 AM
Hello, I don' t see any question, because, I think, I didn' t clarify well what I must do.
Now I changed the type of attribute "giorno" (giorno is an attribute of the database, which is Access) from date to Text type (or better the type is text, but when in access there is "maschera di input" I indicated "Data in cifre" and the format of the date is '00/00/0000") . I want to know if these statements change:
searchDate.setQueryParam('giorno', selecteddate);
searchDate.doRequest();
In jsp I had to indicate String Giorno = request.getParameter("giorno");
pstmt.setString(1, Giorno);
Thank you and good-bye
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.