Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
Rajesh Chaurasia
How to persist custom fields values on update ?
30 de Outubro de 2011 07:45
Resposta

Rajesh Chaurasia

Ranking: Regular Member

Mensagens: 119

Data de entrada: 18 de Agosto de 2011

Mensagens 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 ?
Maarten van Heiningen
RE: How to persist custom fields values on update ?
1 de Novembro de 2011 14:01
Resposta

Maarten van Heiningen

Ranking: Regular Member

Mensagens: 173

Data de entrada: 5 de Fevereiro de 2009

Mensagens 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