Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Idoia Olalde
get the value of custom fields
May 24, 2010 12:58 AM
Answer

Idoia Olalde

Rank: New Member

Posts: 3

Join Date: May 24, 2010

Recent Posts

Hi,

I would like to get the value of a custom field.

I have added a new field to the "create an account" portlet. The custom field is a selection of Text Values with 3 possible values.

<liferay-ui:custom-attribute
className="<%= User.class.getName() %>"
classPK="<%= 0 %>"
editable="<%= true %>"
label="<%= true %>"
name="user-type"/>

I can see the new field in the portlet and select a value, but I don't know how to access to that value by code. I have been trying with this.

String user_type = (String)user.getExpandoBridge().getAttribute("user-type").toString();

but this doesn't return the value that the user has selected.Any idea?

Thanks in advance
Idoia Olalde
RE: get the value of custom fields
May 24, 2010 1:23 AM
Answer

Idoia Olalde

Rank: New Member

Posts: 3

Join Date: May 24, 2010

Recent Posts

Ok, now it's solved. The getAttribute method returns an array (with only one value, the selected by the user)

String[] array_type = (String[])user.getExpandoBridge().getAttribute("user-type");

Then, you can access to the value:

array_type[0]
zahra zarei
RE: get the value of custom fields
September 30, 2011 11:53 AM
Answer

zahra zarei

Rank: New Member

Posts: 9

Join Date: August 26, 2011

Recent Posts

hi,
I also add a field to create account and get it's value, but I want to show some other fields based on the user type selected by user
but it seems it can't re render itself with new values, can anyone help please
Eric Min
RE: get the value of custom fields
August 21, 2012 11:16 PM
Answer

Eric Min

LIFERAY STAFF

Rank: Junior Member

Posts: 31

Join Date: October 5, 2009

Recent Posts

You should refer the following code snippet:

 1
 2<liferay-ui:custom-attribute
 3className="<%= User.class.getName() %>"
 4classPK="<%= (selUser != null) ? selUser.getUserId() : 0 %>"
 5
 6editable="<%= true %>"
 7label="<%= true %>"
 8name="about-us"
 9/>