Try now Demo en
  • en
  • fr
  • de
  • Product
    • Platform
      • Software TourFeatures & capabilities overview
      • Why eXoeXo Platform key differentiators
      • InternationalisationSupporting multilingual environments
      • MobileResponsive & available on any device
    • Technology
      • No CodeTailor eXo platform to your needs
      • ArchitectureAn overview of eXo Platform technology
      • IntegrationsAvailable connectors & integration capabilities
      • SecurityeXo Platform security measures
      • Open sourceComponents & licensing
  • Solutions
    • Communication
      • Modern IntranetBuild your company culture
      • Knowledge managementCentralize and share your company knowledge
      • Community managementEngage your community
      • ExtranetInvolve your clients and partners
    • Collaboration
      • Social NetworkConnect all your employees
      • Collaboration PlatformEmpower your teams
      • Employee PortalCentralize your work environment
      • Employee EngagementEngage & empower your employees
    • For
      • Public Sector
      • Networks
      • Education
      • Enterprises
  • Pricing
  • Resources
    • Resource center
      • Case studies
      • White Papers
      • Datasheets
      • Videos
    • Migration guide
      • Alternative to Microsoft 365
      • Alternative to Sharepoint
      • Alternative to Workplace from Meta
    • From The Blog
      • eXo Platform 6.5 is released: personalized navigation, multi-sites management and more
      • eXo launches its online community platform – eXo Tribe!
      • Cloud Vs On-premise Digital Workplace: Which one is right for your business?
  • Community
    • CommunityJoin our online community platform
    • DownloadLaunch eXo platform in your infrastructure
    • Source codeSource code on github
    • FAQsAbout the software, the community and our offers
    • REST APIs & DocumentationAll REST APIs available in eXo Platform
  • Company
    • Customers
    • Partners
    • Services
    • About us
    • Contact us
    • Newsroom
  • Menu mobile
    • Pricing
    • About us
    • Careers
    • Resource center
    • Blog
    • Contact us
    • Try eXo
Platform
  • Software Tour Features & capabilities overview
  • Why eXo eXo Platform key differentiators
  • Internationalisation Supporting multilingual environments
  • Mobile Responsive & available on any device
Technology
  • No Code Tailor eXo platform to your needs
  • Architecture An overview of eXo Platform technology
  • Integrations Available connectors & integration capabilities
  • Security eXo Platform security measures
  • Open source Components & licensing
Communication
  • Modern Intranet Build your company culture
  • Knowledge management Centralize and share your company knowledge
  • Community management Engage your community
  • Extranet Involve your clients and partners
Collaboration
  • Social Network Connect all your employees
  • Collaboration Platform Empower your teams
  • Employee Portal Centralize your work environment
  • Employee Engagement Engage & empower your employees
For
  • Public Sector
  • Networks
  • Education
  • Enterprises
Resource center
  • Case studies
  • White Papers
  • Datasheets
  • Videos
Migration guide
  • Alternative to Microsoft 365
  • Alternative to Sharepoint
  • Alternative to Workplace from Meta
From The Blog
  • eXo Platform 6.5 is released: personalized navigation, multi-sites management and more
  • eXo launches its online community platform – eXo Tribe!
  • Cloud Vs On-premise Digital Workplace: Which one is right for your business?
Community Join our online community platform
Download Launch eXo platform in your infrastructure
Source code Source code on github
FAQs About the software, the community and our offers
REST APIs & Documentation All REST APIs available in eXo Platform
Customers
Partners
Services
About us
Contact us
Newsroom
Pricing
About us
Careers
Resource center
Blog
Contact us
Try eXo
  1. Accueil
  2. Uncategorized
  3. Portlet Development in eXo Platform with JSF and RichFaces (Part 3/3)

Portlet Development in eXo Platform with JSF and RichFaces (Part 3/3)

One of the greatest strengths of the eXo Platform is that it integrates a lot of features, such as content management and collaboration or social capabilities.

After the development of a JSF 2 / RichFaces portlet, and the integration of the Content Management capabilities of the eXo Platform, we will learn, in this third tutorial, how to leverage the eXo Platform social features in your own business portlets. To do so, we will start from the portlet created in the previous tutorial and post an activity in the user’s activity stream when he buys a product.

The source code of this tutorial is available here.

Adding eXo dependencies

The first step is to add the eXo dependencies that will be used in our portlet. Edit your pom.xml and add these lines:

<dependency>
  <groupId>org.exoplatform.social</groupId>
  <artifactId>exo.social.component.core</artifactId>
  <version>1.2.6</version>
  <scope>provided</scope>
</dependency>

Using the eXo Social API

Now let’s create a service that will use the eXo Social API to post an activity in the user’s activity stream. For this, we will create a new class with the following method:

@Override
public void postActivity(String activityText) {

    // Gets the current container.
    PortalContainer container = PortalContainer.getInstance();

    // Gets the current user id
    ConversationState conversationState = ConversationState.getCurrent();
    org.exoplatform.services.security.Identity identity = conversationState.getIdentity();
    String userId = identity.getUserId();

    // Gets identityManager to handle an identity operation.
    IdentityManager identityManager = (IdentityManager) container.getComponentInstanceOfType(IdentityManager.class);

    // Gets an existing social identity or creates a new one.
    Identity userIdentity = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, userId, false);

    // Gets activityManager to handle an activity operation.
    ActivityManager activityManager = (ActivityManager) container.getComponentInstanceOfType(ActivityManager.class);

    // Saves an activity by using ActivityManager.
    activityManager.saveActivity(userIdentity, null, activityText);
}

This service retrieves the current user’s identity and then posts an activity for this identity with the given text.

We now use this service in our JSF view. The ‘Buy’ button of each product calls an action with the product’s data as parameter:

<h:commandButton value="Buy" styleClass="buyButton" action="#{comicsStoreBean.buy}">
  <f:param name="productId" value="#{product.id}" />
  <f:param name="productName" value="#{product.name}" />
</h:commandButton>

And this action, added in the ComicsStoreBean managed bean, uses our previously created service to post the activity:

public void buy() {
    FacesContext context = FacesContext.getCurrentInstance();
    ActionRequest request = (ActionRequest) context.getExternalContext().getRequest();
    String productName = request.getParameter("productName");
    socialService.postActivity("I have just bought <b>" + productName + "</b> !");
}

You can now see the result in your activity stream after clicking on the Buy button of one of the products by going to the ‘intranet’ demo site (My Sites > intranet):

social-activity

eXo Social offers you a lot of others possibilities, such as posting an activity in a space, posting different kinds of activity (for instance content activity, such as the one in the screenshot for the “iron-man-2.jpg” file), adding a comment to an activity, getting the relations of an user, getting the users of a space,…

Besides this Java API, the eXo social feature offers a REST API and the OpenSocial API.

In this tutorial, we learnt how to use the eXo Social API to post an activity from your own business portlet.

Don’t hesitate to take a look at the documentation to discover all the available APIs.

(original article from Thomas blog)

Brahim Jaouane

I am a Digital Marketing specialist specialized in SEO at eXo Platform. Passionate about new technologies and Digital Marketing. With 10 years' experience, I support companies in their digital communication strategies and implement the tools necessary for their success. My approach combines the use of different traffic acquisition levers and an optimization of the user experience to convert visitors into customers. After various digital experiences in communication agencies as well as in B2B company, I have a wide range of skills and I am able to manage the digital marketing strategy of small and medium-sized companies.

Full-featured digital workplace with everything your employees need to work efficiently, smartly integrated for a compelling employee experience

  • Product
    • Software tour
    • Communication
    • Collaboration
    • Knowledge
    • Productivity
    • Open Source
    • Integrations
    • Security
  • Uses cases
    • Digital Workplace
    • Intranet software
    • Collaboration software
    • Knowledge management software
    • Entreprise Social Network
    • Employee Engagement platform
  • Roles
    • Internal Communications
    • Human Resources
    • Information Technology
  • Company
    • Product offer
    • Services Offer
    • Customers
    • Partners
    • About us
  • Resources
    • FAQs
    • Resource Center
    • Collaboration guide
    • What is a Digital workplace?
    • What is an intranet?
    • Employee engagement
  • Terms and Conditions
  • Legal
  • Privacy Policy
  • Accessibility
  • Contact us
  • Sitemap
  • Facebook
  • Twitter
  • LinkedIn
wpDiscuz