RE: Get themeDisplay object from liferay's dxp rest module

thumbnail
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.
Tej Dave, modified 5 Years ago. New Member Posts: 11 Join Date: 12/24/19 Recent Posts
Facing  same scenario. Any solution to it? 
thumbnail
Olaf Kock, modified 5 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
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.
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
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, ...