Forums

angle-left Back

Display content with JournalContentUtil in JSF with Liferay 7?

PP
Pernes Panta, modified 9 Months ago.

Display content with JournalContentUtil in JSF with Liferay 7?

New Member Posts: 6 Join Date: 11/7/17 Recent Posts
Please how can i display my content in Liferay 7?
In Liferay 6 I proceeded like this:

@ApplicationScoped
@ManagedBean
public class ContentUtil {
...
public static String readArticleByTitleOld(final String articleTitle) {
     .....
   journalArticle = JournalArticleLocalServiceUtil .getArticleByUrlTitle(groupId, articleTitle);

  return JournalContentUtil.getContent(themeDisplay.getScopeGroupId(),
    journalArticle.getArticleId(), null, locale.toString(),  themeDisplay);
  } catch (){}
  return "Article '" + articleTitle + "' not found.";
}


JSF

<h:outputText
  value="#{contentUtil.readArticleByTitle(myBean.getArticleId())}"
  escape="false" />

But the
JournalContentUtil class
was be removed in Liferay 7 and i don't find the equivalent class the new Liferay 7.
please someone can help?
Kyle Joseph Stiemann, modified 9 Months ago.

RE: Display content with JournalContentUtil in JSF with Liferay 7?

LIFERAY STAFF Liferay Master Posts: 676 Join Date: 1/14/13 Recent Posts
Hi Pernes,
Can you call JournalArticle.getContentByLocale() instead?

Otherwise take a look at one of the JournalArticleLocalServiceUtil.getArticleContent() methods.

- Kyle
PP
Pernes Panta, modified 9 Months ago.

RE: Display content with JournalContentUtil in JSF with Liferay 7?

New Member Posts: 6 Join Date: 11/7/17 Recent Posts
Hi Kyle
Thanks for the response
I have this error when i try to get JournalArticle from JournalArticleServiceUtil:
Code:

final JournalArticle article = JournalArticleLocalServiceUtil.getArticleByUrlTitle(groupId,  articleTitle);


Error:

Caused by: java.lang.NoClassDefFoundError: com/liferay/portal/kernel/service/PersistedResourcedModelLocalService
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(ModuleClassLoader.java:272)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.defineClass(ClasspathManager.java:632)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(ClasspathManager.java:588)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:540)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:527)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:324)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:330)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:407)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:357)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:349)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.liferay.journal.service.JournalArticleLocalServiceUtil.<clinit>(JournalArticleLocalServiceUtil.java:4047)
    at mytudo.view.util.ContentUtil.readArticleByTitle(ContentUtil.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at javax.el.ELUtil.invokeMethod(ELUtil.java:332)
    ... 234 more


Permes
Kyle Joseph Stiemann, modified 9 Months ago.

RE: Display content with JournalContentUtil in JSF with Liferay 7?

LIFERAY STAFF Liferay Master Posts: 676 Join Date: 1/14/13 Recent Posts
Hi Pernes,
Can you paste your pom.xml's or build.gradle's (or ivy.xml's) dependencies section? It seems like you might have some Liferay 6.2 dependencies in your war.

- Kyle
PP
Pernes Panta, modified 9 Months ago.

RE: Display content with JournalContentUtil in JSF with Liferay 7?

New Member Posts: 6 Join Date: 11/7/17 Recent Posts
Hi Kyle,
thanks for the idear.
I work with many projects (4) projects with many pom.xml files .
I would firstly checked all project librarie dependencies .
If i don't find any Liferay 6.2 dependencies inside, i will post all project dependencies here.

Thanks

Pernes
Kyle Joseph Stiemann, modified 9 Months ago.

RE: Display content with JournalContentUtil in JSF with Liferay 7?

LIFERAY STAFF Liferay Master Posts: 676 Join Date: 1/14/13 Recent Posts
Sounds good Pernes. Let us know what you find out. You may also want to take a look at our Resolving ClassNotFoundException and NoClassDefFoundError in OSGi Bundles documentation.

- Kyle
PP
Pernes Panta, modified 8 Months ago.

RE: Display content with JournalContentUtil in JSF with Liferay 7?

New Member Posts: 6 Join Date: 11/7/17 Recent Posts
Hi Kyle,
I don't found any Liferay 6 dependency im my pom.xml.
I attached my dependencies file to the post.

How can i use bnd.bnd file with JSF Portlet in liferay 7?

Best regards
Kyle Joseph Stiemann, modified 8 Months ago.

RE: Display content with JournalContentUtil in JSF with Liferay 7? (Answer)

LIFERAY STAFF Liferay Master Posts: 676 Join Date: 1/14/13 Recent Posts
Hi Pernes,
You need to change the Journal API dependency to <scope>provided</scope> so it is not included in your portlet's WEB-INF/lib since Liferay provides it:

<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.journal.api</artifactId>
<version>2.11.0</version>
<scope>provided</scope>
</dependency>


You should also upgrade to JSF 2.2 since that is the only supported version of JSF in Liferay 7.0. liferayfaces.org can show you the recommended dependencies for Liferay 7.0.

- Kyle
PP
Pernes Panta, modified 8 Months ago.

RE: Display content with JournalContentUtil in JSF with Liferay 7?

New Member Posts: 6 Join Date: 11/7/17 Recent Posts
hi Kyle,
Thousand thanks for your help.
Now all work perfectly.
Thank you very much
I love liferay 7
Pernes
Kyle Joseph Stiemann, modified 8 Months ago.

RE: Display content with JournalContentUtil in JSF with Liferay 7?

LIFERAY STAFF Liferay Master Posts: 676 Join Date: 1/14/13 Recent Posts
Glad to hear it! Thanks for using Liferay Faces!

- Kyle