Search code examples
liferayliferay-6liferay-themeliferay-auiliferay-ide

Liferay 6.2: How to get window state in JSP?


I have to get current Liferay Window state in jsp file. I have tried

WindowState.class.toString()

It is giving result class javax.portlet.WindowState

I also try for actionResponse.getWindowState().toString() It is giving the same result as above.

I just want to check in my jsp file portlet is in which state, and write the conditions accordingly. I am looking for the condition like (actionResponse.getWindowState().toString()).equals(WindowState.MAXIMIZED)

I am getting exception in above condition. By which means I can get current state of the portlet in JSP.


Solution

  • What you want is one of the following:

    portletRequest.getWindowState() == WindowState.MAXIMIZED
    actionRequest.getWindowState() == WindowState.MAXIMIZED
    renderRequest.getWindowState() == WindowState.MAXIMIZED
    

    (You can use .equals() on the state as well, but that is not necessary, as it is a constant value).

    The toString() method of any Class object will always return class + the class name. I don't see why you are even try to do that - it seems that you need to investigate the differences between of objects, classes, variables and constants.