留言板
How to persist a value of custom field on update
Charu Babbar,修改在12 年前。
How to persist a value of custom field on update
Regular Member 帖子: 167 加入日期: 11-9-13 最近的帖子
Hi,
i created few custom fields for web content and assigned them default values as per my requirement for intitial stage.
I am displaying these field values in Archive Setting screen that I created as ;part of my use case.In that screen I am allowing it to update the values of custom fieldsa
I am retreiving the individual field values as give below in jsp:
//durationArchiveInactiveSite
Integer durationArchiveInactiveSite = 0;
long jrnlClassNameId = ClassNameLocalServiceUtil.getClassNameId(JournalArticle.class.getName());
long company_id = user.getCompanyId();
ExpandoTable jnrnlTable = ExpandoTableLocalServiceUtil.getDefaultTable(company_id, jrnlClassNameId);
ExpandoColumn jrnlColumn = ExpandoColumnLocalServiceUtil.getColumn(jnrnlTable.getTableId(), "durationArchiveInactiveSite");
String value = jrnlColumn.getDefaultData();
if (value != null) {
durationArchiveInactiveSite= Integer.parseInt(value);
}
I am calling the EditServerAction method with cmd ="archiveSettings" and in the method where I want to update the field values retrieved from jsp page on user edit as below:
int defaultSortOrderForAutogeneratedPortlets = ParamUtil.getInteger(actionRequest, "defaultSortOrderForAutogeneratedPortlets");
//Update the Expando column with correct values
long jrnlClassNameId = ClassNameLocalServiceUtil.getClassNameId(JournalArticle.class.getName());
long company_id = PortalUtil.getCompanyId(actionRequest);
ExpandoTable jnrnlTable = ExpandoTableLocalServiceUtil.getDefaultTable(company_id, jrnlClassNameId);
//Specific Handling for durationArchiveInactiveSite
ExpandoColumn jrnlColumn = ExpandoColumnLocalServiceUtil.getColumn(jnrnlTable.getTableId(), "durationArchiveInactiveSite");
jrnlColumn.setDefaultData(String.valueOf(durationArchiveInactiveSite));
ExpandoColumn eColumndurationArchiveInactiveSite = ExpandoColumnLocalServiceUtil.updateColumn(jrnlColumn.getColumnId(), "durationArchiveInactiveSite", ExpandoColumnConstants.INTEGER, durationArchiveInactiveSite);
eColumndurationArchiveInactiveSite.persist();
But I failed to update the expando column for the right key.
Can someone let me knwo what is wrong ?
With Regards,
Charu
i created few custom fields for web content and assigned them default values as per my requirement for intitial stage.
I am displaying these field values in Archive Setting screen that I created as ;part of my use case.In that screen I am allowing it to update the values of custom fieldsa
I am retreiving the individual field values as give below in jsp:
//durationArchiveInactiveSite
Integer durationArchiveInactiveSite = 0;
long jrnlClassNameId = ClassNameLocalServiceUtil.getClassNameId(JournalArticle.class.getName());
long company_id = user.getCompanyId();
ExpandoTable jnrnlTable = ExpandoTableLocalServiceUtil.getDefaultTable(company_id, jrnlClassNameId);
ExpandoColumn jrnlColumn = ExpandoColumnLocalServiceUtil.getColumn(jnrnlTable.getTableId(), "durationArchiveInactiveSite");
String value = jrnlColumn.getDefaultData();
if (value != null) {
durationArchiveInactiveSite= Integer.parseInt(value);
}
I am calling the EditServerAction method with cmd ="archiveSettings" and in the method where I want to update the field values retrieved from jsp page on user edit as below:
int defaultSortOrderForAutogeneratedPortlets = ParamUtil.getInteger(actionRequest, "defaultSortOrderForAutogeneratedPortlets");
//Update the Expando column with correct values
long jrnlClassNameId = ClassNameLocalServiceUtil.getClassNameId(JournalArticle.class.getName());
long company_id = PortalUtil.getCompanyId(actionRequest);
ExpandoTable jnrnlTable = ExpandoTableLocalServiceUtil.getDefaultTable(company_id, jrnlClassNameId);
//Specific Handling for durationArchiveInactiveSite
ExpandoColumn jrnlColumn = ExpandoColumnLocalServiceUtil.getColumn(jnrnlTable.getTableId(), "durationArchiveInactiveSite");
jrnlColumn.setDefaultData(String.valueOf(durationArchiveInactiveSite));
ExpandoColumn eColumndurationArchiveInactiveSite = ExpandoColumnLocalServiceUtil.updateColumn(jrnlColumn.getColumnId(), "durationArchiveInactiveSite", ExpandoColumnConstants.INTEGER, durationArchiveInactiveSite);
eColumndurationArchiveInactiveSite.persist();
But I failed to update the expando column for the right key.
Can someone let me knwo what is wrong ?
With Regards,
Charu