Fórum

Display content with JournalContentUtil in JSF with Liferay 7?

Pernes Panta, modificado 6 Anos atrás.

Display content with JournalContentUtil in JSF with Liferay 7?

New Member Postagens: 6 Data de Entrada: 07/11/17 Postagens Recentes
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?
thumbnail
Kyle Joseph Stiemann, modificado 6 Anos atrás.

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

Liferay Master Postagens: 760 Data de Entrada: 14/01/13 Postagens Recentes
Hi Pernes,
Can you call JournalArticle.getContentByLocale() instead?

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

- Kyle
Pernes Panta, modificado 6 Anos atrás.

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

New Member Postagens: 6 Data de Entrada: 07/11/17 Postagens Recentes
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
</clinit>


Permes
thumbnail
Kyle Joseph Stiemann, modificado 6 Anos atrás.

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

Liferay Master Postagens: 760 Data de Entrada: 14/01/13 Postagens Recentes
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
Pernes Panta, modificado 6 Anos atrás.

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

New Member Postagens: 6 Data de Entrada: 07/11/17 Postagens Recentes
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
thumbnail
Kyle Joseph Stiemann, modificado 6 Anos atrás.

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

Liferay Master Postagens: 760 Data de Entrada: 14/01/13 Postagens Recentes
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
Pernes Panta, modificado 6 Anos atrás.

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

New Member Postagens: 6 Data de Entrada: 07/11/17 Postagens Recentes
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
thumbnail
Kyle Joseph Stiemann, modificado 6 Anos atrás.

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

Liferay Master Postagens: 760 Data de Entrada: 14/01/13 Postagens Recentes
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
Pernes Panta, modificado 6 Anos atrás.

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

New Member Postagens: 6 Data de Entrada: 07/11/17 Postagens Recentes
hi Kyle,
Thousand thanks for your help.
Now all work perfectly.
Thank you very much
I love liferay 7
Pernes
thumbnail
Kyle Joseph Stiemann, modificado 6 Anos atrás.

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

Liferay Master Postagens: 760 Data de Entrada: 14/01/13 Postagens Recentes
Glad to hear it! Thanks for using Liferay Faces!

- Kyle