Just add this to the portlet.xml file
<public-render-parameter>
<description>Shared render parameter that holds the toolbar state.</description>
<identifier>toolbarstate</identifier>
<qname xmlns:utb='http://www.ibm.com/xmlns/prod/websphere/portal/publicparams/utb'>utb:state</qname>
</public-render-parameter>
Inside the <portlet> tag you need to add:
<supported-public-render-parameter>toolbarstate</supported-public-render-parameter>
The value is then red using a normal:
String statevalue = renderRequest.getparameter("toolbarstate");