Hi,
I am wondering what the best way (or at least a good way) of knowing when you are running in a portlet (Liferay in this case) vs just running as a servlet.
I am following some instructions from the Vaadin book about testing my portlet as a servlet first to make things easier… and it does. Now I want to add some portlet specific stuff but only if I am running in a portal.
In my searches I have seen that in Vaadin 6 you could go something like the following (and also found it in the Vaadin 6 book):
// Check that we are running as a portlet.
if (getContext() instanceof PortletApplicationContext2) {
// We are in a portlet....
For Vaadin 7, possibly the book page is still to be written? Section 12.6. Portlet Context is still to be done and maybe this is where it would be covered?
Anyhow, I have code like the following:
if (request instanceof VaadinPortlet.VaadinLiferayRequest) {
System.out.println("I am a Vaadin Liferay Request");
} else {
System.out.println("I am not a Vaadin Liferay Request");
}
When running outside of a portlet I get a java.lang.NoClassDefFoundError: javax/portlet/filter/PortletRequestWrapper exception, which I guess I could catch, and then assume I am not running in a portlet…
Is there a better way to tell if I am running in a portlet?
Thanks for any help.