Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Custom field on DL not updating
Hi,
I create a custom field for the Documents and Media Document
this new field add automatically on the page
When I add a new document, the new field was saved in the expendo table but I can't update this field after
Do I have to make a modification to update the field ?
thanks
I create a custom field for the Documents and Media Document
this new field add automatically on the page
When I add a new document, the new field was saved in the expendo table but I can't update this field after
Do I have to make a modification to update the field ?
thanks
Hi Etienne,
why cannot you update? What is the symptom either on the UI or in the log files.
Regards,
Zsigmond
why cannot you update? What is the symptom either on the UI or in the log files.
Regards,
Zsigmond
I'm having the same problem,
after creating some expando columns programatically they appear to be working fine even creating the DL entry but after creation if i try to update any of the custom attributes nothing happend however the normal attributes of the DL entry change as expected.
more information here
any ideas?
after creating some expando columns programatically they appear to be working fine even creating the DL entry but after creation if i try to update any of the custom attributes nothing happend however the normal attributes of the DL entry change as expected.
more information here
any ideas?
Nagendra Kumar Busam, modified 12 Years ago.
Liferay Master
Posts: 678
Join Date: 7/7/09
Recent Posts
Which version of liferay you are using?
Can you share code snippet for how you are adding your custom fields programmatically , so that we can look where the actual issue is
Can you share code snippet for how you are adding your custom fields programmatically , so that we can look where the actual issue is
Etienne Roy:
Hi,
I create a custom field for the Documents and Media Document
this new field add automatically on the page
When I add a new document, the new field was saved in the expendo table but I can't update this field after
Do I have to make a modification to update the field ?
thanks
Hi,
I think problem is related to update permissions. Have you set update permissions for that custom field. First assign update permissions,then check.
I hope this may help you.
Thanks
Hi.
In my case, I am having this problem with the portal administrator, however y put all the permissions for the field to the power user role wich is also a role on the user i'm using but the custom field remains unmodified.
I'm using version 6.1 GA3 of LP if that brings any light on the matter.
Thanks in advance.
In my case, I am having this problem with the portal administrator, however y put all the permissions for the field to the power user role wich is also a role on the user i'm using but the custom field remains unmodified.
I'm using version 6.1 GA3 of LP if that brings any light on the matter.
Thanks in advance.
Finally made it work!!
i developed a hook in the struts action /document_library/edit_file_entry
after the entry is updated i manually set the expandos with a couple of methods that looks something like this.
I know it's dirty but i had to do it
i developed a hook in the struts action /document_library/edit_file_entry
after the entry is updated i manually set the expandos with a couple of methods that looks something like this.
private static final Pattern EXPANDO_PATTERN = Pattern.compile("ExpandoAttribute--(.*)--");
private void updateExpandosForFileEntries(PortletRequest request, FileEntry fileEntry){
Set<string> values = new HashSet<string>();
for(String param : request.getParameterMap().keySet()){
// aplies the method only to the expando parameters
Matcher matcher = EXPANDO_PATTERN.matcher(param);
if(matcher.find()){
String expandoParam = matcher.group(1);
if(values.contains(expandoParam)){
continue;
}
else{
updateExpandosForFileEntry(request, expandoParam, fileEntry);
values.add(expandoParam);
}
}
}
}
private void updateExpandosForFileEntry(PortletRequest request, String expandoName, FileEntry fileEntry){
String nameParam = "ExpandoAttribute--" + expandoName + "--";
String paramValue = request.getParameter(nameParam);
if(Validator.isNotNull(paramValue)){
int type = fileEntry.getExpandoBridge().getAttributeType(expandoName);
if(type == ExpandoColumnConstants.BOOLEAN){
fileEntry.getExpandoBridge().setAttribute(expandoName, paramValue.equals("1")?true:false);
return;
}
fileEntry.getExpandoBridge().setAttribute(expandoName, paramValue);
} else{
String dateYear = nameParam + "Year";
String dateMonth = nameParam + "Month";
String dateName = nameParam + "Day";
String dateAmPm = nameParam + "AmPm";
String dateHour = nameParam + "Hour";
String dateMinute = nameParam + "Minute";
Calendar expandoCalendar = Calendar.getInstance();
expandoCalendar.set(Calendar.YEAR, ParamUtil.getInteger(request, dateYear));
expandoCalendar.set(Calendar.MONTH, ParamUtil.getInteger(request, dateMonth));
expandoCalendar.set(Calendar.DAY_OF_MONTH, ParamUtil.getInteger(request, dateName));
expandoCalendar.set(Calendar.AM_PM, ParamUtil.getInteger(request, dateAmPm));
expandoCalendar.set(Calendar.HOUR, ParamUtil.getInteger(request, dateHour));
expandoCalendar.set(Calendar.MINUTE, ParamUtil.getInteger(request, dateMinute));
try {
fileEntry.getExpandoBridge().setAttribute(expandoName, expandoCalendar.getTime());
} catch (Exception e) {
_log.error(e);
}
}
}
</string></string>I know it's dirty but i had to do it