id for ScheduleEvent

UI Components for JSF
jsfcoder
Posts: 17
Joined: 08 Feb 2010, 08:31

17 Feb 2010, 10:12

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

rene.guenther
Posts: 56
Joined: 19 Oct 2009, 15:56

17 Feb 2010, 11:59

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

Code: Select all


private Long myId;

public Long getMyId() {
...
}

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

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

17 Feb 2010, 12:25

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.

jsfcoder
Posts: 17
Joined: 08 Feb 2010, 08:31

17 Feb 2010, 17:42

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

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

17 Feb 2010, 18:08

Does your calendarEvent implement PrimeFaces ScheduleEvent?

jsfcoder
Posts: 17
Joined: 08 Feb 2010, 08:31

17 Feb 2010, 18:44

@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 ...

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

17 Feb 2010, 18:55

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;

Code: Select all

@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 ....
}

jsfcoder
Posts: 17
Joined: 08 Feb 2010, 08:31

17 Feb 2010, 19:26

Hi Cagatay,

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

jsfcoder
Posts: 17
Joined: 08 Feb 2010, 08:31

26 Feb 2010, 15:47

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:

jsfcoder
Posts: 17
Joined: 08 Feb 2010, 08:31

27 Feb 2010, 11:32

Any idea?

thanks

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 26 guests