Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Get themeDisplay object from liferay's dxp rest module
Naresh Reddy Kallamadi, modified 6 Years ago.
Regular Member
Posts: 120
Join Date: 7/9/14
Recent Posts
Hi All,
I am trying to get themeDisplay object from rest module , As I dont have request object I couldn't able to get it.
From themeDisplay i am trying to getting below things:
portalURL
themeDisplay.getPathThemeImages()
Can any one help to get above values from my rest module?
@POST
@Path("/sampleTest")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public Response someMethod(@HeaderParam("xyz") String xyz,
@HeaderParam("abc") String abc) {
// Here I need to get themeDisplay object
}
Thanks,
Naresh Kallamadi.
I am trying to get themeDisplay object from rest module , As I dont have request object I couldn't able to get it.
From themeDisplay i am trying to getting below things:
portalURL
themeDisplay.getPathThemeImages()
Can any one help to get above values from my rest module?
@POST
@Path("/sampleTest")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public Response someMethod(@HeaderParam("xyz") String xyz,
@HeaderParam("abc") String abc) {
// Here I need to get themeDisplay object
}
Thanks,
Naresh Kallamadi.
Facing same scenario. Any solution to it?
A request for a page always has implicit data, e.g. the site you're asking for, the current page, the layout of the page, the theme of the page. That is not the case for a REST call: It's neither bound to a page, nor a site, unless it brings the relevant parameters explicitly. Thus a ThemeDisplay object, which encapsulates all this implicit context, can't be automagically created. Instead, you'll have to figure out the relevant configuration parameters for yourself: As you're not bound to a page, that (non)page doesn't have a theme, thus you won't know where the theme-images are (coming back to the original question for themeDisplay.getPathThemeImages()
A REST call is a different beast than what you see in a portlet, and you can't expect any context to spill over. You'll have to provide the data yourself.
A REST call is a different beast than what you see in a portlet, and you can't expect any context to spill over. You'll have to provide the data yourself.
As Olaf said, since a rest call has no relation to pages, there is no themedisplay object.
There are several solutions possible, which one is "best", depends on your usecase.
You can add a configuration and store the path to the images there, maybe you can solve this on the frontend (Liferay adds a javascript themeDisplay variable to each page) and use getPathThemeImages() there, maybe you can add the images to your module and reference them from there, ...
There are several solutions possible, which one is "best", depends on your usecase.
You can add a configuration and store the path to the images there, maybe you can solve this on the frontend (Liferay adds a javascript themeDisplay variable to each page) and use getPathThemeImages() there, maybe you can add the images to your module and reference them from there, ...
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™