liferayliferay-6custom-attribute

Getting Null value in liferay custom field?


I am using Liferay 6.1 CE version. I added my custom attribute in User entity from control panel. I want to add this my custom field in create_account.jsp hook page. I added like this way.

<div class="exp-ctrl-holder">
<liferay-ui:custom-attribute className="<%=User.class.getName()%>"
classPK="<%=0%>" editable="<%=true%>" label="<%=true%>"
name="user-default-group-name" />

After that i am trying to getting this value in UserLocalService hook class which extends UserLocalServiceWrapper class - (hook). I find each value from this but can not able to get my custom field value.

I am trying to get custom field value like this.

String defaultGroup = (String) User.getExpandoBridge().getAttribute("defaultGroupName");
log.info("Default Group Name :" + defaultGroup);

But I am getting null value or default value which I set at the time of adding custom attribute. I can not find my entered value from jsp page.

Please help me.

Regards : Pradip Bhatt pradip.bhatt@aspiresoftware.in


Solution

  • You dont have to write any logic for save custom-field, Liferay API will take care of saving it.

    You just have to specify custom-field tag inside form of create account screen.

    Hope this would help.