filnet pe eform

We have a jsp where we list links of tasks that open the corresponding eform.

I created the code to display the eform by exploring some XSL files in the workplace web application.

Here you have it. You'll have to adapt some parts of the code as it references to some of our custom variables and constants.

Example of use:

String token = getWorkplaceUserToken(user, pwd);
String label = "click here";
String attribs = "class=\"mylink\"";
String returnUrl = "tasksPage.jsp?refresh=true";
String eformLink = getStepProcessorLink(wob, label, attribs, returnUrl, token);
out.print(eformLink);

Code:
   /**
    * Gets a string with an HTML 'A' tag to open the task with the appropriate step processor.
    *
    * @param wob             work item
    * @param label           label that will display the A link (can be anything that could be placed within the A tag)
    * @param linkAttributes  other link attributes, for example: "class ='xxx' style='yyy'" (can be null)
    * @param refreshUrl      usually the page that displays this link (it will be used to refresh this page when the task is closed)
    * @param userToken       user identification token for workplace automatic login
    */
   public static String getStepProcessorLink(VWWorkObject wob, String label, String linkAttributes, String refreshUrl, String userToken) throws Exception {
        String link = null;
      VWStepProcessorInfo stepProcessor = wob.fetchStepProcessorInfo();

        if (stepProcessor != null) {
            VWStepElement stepElement = wob.fetchStepElement();
            link = getStepProcessorLink(label, linkAttributes, stepProcessor.getId(), stepElement.getQueueName(), wob.getWorkObjectNumber(), stepElement.getStepName(), stepProcessor.getWidth(), stepProcessor.getHeight(), refreshUrl, userToken );
        }
     
      return link;
   }

  
   /**
    * Translated from getStepProcessorUrl template in WcmProcessorInfo.xsl
    */
   private static String getStepProcessorLink(String label, String linkAttributes, int stepProcId, String queueName, String wobNum, String stepName, int width, int height, String refreshUrl, String userToken) throws Exception {

      String fullUrl = getStepProcessorHtmlHref(wobNum,stepName,queueName,stepProcId,userToken);
     
        String randomNumber = WcmEncodingUtil.getRandomNumber();

        String wBasePath = FilenetResources.getWorkplaceBasePath();
       
        //WcmURLBuilder wcmurlbuilder = new WcmURLBuilder(CLOSE_STEP_WINDOW_PATH);
        WcmURLBuilder wcmurlbuilder = new WcmURLBuilder(wBasePath + "/utils/CloseStepWindow.jsp");
       
        wcmurlbuilder.addParameter("refreshUrl", WcmEncodingUtil.encodeURL(refreshUrl)); // refreshUrl is WcmUiModule.getPageUrl(null, null)
        String currentPageURL = wcmurlbuilder.toString();

        String returnUrl = Util.URLEncode(currentPageURL);
       
        String hrefUrl = getItemLinkHref( fullUrl, randomNumber, width, height );
        String url = fullUrl + AMP + "returnUrl=" + returnUrl;
        String clickUrl = getItemLinkOnclick( url, randomNumber, width, height );
       
        if( linkAttributes == null ) linkAttributes = "";
       
        String link = "<a " + linkAttributes + " href=\"" + hrefUrl + "\" onClick=\"" + clickUrl + "\">" + label + "</a>";
       
        return link;
   }

   /**
    * Translated from getItemLinkOnclick template in ListViewJavascriptLinks.xsl
    */
   private static String getItemLinkOnclick(String url, String title, int width, int height) {

      String itemLinkOnclick = "var x=(screen.width-" + width + ")/2;var y=(screen.height-"
            + height + ")/2;" + "var f=" + APOS
            + "resizable=yes,scrollbars=yes,status=yes,width=" + width
            + " + height=" + height + " + top=" + APOS + "+y+ "
            + APOS + " + left=" + APOS + "+x;"
            + "var w=window.open(" + APOS + url + APOS + ","
            + APOS + title + APOS + "," + "f" + ")"
            + ";w.focus();return false;";
     
      return itemLinkOnclick;
   }

   /**
    * Translated from getItemLinkHref template in ListViewJavascriptLinks.xsl
    */
   private static String getItemLinkHref(String url, String title, int width, int height) {
     
      String itemLinkHref = "javascript:var x=(screen.width-" + width
            + ")/2;var y=(screen.height-" + height + ")/2;" + "var f="
            + APOS + "resizable=yes,scrollbars=yes,status=yes,width="
            + width + ",height=" + height + ",top=" + APOS + "+y+ "
            + APOS + ",left=" + APOS + "+x;" + "var w=window.open("
            + APOS + url + APOS + "," + APOS + title + APOS
            + "," + "f" + ")" + ";w.focus();";
     
      return itemLinkHref;
   }

   /**
    * Translated from getStepProcessorHtmlHref template in WcmProcessorInfo.xsl
    */
   private static String getStepProcessorHtmlHref(String wobNum, String stepName, String queueName, int stepProcId, String userToken) throws Exception {

      String encodedStepName = WcmEncodingUtil.encodeLabel(stepName);
      String encodedQueueName = WcmEncodingUtil.encodeLabel(queueName);
      String encodedUserToken = URLEncoder.encode(userToken, "UTF-8");

      String wBasePath = FilenetResources.getWorkplaceBasePath();
     
      String url = wBasePath
            + "/getProcessor?"
            + "processorType=" + "step"
            + AMP + "queueName=" + encodedQueueName
            + AMP + "wobNum=" + wobNum
            + AMP + "stepName=" + encodedStepName
            + AMP + "stepProcId=" + stepProcId
            + AMP + "ut=" + encodedUserToken;

      return url;

   }

   /** Get token credentials for workplace */
   public static String getWorkplaceUserToken(String user, String password) throws Exception {
     
      String workplaceUrl = FilenetResources.getWorkplaceBasePath();

      URL url = new URL(workplaceUrl + "/setCredentials?op=getUserToken&userId=" + user + "&password=" + password + "&verify=true");  
      URLConnection p8con = url.openConnection();
      p8con.connect();
      InputStream in = p8con.getInputStream();
  
      BufferedReader br = new BufferedReader(new InputStreamReader(in));
     
      return br.readLine();
   }



ecm link:http://www.ecmplace.com/viewtopic.php?f=29&t=7288

猜你喜欢

转载自xkorey.iteye.com/blog/1481528
PE
今日推荐