Skip to content

Commit

Permalink
feat: Allow to define Parent CSS Classes on Application Parent Contai…
Browse files Browse the repository at this point in the history
…ner - MEED-7094 - Meeds-io/MIPs#144 (#916)

This change will allow to define a custom CSS class to a portlet using a
portlet.xml definition inside an init param with key 'layout-css-class'.
This CSS is part of portlet definition and not attached to a particular
of Portlet instance only.
  • Loading branch information
boubaker authored Jun 20, 2024
1 parent a7f4963 commit e5ce953
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@
}
cssStyle = " style=\"" + cssStyle + "\"";
}
String cssClass = uicomponent.getCssClass() == null ? "" : " " + uicomponent.getCssClass();
%>
<div id="$portletId" $hiddenClass>
<div class="PORTLET-FRAGMENT" $cssStyle>
<div class="PORTLET-FRAGMENT$cssClass" $cssStyle>
<% println portletContent; %>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@

import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import lombok.Getter;
import lombok.Setter;

/**
* This UI component represent a portlet window on a page. <br>
Expand Down Expand Up @@ -195,6 +197,10 @@ public class UIPortlet<S, C extends Serializable> extends UIApplication {
/** A field storing localized value of javax.portlet.title * */
private String configuredTitle;

@Getter
@Setter
private String cssClass;

public String getStorageId() {
return storageId;
}
Expand Down Expand Up @@ -1068,8 +1074,8 @@ public Text generateRenderMarkup(PortletInvocationResponse pir, WebuiRequestCont
if (pir instanceof FragmentResponse) {
if (lazyResourcesLoading == null) {
PortletInfo portletInfo = producedOfferedPortlet.getInfo();
if (portletInfo instanceof ContainerPortletInfo) {
String prefetchResources = ((ContainerPortletInfo) portletInfo).getInitParameter("prefetch.resources");
if (portletInfo instanceof ContainerPortletInfo containerPortletInfo) {
String prefetchResources = containerPortletInfo.getInitParameter("prefetch.resources");
lazyResourcesLoading = StringUtils.equals(prefetchResources, "true");
} else {
lazyResourcesLoading = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
import java.util.Set;

import org.exoplatform.portal.mop.service.LayoutService;

import org.gatein.common.net.media.MediaType;
import org.gatein.pc.api.Portlet;
import org.gatein.pc.api.info.ModeInfo;
import org.gatein.pc.api.info.PortletInfo;
import org.gatein.pc.portlet.impl.info.ContainerPortletInfo;

import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.Application;
Expand Down Expand Up @@ -249,7 +251,10 @@ private static <S> void toUIPortlet(UIPortlet<S, ?> uiPortlet, Application<S> mo
if (supportModes.size() > 1)
supportModes.remove("view");
uiPortlet.setSupportModes(supportModes);
}
if (portletInfo instanceof ContainerPortletInfo containerPortletInfo) {
uiPortlet.setCssClass(containerPortletInfo.getInitParameter("layout-css-class"));
}
}

public static void toUIContainer(UIContainer uiContainer, Container model) throws Exception {
uiContainer.setStorageId(model.getStorageId());
Expand Down

0 comments on commit e5ce953

Please sign in to comment.