Foren

Add custom fields to calendar and many to many relation to custom portlet

Zlatko Roncevic, geändert vor 9 Jahren.

Add custom fields to calendar and many to many relation to custom portlet

New Member Beiträge: 3 Beitrittsdatum: 05.05.14 Neueste Beiträge
Hi,

I want to extend calendar portlet with list of users which will attend event. Users are implemented as my custom portlet.
This is my idea how I would solve this:

In calendar portlet:
I would add custom field (list of integers) which would store users Ids

In my custom portlet:
I would create multiselect for adding user to more events.

How to create many to many from my custom portlet table to custom field ?
To one event can come more users and one user can go to many events ?

Is there better approach to this problem ?
Extend Liferay portlet and add many to many to custom portlet ?

Thanks in advance
Regards

Zlatko Roncevic
thumbnail
Sandip Patel, geändert vor 9 Jahren.

RE: Add custom fields to calendar and many to many relation to custom portl

Regular Member Beiträge: 205 Beitrittsdatum: 05.01.11 Neueste Beiträge
Hi,
You have to create one custom field as name as "attendes" in Calendar from control panel. Now write below code to put value in it.

ExpandoValue value = ExpandoValueLocalServiceUtil.addValue(long classNameId, long tableId, long columnId, long classPK,String data);
ExpandoValueLocalServiceUtil.updateExpandoValue(com.liferay.portlet.expando.model.ExpandoValue expandoValue);

Please refer below link for more help.
http://www.liferaysolution.com/2013/09/some-useful-expando-service-methods.html

HTH !!!
Zlatko Roncevic, geändert vor 9 Jahren.

RE: Add custom fields to calendar and many to many relation to custom portl

New Member Beiträge: 3 Beitrittsdatum: 05.05.14 Neueste Beiträge
Hi Sandip,

thanks for answer.

I have chosen more complex solution.

I have created myEvent and myEvent_Users table in service builder.
myEvent is one to one related to CalendarEvents and myEvent_Users is many to many relation to Users and myEvent

Than I have created hook which:
- extends CalEventLocalServiceWrapper to add input to myEvent table on adding calendar event and to delete input from
myEventTable on deleting calendar event
- overrides /calendar/edit_event struts action to put/delete values in myEvent_Users table on adding and updating calendar event, to put list of
users in attributes of calendar jsp
- extends calendar jsps to show list of users (selected and not selected) in to multiple selections

Also added functionality to users service to delete items from myEvent_Users in case deleting users
....

I'm sure that I forget something ....
Soooo much physical work for one many to many relation with existing portlet ... maybe I'm missing something ...

Yours solution is maybe little bit simpler, but still I would need hook to override struts action and manually administer
values in Expando tables in case of deleting Users or Events ...


Thanks
Regards

Zlatko Roncevic
thumbnail
Sandip Patel, geändert vor 9 Jahren.

RE: Add custom fields to calendar and many to many relation to custom portl

Regular Member Beiträge: 205 Beitrittsdatum: 05.01.11 Neueste Beiträge
Hi,
Are you really need to create myEvent and myEvent_Users Table for mapping? Have you any search functionality on myEvent_Users table to find user specific events or event specific Users??

If answer is No then you can create one custom field in Calender which store list of userIds per event. You have already create hook to override CalEventLocalServiceWrapper class, So just save all userIds list in custom field while adding event. same delete custom field value when delete event.

If User will deleted then don't update custom field value, just check User from userId whereever you use custom field value.

Please let me correct if i understood any wrong point..

HTH !!!
Zlatko Roncevic, geändert vor 9 Jahren.

RE: Add custom fields to calendar and many to many relation to custom portl

New Member Beiträge: 3 Beitrittsdatum: 05.05.14 Neueste Beiträge
Hi,

I need to show events for selected user, and to show users for selected event.
Many to many seemed logical solution, but amount of code was beyond expectations ....
Now your solution seems simpler. I need to search in Expando tables, and update them.


Thanks !

Regards

Zlatko