掲示板
MessageListener class
How can i get the Portal URL (e.g., http://localhost:8080) dynamically inside a MessageListener class. I've given the sample code here. Based on this value i have to dynamically create an createAccountURL and send to the invitees. This job is being invoked by a scheduler.
public class ReminderInvitationJob extends BaseMessageListener {
protected void doReceive(Message message) throws Exception {
long userId = 10195l;
long companyId = CompanyLocalServiceUtil.getCompanyIdByUserId(userId);
Group group = GroupLocalServiceUtil.fetchGroup(companyId, GroupConstants.GUEST);
String portalURL = ""; // ???????
System.out.println("createAccountURL ==> " +
InvitationUtil.getCreateAccountURL(group.getGroupId(), portalURL, userId));
Iterator<string> itr = message.getValues().keySet().iterator();
while (itr.hasNext()) {
System.out.println(itr.next());
}
}
}</string>
you can create a friendly url and then pass the parameters in the URL (something like a new create_account_id) and then u can get this parameter in your custom create account portlet (or even create a hook to override account create portlet)
with the create_account_id you can fetch data from the DB and pre-populate the form in the page,
/Praveen
with the create_account_id you can fetch data from the DB and pre-populate the form in the page,
/Praveen
11年前 に Gnaniyar Zubair によって更新されました。
RE: MessageListener class
Liferay Master 投稿: 722 参加年月日: 07/12/19 最新の投稿
I think we can get the service context object in MessageListener class and get the Portal URL like this:
I am not sure whether above things will work in Message Listener class but i have tried like this in my model listener class.
HTH
- Gnaniyar Zubair
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
serviceContext.getPortalURL()
I am not sure whether above things will work in Message Listener class but i have tried like this in my model listener class.
HTH
- Gnaniyar Zubair
Oh, cool zubair bhai, will try this. Then how are things @ elm?
11年前 に Gnaniyar Zubair によって更新されました。
RE: MessageListener class
Liferay Master 投稿: 722 参加年月日: 07/12/19 最新の投稿
Expecting your presence for technical supports.
10年前 に Domingo Piña によって更新されました。
RE: MessageListener class
Junior Member 投稿: 28 参加年月日: 09/04/03 最新の投稿ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
Returns null inside a MessageListener (with Liferay 6.0 EE).
10年前 に Jitendra Rajput によって更新されました。
RE: MessageListener class
Liferay Master 投稿: 875 参加年月日: 11/01/07 最新の投稿
You can also get Portal URL if you have company details .
Third argument for getPortalURL is to indicate server is secured or not. If you have enabled SSL then you can read from properties file and based on that you can pass true or false.
#
# Set the preferred protocol.
#
#web.server.protocol=https
Company company = CommonUtil.getCompanyByWebId("liferay.com");
if (Validator.isNotNull(company))
{
String portalURL = PortalUtil.getPortalURL(company.getVirtualHostname(), PortalUtil.getPortalPort(false), false);
}
Third argument for getPortalURL is to indicate server is secured or not. If you have enabled SSL then you can read from properties file and based on that you can pass true or false.
#
# Set the preferred protocol.
#
#web.server.protocol=https
10年前 に Domingo Piña によって更新されました。
RE: MessageListener class
Junior Member 投稿: 28 参加年月日: 09/04/03 最新の投稿
Thanks for the clue!
Finally, this is the code that works for LR 6.0 EE SP1:
Finally, this is the code that works for LR 6.0 EE SP1:
Company company = CompanyLocalServiceUtil.getCompanyByWebId("liferay.com");
if ( company != null ) {
int port = PortalUtil.getPortalPort();
if ( port < 0 ) {
port = 80;
}
portalURL = PortalUtil.getPortalURL(company.getVirtualHost(), port, false);
}