Initializing Portlets with PortletPreferences

I have stored some attributes of the portal in portlet preferences and would like to initialize my portlet based on it.

Howerver, it seems that the init method gets called before the handleResourceRequest method. So, there is no opportunity to initialize the portlet before the init invocation.

Relavant code

public class MyPortletUI extends UI implements PortletListener {
...
protected void init(VaadinRequest request) {
VaadinSession vSession = VaadinSession.getCurrent();
((VaadinPortletSession) vSession).addPortletListener(this);

setContent(getViewContent());

}
....
public void handleResourceRequest(ResourceRequest request,
ResourceResponse response, UI uI) {
System.out.println("==== HandleResourceRequest ====" + "isEditMode " + isEditMode + " " + request.getPortletMode() + " " + this.env);
if (this.env == null){
this.env = request.getPreferences().getValue("env", Environment.Development);
System.out.println("handleResourceRequest env inside this.env == null " + env);
//this.getContent().detach();
setContent(getViewContent());
}
if (environment == null){
environment = request.getPreferences();
System.out.println("==== Setting environment ====" + environment.toString());
}

if ((request.getPortletMode() == PortletMode.EDIT) && (isEditMode == false)){
setContent(getEditContent());
isEditMode = true;
System.out.println("==== Edit Mode ====");
}
else if ((request.getPortletMode() == PortletMode.VIEW) && (isEditMode == true)) {
setContent(getViewContent());
isEditMode = false;
System.out.println("==== View Mode ====");
}

}

Thanks,

Seems like PortletRequestListener has been removed in Vaadin 7 as a result we do not have access to onRequestStart method. There is no documentation on alternatives to this interface. Unless I find a way in Vaadin 7 , I am moving back to Vaadin 6

Ok, So this can be done in Vaadin 7 also. Turns out the simplest way is. This way, now the portlet can initialize itself with the PortletPreferences.

    protected void init(VaadinRequest request) {
        //Set the environment here
         VaadinPortletRequest vprRequest = (VaadinPortletRequest) request;
        PortletRequest pRequest = vprRequest.getPortletRequest();
        pRequest.getPreferences();
     ........
   }