Foren

Login portlet with more than one look and feel

Jawwad Farooq, geändert vor 11 Jahren.

Login portlet with more than one look and feel

Junior Member Beiträge: 35 Beitrittsdatum: 21.06.12 Neueste Beiträge
Hi,

Is there any way to have more than one style for the Login Portlet?

I have 3 Sites on Liferay and I want to use the Liferay Login portlet for all these sites but the style is different for all. To my knowledge if I use Hook to change the layout it will be applicable for all three as well as for the Liferay itself.

Please help, I am stuck badly
thumbnail
Tejas Kanani, geändert vor 11 Jahren.

RE: Login portlet with more than one look and feel

Liferay Master Beiträge: 654 Beitrittsdatum: 06.01.09 Neueste Beiträge
Which version of Liferay are you using ?
thumbnail
Tejas Kanani, geändert vor 11 Jahren.

RE: Login portlet with more than one look and feel

Liferay Master Beiträge: 654 Beitrittsdatum: 06.01.09 Neueste Beiträge
If you are using Liferay 6.1 then its possible to create separate hook for each site. So that you can define different look and feel in different site specific hook.
You can do it using Application Adapters.

Have a look at sample application adapter hook and try it out.

I hope this help you.

Regards,
TK
thumbnail
Paul ., geändert vor 11 Jahren.

RE: Login portlet with more than one look and feel

Liferay Master Beiträge: 522 Beitrittsdatum: 29.08.11 Neueste Beiträge
With 6.1 you get an option to do it with hooks that can be applied to specific liferay sites. Check out http://www.liferay.com/es/community/wiki/-/wiki/1071674/Application+Adapters for more details. Otherwise you can always hook in the normal manner (for earlier liferay version) and write code to check which site is currently being shown and apply style accordingly.

Do post in more details about any more doubts.
Jawwad Farooq, geändert vor 11 Jahren.

RE: Login portlet with more than one look and feel

Junior Member Beiträge: 35 Beitrittsdatum: 21.06.12 Neueste Beiträge
Thanks TK and Paul.

This is my first post on this forum and got a very good impression, 3 replies within 20 minutes

I am using Liferay 6.1. Let me go through the links you provided and let you know about any other queries.


Thanks and Regards

JF
thumbnail
Sachin Mane, geändert vor 11 Jahren.

RE: Login portlet with more than one look and feel

Junior Member Beiträge: 76 Beitrittsdatum: 10.04.12 Neueste Beiträge
I believe that there should be a single version of login portlet codebase (jsp) and look and feel customization should be achieved using different Theme for different instances.
You can keep the CSS class names same in the login JSP and just have a new theme with different .css file containing required css tag values.
Kevin Matthews, geändert vor 11 Jahren.

RE: Login portlet with more than one look and feel

Junior Member Beiträge: 38 Beitrittsdatum: 23.05.12 Neueste Beiträge
Hi , I want to use liferay login portlet to call my custom portlet.. Inside my custom portlet I would like to display information about the user who logged in. Basically i use their user Id that get genereated when they use liferay create account portlet. A web service call is made to our back-end system. Base on that use ID i have a jsp page that display all of user information. I need guidance as to how to leveray the liferay login portlet to call my portlet which calls a web service that looks up the user information base on the user id. They have create an account first, their account get addted to liferay table. I get th euser ID and sent it to the back-end system be stored on the back-end. I will like to use this userId after the user login using the liferay login portlet to call custom portlet which returns user information in session int jsp..Please advise or help if you can provide me some direction

Thanks
Kevin
thumbnail
David H Nebinger, geändert vor 11 Jahren.

RE: Login portlet with more than one look and feel

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
You don't need to do any of that stuff.

Create a portlet that just pulls the info for the current user (there are many API entry points to determine who that is, but it depends upon your framework as to which I'd recommend).

Deploy the portlet and drop it on a page. Then remove the guest view access on the portlet (means only logged in users will see it, hence you'll know you have a valid logged in user and your portlet will do the right thing).
Kevin Matthews, geändert vor 11 Jahren.

RE: Login portlet with more than one look and feel

Junior Member Beiträge: 38 Beitrittsdatum: 23.05.12 Neueste Beiträge
Thanks for the quick response David. Let me clarify my requirements. I created a hook for the login portlet using the login.events.post pointing to my custom class CustomPostLogin. Inside this class I get the userid from the email address entered from the login form. After retrieving the the userId I make a web service call that takes the userId as a parameter to pull customer information about the user base on his userId we store in our back-end system after they had created an account. After that information I store it into a list into request/session actionRequest.setAttribute("consumer",consumerDetails) so I can populate on the landing page LastPath publiclastPath = new LastPath(StringPool.BLANK, "/web/guest/login").

The question is how can I populate this information on the default landing page?
Kevin Matthews, geändert vor 11 Jahren.

RE: Login portlet with more than one look and feel

Junior Member Beiträge: 38 Beitrittsdatum: 23.05.12 Neueste Beiträge
Also David, if I modify the view.jsp which I am using as the landing page and place my portlet which i have wriiten similar to the greeting portlet

<jsp:useBean id="dbInfo" type="com.mypackage.myInfoDTO" scope="request" />


As soon as I place the portlet on the home page I get an "exception can't instantiate bean"
thumbnail
Harish Kumar, geändert vor 11 Jahren.

RE: Login portlet with more than one look and feel

Expert Beiträge: 483 Beitrittsdatum: 31.07.10 Neueste Beiträge
Hi Kevin,

Kevin Matthews:
Thanks for the quick response David. Let me clarify my requirements. I created a hook for the login portlet using the login.events.post pointing to my custom class CustomPostLogin. Inside this class I get the userid from the email address entered from the login form. After retrieving the the userId I make a web service call that takes the userId as a parameter to pull customer information about the user base on his userId we store in our back-end system after they had created an account. After that information I store it into a list into request/session actionRequest.setAttribute("consumer",consumerDetails) so I can populate on the landing page LastPath publiclastPath = new LastPath(StringPool.BLANK, "/web/guest/login").

The question is how can I populate this information on the default landing page?


If my understanding is right, you want to display the logged in user information in your custom portlet placed on the landing page.

You can achieve this by simply creating a custom portlet and in that you can pick logged in user information using the liferay API.

For example - you can use themeDisplay object to get logged in user info as -

ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

User user = themeDisplay.getUser() OR
long userId = themeDisplay.getUserId()

and as suggested by David, you can make this portlet hidden for Guest.


Regards,
Kevin Matthews, geändert vor 11 Jahren.

RE: Login portlet with more than one look and feel

Junior Member Beiträge: 38 Beitrittsdatum: 23.05.12 Neueste Beiträge
No I don't want to display the logged in user Information. I want to display the information about the user i received from the web service call about their particular stock information. When i set this information in session I would like to redirect to my home.jsp page which has some java bean and objects and other properties set. I already store this information in session
My Postlogin java code
public class CustomPostLoginAction extends Action{
@Override
public void run(HttpServletRequest actionRequest, HttpServletResponse httpres)
throws ActionException {
session.setAttribute("firstname",customerDetails.getFirstname());
session.setAttribute("price", priceList);

My Home.jsp page snippet:
For example here is a sippet of my jsp. I am currently overriding the run method and redirecting as LastPath publiclastPath = new LastPath(StringPool.BLANK, "/web/guest/login");

<jsp:useBean id="customerr" type="com.xxxx.xxxx.xxx.ConsumerDTO" scope="request" />
<jsp:useBean id="priceList" type="java.util.List" scope="request" />


<h2>
Welcome&nbsp;<%=consumer.getFirstname()%>&nbsp;<%=consumer.getLastname()%>your stock is value Today at <%=get.PriceValue%>


Thanks
Kevin Matthews, geändert vor 11 Jahren.

RE: Login portlet with more than one look and feel

Junior Member Beiträge: 38 Beitrittsdatum: 23.05.12 Neueste Beiträge
Will this do solve my problem? Could I populate the user stock information from the back-end as soon as they login to the portal. Please see below


STEP 1:I create a page and add my portlet to this page with the following content below,

<portlet:renderURL windowState="maximized" var="rowURL">
<portlet:param name="jspPage" value="/html/stocks/client/home.jsp"/>
</portlet:renderURL>


STEP 2: I override the my run method and call the portlet

public class CustomPostLoginAction extends Action{
@Override

StockInfo stock = RestWebserviceCall(userId)
If stock != null {
public void run(HttpServletRequest actionRequest, HttpServletResponse httpres)
throws ActionException {
LastPath publiclastPath = new LastPath(StringPool.BLANK, "/web/guest/my-account");
}

}
thumbnail
mohammad azaruddin, geändert vor 11 Jahren.

RE: Login portlet with more than one look and feel

Expert Beiträge: 492 Beitrittsdatum: 17.09.12 Neueste Beiträge
Hi Kevin Matthews

I need One Help.
How you pass object from CustomPostLoginAction to Action class in MVC of custom portlet

Thanks
Regards
Azar
Kevin Matthews, geändert vor 10 Jahren.

RE: Login portlet with more than one look and feel

Junior Member Beiträge: 38 Beitrittsdatum: 23.05.12 Neueste Beiträge
Hi Mohammad,

You can set your object in session in your CustomPostLoginAction class and retrieve your object out of session from your Action class
CustomPostLoginAction:
HttpSession session = request.getSession(true);
session.setAttribute(WebKeys.PORTLET_PREFERENCES_MAP, consumerDetails.getFirstname());

Action Class:
List<ConsumerDTO> consumer = (ArrayList<ConsumerDTO>)portletSession.getAttribute("consumerDetails",PortletSession.APPLICATION_SCOPE);

Thanks,
Kevin