Follow the steps for making custom attributes-
Go to Control Panel -> User - > Custom Attribute -> Add Custom Attribute
An Attribute is a key and type of the field (once saved) cannot be changed at all...
Accessing Custom Attribute Pragmatically
ThemeDisplay td=(ThemeDisplay)request.getAttribute(Web_Keys.THEME_DISPLAY);User u=td.getUser();
System.out.println(u.getExpendoBridge().getAttribute("CustomAttributeName"));
Setting Attribute Pragmatically
ThemeDisplay td=(ThemeDisplay)request.getAttribute(Web_Keys.THEME_DISPLAY);User u=td.getUser();
System.out.println(u.getExpendoBridge().setAttribute("CustomAttributeName","Value"));
Adding custom Attribute form element at Sign In Portlet
write the following code in /root/html/portlet/login/create_account.jsp
<liferay ui:custom-attribute-listclassName="com.liferay.portal.model.user"
editable="<%=true%>"
label="<%=true%>">
but this will not visible to due to permission. So, login as admin and provide permission to guest to see and modify custom field through control panel.
Source : http://www.apoorvaprakash.in/2010/11/custom-attributes-in-liferay.html
gud post and nice blog. i am very new to the concept of liferay i have created the custom attribute given permission and it is displaying in my user registration page. i want to access the custom value how to do it and where to write the below code
ReplyDeleteThemeDisplay td=(ThemeDisplay)request.getAttribute(Web_Keys.THEME_DISPLAY);
User u=td.getUser();
System.out.println(u.getExpendoBridge().getAttribute("CustomAttributeName"));
Online Tech Support all you need to do is call them and the just relax while they troubleshoot all your PC problems...........................
ReplyDeleteThankyou
Lacy Brown