Hi,
I want to use my hibernate generate pojo java files in spring to complete my application.In Event.java (which I generated by hbm2java ant task)
two variables are, in which first is String type and other is Date type.
When I send these two variables using jsp welcome page to Event.java, I found error on jsp page can not parse String to required type Date.
I am still trying but not getting.
hbm2java generated code
Event.java ::
Code:
package events;
// Generated Jun 5, 2008 9:16:18 AM by Hibernate Tools 3.2.0.b9
import java.util.Date;
/**
* Event generated by hbm2java
*/
public class Event implements java.io.Serializable {
private long id;
private Date date;
private String title;
public Event() {
}
public Event(Date date, String title) {
this.date = date;
this.title = title;
}
public long getId() {
return this.id;
}
public void setId(long id) {
this.id = id;
}
public Date getDate() {
return this.date;
}
public void setDate(Date date) {
this.date = date;
}
public String getTitle() {
return this.title;
}
public void setTitle(String title) {
this.title = title;
}
}
welcome form
hello.jsp ::
Code:
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<%@ taglib prefix="spring" uri="/spring" %>
<html>
<head>
<title><fmt:message key="Event.title"/></title>
</head>
<body>
<h1><fmt:message key="Event.heading"/></h1>
<form method="post">
<table width="95%" bgcolor="f8f8ff" border="0" cellspacing="0" cellpadding="5">
<tr>
<td alignment="right" width="20%">
Event Date:
</td>
<!--here entry for event is done in springapp2-servlet.xml i.e. Event.java-->
<spring:bind path="event.date">
<td width="20%">
<input type="text" name="date">
</td>
<td width="60%">
<font color="red"><c:out value="${status.errorMessage}"/></font>
</td>
</spring:bind>
</tr>
<tr>
<td alignment="right" width="20%">
Event Title
</td>
<spring:bind path="event.title">
<td width="20%">
<input type="text" name="title">
</td>
<td width="60%">
<font color="red"><c:out value="${status.errorMessage}"/></font>
</td>
</spring:bind>
</tr>
</table>
<br>
<spring:hasBindErrors name="event">
<b>Please fix all errors!</b>
</spring:hasBindErrors>
<br><br>
<input type="submit" alignment="center" value="Submit">
</form>
</body>
</html>
Problem is I submit date as string type like 2008/09/09 to Event.java but it must be date type in Event.java.
Should I something change in jsp page to convert date(String type) to date(Date type)?
How manner I can remove this problem?
I try but not getting.
Please!! post your valuable suggestions.
Regards,
Thanks