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.
one of the finest blog ever and really thanks for sharing.
ReplyDelete- liferay customization
Hi Apoorva,
ReplyDeleteThanks for Sharing the docs,
but i have one doubt
for Accessing CustomAttribut Programetically we need to create one class than only we can provide or what Please help me . i am new to this Liferay.
Please i need a support to implement the CustomAttribute.
Hi Sipra,
ReplyDeleteThe Java code that I've mentioned as "Accessing Custom Attributes Programatically" is the code that you have to use in Java class.
How can i add custom attribute as a hidden ?? another thing is that how can I set my custom attribute value in js ??
ReplyDelete