Fórum

How to persist custom fields values on update ?

thumbnail
Rajesh Chaurasia, modificado 12 Anos atrás.

How to persist custom fields values on update ?

Regular Member Postagens: 183 Data de Entrada: 18/08/11 Postagens Recentes
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 ?
thumbnail
Maarten van Heiningen, modificado 12 Anos atrás.

RE: How to persist custom fields values on update ?

Regular Member Postagens: 174 Data de Entrada: 05/02/09 Postagens Recentes
Hi Rajesh,

I think you should ask your question in the development forum. I think you have a better chance of getting an answer
Development forum

Best,
Maarten