Combination View Flat View Tree View
Threads [ Previous | Next ]
Morad Ahmad
Website custom field
August 28, 2012 1:14 AM
Answer

Morad Ahmad

Rank: Junior Member

Posts: 29

Join Date: June 16, 2010

Recent Posts

Dear Community,

In Liferay 6.1.1

how to get the value of custom field defined for "Website"?

First of all I wonder why "WebsiteLocalServiceUtil.getWebsites()" returns an empty List althoug 5 Websites exists!!

So I expect to get values like these:

List<Website> websites = WebsiteLocalServiceUtil.getWebsites();
if (websites != null) {
for (Website website : websites) {
String typ = (String) website.getExpandoBridge().getAttribute("Typ");
...
}
}

I tried also to consider Websites as "Group" to read the custom fields like:


int count = GroupLocalServiceUtil.getGroupsCount();
List<Group> websites = GroupLocalServiceUtil.getGroups(0, count);
if (websites != null) {
for (Group website : websites) {
if (website.isSite() && !website.isControlPanel()) {
String siteName = website.getName();
Serializable typ = website.getExpandoBridge().getAttribute("Typ");
System.out.println(siteName + " - " + website.getFriendlyURL() + ", typ=" + typ);
// or: ????
Serializable typ2 = ExpandoValueLocalServiceUtil.getValue(Website.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME,
"Typ", website.getClassPK());

System.out.println("Typ2 = " + typ2);

tangoCommunities.add(siteName);
}
}
}

But I got only null values!

Please help!!

Thanks,
Morad.