Foren

how to pass information from portlet to a listener?

thumbnail
Tanaji M. Londhe, geändert vor 11 Jahren.

how to pass information from portlet to a listener?

Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste Beiträge
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
Rishi Dev Gupta, geändert vor 11 Jahren.

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

Expert Beiträge: 255 Beitrittsdatum: 23.11.08 Neueste Beiträge
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
Tanaji M. Londhe, geändert vor 11 Jahren.

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

Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste Beiträge
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?
Siby Mathew, geändert vor 11 Jahren.

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

Expert Beiträge: 268 Beitrittsdatum: 04.03.11 Neueste Beiträge
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
Tanaji M. Londhe, geändert vor 11 Jahren.

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

Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste Beiträge
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
Tanaji M. Londhe, geändert vor 11 Jahren.

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

Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste Beiträge
Can anybody tell me how can acheive this thing?

Thanks & regards,
Tanaji
Siby Mathew, geändert vor 11 Jahren.

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

Expert Beiträge: 268 Beitrittsdatum: 04.03.11 Neueste Beiträge
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
Tanaji M. Londhe, geändert vor 11 Jahren.

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

Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste Beiträge
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.
Siby Mathew, geändert vor 11 Jahren.

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

Expert Beiträge: 268 Beitrittsdatum: 04.03.11 Neueste Beiträge
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
Tanaji M. Londhe, geändert vor 11 Jahren.

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

Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste Beiträge
Hi Siby,
No. Its requirement to add it in listener only. thats why adding in listener.
Siby Mathew, geändert vor 11 Jahren.

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

Expert Beiträge: 268 Beitrittsdatum: 04.03.11 Neueste Beiträge
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
Tanaji M. Londhe, geändert vor 11 Jahren.

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

Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste Beiträge
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.
.............
}
Siby Mathew, geändert vor 11 Jahren.

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

Expert Beiträge: 268 Beitrittsdatum: 04.03.11 Neueste Beiträge
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
Tanaji M. Londhe, geändert vor 11 Jahren.

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

Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste Beiträge
Hi Siby,
Yeah i am getting your point but Its client requirement to add this addEmp code is only within listener.
thumbnail
David H Nebinger, geändert vor 11 Jahren.

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

Liferay Legend Beiträge: 14917 Beitrittsdatum: 02.09.06 Neueste Beiträge
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
Vikas Kadam, geändert vor 11 Jahren.

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

New Member Beiträge: 22 Beitrittsdatum: 15.06.11 Neueste Beiträge
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
Tanaji M. Londhe, geändert vor 11 Jahren.

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

Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste Beiträge
Hi Vikas,
Thanks. I have done this using Expando concept. emoticon