掲示板

how to pass information from portlet to a listener?

thumbnail
11年前 に Tanaji M. Londhe によって更新されました。

how to pass information from portlet to a listener?

Regular Member 投稿: 194 参加年月日: 12/04/25 最新の投稿
Hi,
I am having one portlet, one Listener for organization and i am performing some operation adding, deleting in my custom table depending upon listener method.
I am adding any organization using liferay API in my portlet that time listener get call. So i want to pass some object from my portlet to that listener.
How can pass any object to listener or is there any way to get session object into a listener ?
thumbnail
11年前 に Rishi Dev Gupta によって更新されました。

RE: how to pass information from portlet to a listener?

Expert 投稿: 255 参加年月日: 08/11/23 最新の投稿
You can pass the primary key of the object in hte message bus and in the listener fetch the object for same and do the processsing.
thumbnail
11年前 に Tanaji M. Londhe によって更新されました。

RE: how to pass information from portlet to a listener?

Regular Member 投稿: 194 参加年月日: 12/04/25 最新の投稿
Hi Rishi,
u mean i can pass that whole object using message bus and in listener of a org will implement that MessageListener and receive that object. is it correct?
But Message Bus is used to exchange the information (only String message) between liferay and web applications. Is it right way to use message bus here or is there any other way?
Here i my case i am having one listener for organization like
//this is my portlet
public class EmployeeManagementPortlet extends MVCPortlet {
addEmployee(Employee emp ) {
OrganizationLocalServiceUtil.addOrganization(...)
}
}
//Listener for organization
public class CustomOrganizationListener extends BaseModelListener<Organization>{
@Override
public void onAfterCreate(AssetEntry model) throws ModelListenerException {
// here i want that emp object when i perform some operation in portlet action like OrganizationLocalServiceUtil.addOrganization(...) then this listener get called.
addEmployee(emp)
}
}

here how do i get emp object in above listener?
11年前 に Siby Mathew によって更新されました。

RE: how to pass information from portlet to a listener?

Expert 投稿: 268 参加年月日: 11/03/04 最新の投稿
Hi Tanaji,
Is there any reason why you are using a ModelListener for this ?
Why are you not doing this operation inside your portlet?

Thanks,
Siby
thumbnail
11年前 に Tanaji M. Londhe によって更新されました。

RE: how to pass information from portlet to a listener?

Regular Member 投稿: 194 参加年月日: 12/04/25 最新の投稿
Hi Siby,
Becuase i am perform some other operation like addEmployee... into my custom table, when i add any organization or user in liferay. thats why i am using this listener for organization.
Thanks for reply.
thumbnail
11年前 に Tanaji M. Londhe によって更新されました。

RE: how to pass information from portlet to a listener?

Regular Member 投稿: 194 参加年月日: 12/04/25 最新の投稿
Can anybody tell me how can acheive this thing?

Thanks & regards,
Tanaji
11年前 に Siby Mathew によって更新されました。

RE: how to pass information from portlet to a listener?

Expert 投稿: 268 参加年月日: 11/03/04 最新の投稿
Hi Tanaji,
So you mean whenever an organization is created, you want some user to be added to your custom table.
You are saying you cannot write this logic inside your portlet's addEmployee(Employee emp ) method because this creation might happen from other places outside the portlet.
Am i right ?

Question : In case the organization is created via control panel, what employee details are you planning to store in your custom table ? (The current logged-in user ?)

Thanks,
Siby
thumbnail
11年前 に Tanaji M. Londhe によって更新されました。

RE: how to pass information from portlet to a listener?

Regular Member 投稿: 194 参加年月日: 12/04/25 最新の投稿
Hi Siby,
Thanks for reply. Yeah u r right.
But I am not adding any organization from control panel, here i am using custom UI for it and it will also add in liferay table using liferay API.
11年前 に Siby Mathew によって更新されました。

RE: how to pass information from portlet to a listener?

Expert 投稿: 268 参加年月日: 11/03/04 最新の投稿
Hi Tanaji,
If you are adding organization only with your custom UI, then you can do it without the ModelListener itself.
You can just write your logic after addOrganization is invoked.

Thanks,
Siby
thumbnail
11年前 に Tanaji M. Londhe によって更新されました。

RE: how to pass information from portlet to a listener?

Regular Member 投稿: 194 参加年月日: 12/04/25 最新の投稿
Hi Siby,
No. Its requirement to add it in listener only. thats why adding in listener.
11年前 に Siby Mathew によって更新されました。

RE: how to pass information from portlet to a listener?

Expert 投稿: 268 参加年月日: 11/03/04 最新の投稿
Hi Tanaji,
My point is, if you use a model Listener, it will get invoked even if an Organization is created inside the control panel.
Its not something specific to your custom portlet.
In that case, where it doesnt have any relationship between this employee object, what will you store ?
thumbnail
11年前 に Tanaji M. Londhe によって更新されました。

RE: how to pass information from portlet to a listener?

Regular Member 投稿: 194 参加年月日: 12/04/25 最新の投稿
Hi Siby,
when i add emloyee using my custom code (actually emp is not added in custom table till now ) some portlet action (like addEmpoyeeAction(.....) ) is get called then listener is called. Listener having actually emp addition code. In listener i want that emp object which is present in portlet action method like
//Portlet action mtd
addEmpoyeeAction(ActionRequest actionRequest, ActionResponse actionResponse ) {
emp = actionRequest.getParamter("employee");
// emp object i want to pass to the listener.
.............
}
11年前 に Siby Mathew によって更新されました。

RE: how to pass information from portlet to a listener?

Expert 投稿: 268 参加年月日: 11/03/04 最新の投稿
Hi Tanaji,
You are not getting my point. If you are creating a model listener it will be invoked by any component using the Liferay Organization API.
If you want this functionality to be present only in addEmployeeAction(), then you should write this logic only inside this method, not in a model listener.

Thanks,
Siby
thumbnail
11年前 に Tanaji M. Londhe によって更新されました。

RE: how to pass information from portlet to a listener?

Regular Member 投稿: 194 参加年月日: 12/04/25 最新の投稿
Hi Siby,
Yeah i am getting your point but Its client requirement to add this addEmp code is only within listener.
thumbnail
11年前 に David H Nebinger によって更新されました。

RE: how to pass information from portlet to a listener?

Liferay Legend 投稿: 14918 参加年月日: 06/09/02 最新の投稿
Tanaji M. Londhe:
Yeah i am getting your point but Its client requirement to add this addEmp code is only within listener.


I have a requirement that my Liferay should generate a nice soft serve ice cream cone every time a new user registers for the site, but the flavor must be whatever the administrator currently thinking about at the time of registration.

What? It can't be done? But I have this requirement! How do I satisfy a requirement that cannot be done?
thumbnail
11年前 に Vikas Kadam によって更新されました。

RE: how to pass information from portlet to a listener?

New Member 投稿: 22 参加年月日: 11/06/15 最新の投稿
Hi Tanaji,
Look for expando, this might alleviate you;
http://www.liferay.com/web/juan.fernandez/blog/-/blogs/sample-expando-hook

Kind regards,
Vikas
thumbnail
11年前 に Tanaji M. Londhe によって更新されました。

RE: how to pass information from portlet to a listener?

Regular Member 投稿: 194 参加年月日: 12/04/25 最新の投稿
Hi Vikas,
Thanks. I have done this using Expando concept. emoticon