Board index JavaServer Faces General id for ScheduleEvent

id for ScheduleEvent

Components, Ajax Framework, Utilities and More.

Post 17 Feb 2010, 10:12

Posts: 17
Hi

ScheduleEventImpl using following properties

private String id;
private String title;
private Date startDate;
private Date endDate;

is it possible to implement a entity class using Long id instead of String id

Any clue? :?:

thanks

Post 17 Feb 2010, 11:59

Posts: 56
Maybe it would be sufficient for you to wrap a Long id, like:



private Long myId;

public Long getMyId() {
...
}

public String getId() {
if (myId == null)
   return null;
else
return myId.toString();
}


?

Post 17 Feb 2010, 12:25

Posts: 14909
Location: Cybertron

jsfcoder, any particular reason you want it to be a long. It is used internally and generated so you don't need to care about it.
PrimeFaces Lead

Post 17 Feb 2010, 17:42

Posts: 17
Hi Rene,

Good idea. Thanks for your advice! I will try it out. :D

Hi Cagatay,

I'm using seam 2.1.2 with seam application framework.

calendarEvent.java
entity class is like following normally:

@Id @GeneratedValue
private Long id;
private String title;
private Date startDate;
private Date endDate;
private String content;
private String remarks;

which id will map to database as a primary key, will be referenced by other table as foreign key, I never try using String as id :mrgreen: .
seam application framework have some functions like
getId()
setId(Object id)
assignId(Object id)

any advise? thanks

Post 17 Feb 2010, 18:08

Posts: 14909
Location: Cybertron

Does your calendarEvent implement PrimeFaces ScheduleEvent?
PrimeFaces Lead

Post 17 Feb 2010, 18:44

Posts: 17
@Name("calendarEvent')
public class CalendarEvent implements ScheduleEvent {
@Id @GeneratedValue
private String id;
private String title;
private Date startDate;
private Date endDate;
private String content;
private String remarks;
private boolean allDay = true;
private String styleClass;
private Object data;

getter setter ....
}
maybe this way looks better ...

Post 17 Feb 2010, 18:55

Posts: 14909
Location: Cybertron

I think it'd be better if you can use another property for database id, ScheduleEvent's id is the identifier in scheduleModel which PrimeFaces generates. So I'd go with the following;

@Entity
public class CalendarEvent implements ScheduleEvent {

@Id @GeneratedValue
private Long dbId;

@Transient
private String id;

private String title;
private Date startDate;
private Date endDate;
private String content;
private String remarks;
private boolean allDay = true;
private String styleClass;
private Object data;

getter setter ....
}
PrimeFaces Lead

Post 17 Feb 2010, 19:26

Posts: 17
Hi Cagatay,

Sorry, I did not read the ScheduleModel carefully.
thanks for your advice!

Post 26 Feb 2010, 15:47

Posts: 17
few new problems encounter

1) JPA1 do not support persist
private Object data;
resolve by separate entity class and scheduleEventImpl object.

and then extend ScheduleEventImpl to add-in more properties, like following

private String id;
private String title;
private Date startDate;
private Date endDate;
private boolean allDay = true;
private String styleClass;
private Object data;

private Long dbId;
private String content;
private String remarks;

display events in scheduler, no problem.

have difficult to update event,
as
p:schedule eventSelectListener is looking for ScheduleEntrySelectEvent,
ScheduleEntrySelectEvent looking for ScheduleEvent

is any work around to ? to extend ScheduleEvent to ExtendScheduleEvent

thanks :roll:

Post 27 Feb 2010, 11:32

Posts: 17
Any idea?

thanks

Next

Return to General