Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Kan Kon
Updating content of Journal Article
July 5, 2012 2:57 PM
Answer

Kan Kon

Rank: New Member

Posts: 23

Join Date: September 12, 2011

Recent Posts

I am trying to update only the content of a Journal Article while keeping template, structure intact. During the process I am trying to get the article published so that it is available immediately of changes. I have tried the following.

1. Get the content of a Journal Article
2. Make Changes
3. Update the journal article using JournalLocalServiceUtil
1
2            JournalArticle  ja = JournalArticleLocalServiceUtil.getArticle(td
3                    .getLayout().getGroupId(), contentId);
4            ja.setContent(content);
5            ja = JournalArticleLocalServiceUtil.updateJournalArticle(ja);


But, I am unable to achieve what I wanted. Any ideas on how to get this working? This is with Liferay 6.1

Thanks in advance
Kan Kon
RE: Updating content of Journal Article
July 9, 2012 2:22 PM
Answer

Kan Kon

Rank: New Member

Posts: 23

Join Date: September 12, 2011

Recent Posts

Update: I see that the entry is updated in the db with modified content. But, the WebContent display portlet does not render it. However, after opening the article from the control panel and clicking "Publish" button it will be displayed in the web content portlet. At this time another version is created. Wondering what "Publish" button would do that makes it to display.
Vitaliy Koshelenko
RE: Updating content of Journal Article
July 10, 2012 3:26 AM
Answer

Vitaliy Koshelenko

Rank: Regular Member

Posts: 222

Join Date: March 25, 2011

Recent Posts

Try to use JournalArticleLocalServiceUtil.updateArticle(<parameters>) method instead of JournalArticleLocalServiceUtil.updateJournalArticle(ja);
it will perform the same actions as you press "Publish" button.
Kan Kon
RE: Updating content of Journal Article
July 17, 2012 9:00 AM
Answer

Kan Kon

Rank: New Member

Posts: 23

Join Date: September 12, 2011

Recent Posts

Tried updateArticle instead and it still does not see to work. What I have noticed is that the journal article is updated. But, Journal Article Display shows blank. Any idea how the corresponding journal article display is update for each journal article update?
Srikanth Konjarla
RE: Updating content of Journal Article
July 17, 2012 1:41 PM
Answer

Srikanth Konjarla

Rank: Junior Member

Posts: 51

Join Date: October 24, 2008

Recent Posts

Likely reason is that the updated content is not "formatted" as it is being written into Journal Article table. The Journal Article Display would "extract" the markup from JHournal Article that can be rendered by the browser. Essentially, the content need to be formatted in a DOM structure. Following is an example on how to format static data (that is being created by CKEditor.

 1
 2private String formatContent(String content) {
 3        String result = null;
 4        Element rootElement = SAXReaderUtil.createElement("root");
 5        Document contentDoc = SAXReaderUtil.createDocument(rootElement);
 6        Element contentElement = SAXReaderUtil.createElement("static-content");
 7        rootElement.add(contentElement);
 8        contentElement.addText(content);
 9        try {
10            result = DDMXMLUtil.formatXML(contentDoc);
11        } catch (IOException e) {            
12            e.printStackTrace();
13        }       
14        return result;
15    }
Alain Dresse
RE: Updating content of Journal Article
October 11, 2012 2:57 PM
Answer

Alain Dresse

Rank: Junior Member

Posts: 95

Join Date: July 18, 2011

Recent Posts

Hi,

Could someone point me to where I could find information on how to format the information for dynamic content ?

Thanks,
Alain
Hitoshi Ozawa
RE: Updating content of Journal Article
October 11, 2012 4:05 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7954

Join Date: March 23, 2010

Recent Posts

I think it's the status. You'll have to change the status to make it display.
Also, how is the workflow for Web Content portlet set? I think you want to disable it to make the content show up immediately.
Hitoshi Ozawa
RE: Updating content of Journal Article
October 11, 2012 4:06 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7954

Join Date: March 23, 2010

Recent Posts

Alain, sorry but your reply isn't concerned with the topic of this thread so I'm going to ignore it. If you have a new question, please create a new thread.
Alain Dresse
RE: Updating content of Journal Article
October 13, 2012 12:16 AM
Answer

Alain Dresse

Rank: Junior Member

Posts: 95

Join Date: July 18, 2011

Recent Posts

Hitoshi,

You are right. My question was only partly related to the original poster and I will start a new thread.

In addition, my post's lack of clarity did not help to see the link: I didn't specify what I meant by dynamic content. I was referring to 'dynamic-content used for journal articles with a non default structure' as opposed to static-content as used in Srikanth's post.

At least my post bumped Kan's initial request, and triggered your input...

Best regards,
Alain