private void init() {
    error = false;
    SinekartaUtility su = SinekartaUtility.getCurrentInstance();

    su.setDataToAppletCertificateChoice(null);
    su.setDataFromAppletCertificateChoice(null);
    su.setDataToAppletSign(null);
    su.setDataFromAppletSign(null);
    description = null;
    selectedDocumentNodePdf = null;

    selectedDocumentNode = browseBean.getActionSpace().getNodeRef();

    documentName =
        (String) su.getNodeService().getProperty(selectedDocumentNode, ContentModel.PROP_NAME);

    documentPath =
        NodeTools.translatePath(
            su.getNodeService(), su.getNodeService().getPath(selectedDocumentNode));
    documentPath = documentPath.substring(0, documentPath.indexOf(documentName));

    // verify if a signed document version of this document already exists
    selectedDocumentNodeParent =
        su.getNodeService().getPrimaryParent(selectedDocumentNode).getParentRef();

    NodeRef exist = null;
    int i = 0;
    do {
      // calculating new filename
      documentNamePdf =
          (String) su.getNodeService().getProperty(selectedDocumentNode, ContentModel.PROP_NAME);
      int dotIdx = documentNamePdf.lastIndexOf('.');
      if (i == 0) {
        documentNamePdf =
            documentNamePdf.substring(0, dotIdx)
                + Configuration.getInstance().getSignedSuffix()
                + documentNamePdf.substring(dotIdx);
      } else {
        documentNamePdf =
            documentNamePdf.substring(0, dotIdx)
                + " ("
                + i
                + ")"
                + Configuration.getInstance().getSignedSuffix()
                + documentNamePdf.substring(dotIdx);
      }

      // adjust documentName
      documentName = PDFTools.calculatePdfName(documentNamePdf);

      exist = su.getFileFolderService().searchSimple(selectedDocumentNodeParent, documentName);
      i++;
    } while (exist != null);

    // preparazione area di input per applet

    prepareDataToAppletCertificateChoice();

    su.setDataFromAppletCertificateChoice(null);
  }
  public String next() {
    String stepName = Application.getWizardManager().getCurrentStepName();
    SinekartaUtility su = SinekartaUtility.getCurrentInstance();

    if (stepName.equals(STEP_NAME_CERTIFICATE_CHOICE)) {

      prepareDataToAppletCertificateChoice();

      su.setDataFromAppletCertificateChoice(null);

    } else if (stepName.equals(STEP_NAME_SIGN)) {

      // adjust documentName
      documentName = PDFTools.calculatePdfName(documentNamePdf);

      // verify if a signed document version of this document already exists
      NodeRef folder = su.getNodeService().getPrimaryParent(selectedDocumentNode).getParentRef();

      if (su.getFileFolderService().searchSimple(folder, documentName) != null) {
        Util.addFatalMessage(BUNDLE_GENERIC_SIGN, "fileAlreadyExists", "fileAlreadyExistsDesc");
        Application.getWizardManager()
            .getState()
            .setCurrentStep(Application.getWizardManager().getCurrentStep() - 1);
        return null;
      }

      prepareDataToAppletSign();

      su.setDataFromAppletSign(null);
    }

    return null;
  }