public void init(PortletConfig config) throws PortletException {
    super.init(config);
    // create application properties with default
    Properties defaultProps =
        PropertiesUtils.loadDefault(getPortletContext().getRealPath(default_properties));
    applicationProps = new Properties(defaultProps);
    // now load properties from last invocation
    applicationProps =
        PropertiesUtils.loadLastState(
            applicationProps, getPortletContext().getRealPath(saved_properties));

    // sets values
    if (applicationProps.getProperty("defaultURL") != null)
      defaultURL = applicationProps.getProperty("defaultURL");
    if (applicationProps.getProperty("defaultHeight") != null)
      defaultHeight = applicationProps.getProperty("defaultHeight");
    if (applicationProps.getProperty("defaultWidth") != null)
      defaultWidth = applicationProps.getProperty("defaultWidth");
    if (applicationProps.getProperty("defaultMessage") != null)
      defaultMessage = applicationProps.getProperty("defaultMessage");
    if (applicationProps.getProperty("hide_url") != null)
      if (applicationProps.getProperty("hide_url").equalsIgnoreCase("true")) hide_url = true;
    if (applicationProps.getProperty("hide_new_windows") != null)
      if (applicationProps.getProperty("hide_new_windows").equalsIgnoreCase("true"))
        hide_new_windows = true;

    // CREATOR_CONSULTATION = new CreateConsultation();
    // CREATOR_URI = new CreateUri();
    emf_consultation = Persistence.createEntityManagerFactory("consultation");
    emf_resource = Persistence.createEntityManagerFactory("resource");
    daoConsultation = new DAOConsultation(emf_consultation);
    daoResource = new DAOResource(emf_resource);
  }
 private void doUpdate(ActionRequest request, ActionResponse response, StringBuffer message)
     throws ReadOnlyException, ValidatorException, IOException, PortletModeException {
   String url = request.getParameter("default-url");
   // System.out.println("[BrowserPortlet.doUpdate] url : " + url);
   String height = request.getParameter("height");
   String width = request.getParameter("width");
   String noMessage = request.getParameter("nomessage");
   boolean px = false;
   boolean save = true;
   // boolean save = true;
   if ((url != null) && (height != null) && (width != null) && (noMessage != null)) {
     if (!url.startsWith("http://")) {
       save = false;
       message.append("URLs must start with 'http://'<br/>");
     }
     try {
       if (height.endsWith("px")) {
         height = height.substring(0, height.length() - 2);
       }
       Integer.parseInt(height);
     } catch (NumberFormatException nfe) {
       // Bad height value
       save = false;
       message.append("Height must be an integer<br/>");
     }
     try {
       if (width.endsWith("px")) {
         px = true;
         width = width.substring(0, width.length() - 2);
       } else if (width.endsWith("%")) {
         width = width.substring(0, width.length() - 1);
       }
       Integer.parseInt(width);
     } catch (NumberFormatException nfe) {
       // Bad height value
       save = false;
       message.append("Width must be an integer<br/>");
     }
     if (save) {
       if (request.getParameter("hide") != null
           && request.getParameter("hide").equalsIgnoreCase("hide")) {
         hide_url = true;
         request.removeAttribute("hide");
       } else hide_url = false;
       if (request.getParameter("hide_open") != null
           && request.getParameter("hide_open").equalsIgnoreCase("hide")) {
         hide_new_windows = true;
         request.removeAttribute("hide");
       } else hide_new_windows = false;
       // System.out.println("[BrowserPortlet.doUpdate] save");
       response.setRenderParameter("height", height + "px");
       response.setRenderParameter("width", px ? width + "px" : width + "%");
       // response.setRenderParameter("url", url);
       request.getPortletSession().setAttribute("current_url", url);
       // this.sendEvent("url", url, response);
       this.sendEvent("loadedurl", url, response);
       response.setRenderParameter("message", noMessage);
       defaultURL = url;
       sendEvent("default_url", url, response);
       request
           .getPortletSession()
           .setAttribute("default_url", url, request.getPortletSession().APPLICATION_SCOPE);
       defaultHeight = height + "px";
       defaultWidth = px ? width + "px" : width + "%";
       defaultMessage = noMessage;
       applicationProps.setProperty("defaultURL", defaultURL);
       applicationProps.setProperty("defaultHeight", defaultHeight);
       applicationProps.setProperty("defaultWidth", defaultWidth);
       applicationProps.setProperty("defaultMessage", defaultMessage);
       if (hide_url) applicationProps.setProperty("hide_url", "true");
       else applicationProps.setProperty("hide_url", "false");
       if (hide_new_windows) applicationProps.setProperty("hide_new_windows", "true");
       else applicationProps.setProperty("hide_new_windows", "false");
       PropertiesUtils.store(
           applicationProps,
           getPortletContext().getRealPath(saved_properties),
           "[PortletWebBrowser.doUpdate]");
       response.setPortletMode(PortletMode.VIEW);
       return;
     }
     response.setRenderParameter("message", message.toString());
     response.setPortletMode(PortletMode.VIEW);
   }
 }