Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Jawwad Farooq
Login portlet with more than one look and feel
June 21, 2012 6:20 AM
Answer

Jawwad Farooq

Rank: Junior Member

Posts: 35

Join Date: June 21, 2012

Recent Posts

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
Tejas Kanani
RE: Login portlet with more than one look and feel
June 21, 2012 6:25 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 655

Join Date: January 6, 2009

Recent Posts

Which version of Liferay are you using ?
Tejas Kanani
RE: Login portlet with more than one look and feel
June 21, 2012 6:36 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 655

Join Date: January 6, 2009

Recent Posts

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
Bart Simpson
RE: Login portlet with more than one look and feel
June 21, 2012 6:40 AM
Answer

Bart Simpson

Rank: Liferay Master

Posts: 524

Join Date: August 29, 2011

Recent Posts

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
RE: Login portlet with more than one look and feel
June 21, 2012 9:08 PM
Answer

Jawwad Farooq

Rank: Junior Member

Posts: 35

Join Date: June 21, 2012

Recent Posts

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
Sachin Mane
RE: Login portlet with more than one look and feel
June 21, 2012 9:17 PM
Answer

Sachin Mane

Rank: Junior Member

Posts: 76

Join Date: April 9, 2012

Recent Posts

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
RE: Login portlet with more than one look and feel
July 23, 2012 12:46 PM
Answer

Kevin Matthews

Rank: Junior Member

Posts: 38

Join Date: May 23, 2012

Recent Posts

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
David H Nebinger
RE: Login portlet with more than one look and feel
July 23, 2012 1:50 PM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 12080

Join Date: September 1, 2006

Recent Posts

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
RE: Login portlet with more than one look and feel
July 26, 2012 8:12 AM
Answer

Kevin Matthews

Rank: Junior Member

Posts: 38

Join Date: May 23, 2012

Recent Posts

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
RE: Login portlet with more than one look and feel
July 26, 2012 4:20 PM
Answer

Kevin Matthews

Rank: Junior Member

Posts: 38

Join Date: May 23, 2012

Recent Posts

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"
Harish Kumar
RE: Login portlet with more than one look and feel
July 26, 2012 10:27 PM
Answer

Harish Kumar

Rank: Expert

Posts: 474

Join Date: July 31, 2010

Recent Posts

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
RE: Login portlet with more than one look and feel
July 27, 2012 1:11 PM
Answer

Kevin Matthews

Rank: Junior Member

Posts: 38

Join Date: May 23, 2012

Recent Posts

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
RE: Login portlet with more than one look and feel
July 30, 2012 6:47 AM
Answer

Kevin Matthews

Rank: Junior Member

Posts: 38

Join Date: May 23, 2012

Recent Posts

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");
}

}
Mohammad Azharuddin
RE: Login portlet with more than one look and feel
December 17, 2012 1:52 AM
Answer

Mohammad Azharuddin

Rank: Liferay Master

Posts: 500

Join Date: September 17, 2012

Recent Posts

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
RE: Login portlet with more than one look and feel
September 24, 2013 7:27 AM
Answer

Kevin Matthews

Rank: Junior Member

Posts: 38

Join Date: May 23, 2012

Recent Posts

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