3 Replies Latest reply on May 10, 2008 7:29 AM by kukeltje

    Is it possible???

    simplysmart1

      hi for all,
      this a code of a class that i have created (WriteFile.java):

      package com.sample.action;
      
      import java.io.*;
      import org.jbpm.graph.def.ActionHandler;
      import org.jbpm.graph.exe.ExecutionContext;
      
      
      public class WriteFile implements ActionHandler {
      
      
       private static final long serialVersionUID = 1L;
      
       public void execute(ExecutionContext executionContext) throws Exception {
      
      
       String message= null;
       executionContext.getContextInstance().setVariable("message", message);
       Object object=new Object();
       object=executionContext.getVariable("Priorite");
      
       // Stream to write file
       FileOutputStream fout;
      
       try
       {
       // Open an output stream
       fout = new FileOutputStream ("C:\\wamp\\www\\uib-ged\\ref.txt");
      
       // Print a line of text
       new PrintStream(fout).println (object);
      
      
       // Close our output stream
       fout.close();
       }
       // Catches any error conditions
       catch (IOException e)
       {
       System.err.println ("Unable to write to file");
       System.exit(-1);
       }
      
      
      
      
       }
      
       }
      


      and this is a code of an xhtml file generated and modified:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:c="http://java.sun.com/jstl/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:tf="http://jbpm.org/jsf/tf"
       xmlns:jbpm="http://jbpm.org/jsf">
      <style type="text/css">
      <!--
      .Style1 {
       font-family: "Times New Roman", Times, serif;
       font-style: italic;
       font-weight: bold;
      }
      .Style2 {font-family: "Times New Roman", Times, serif}
      -->
      </style>
      
      <ui:component>
      
       <div style="margin-top:20px;margin-bottom:20px">
       <ul>
       <li><em><strong>Debut de l'etude du dossier.</strong></em></li>
       </ul>
       </div>
       <div style="margin-top:20px;margin-bottom:20px">
       <ul>
       <li class="Style2"><em><strong>
       <span class="Style1">Vous etes invites a donner la priorite du dossier et a introduire la reference
       de l'hypotheque avec laquelle vous avez realise l'indexation dans la GED</span></strong></em></li>
       </ul>
       </div>
      <jbpm:dataform>
       <f:facet name="header">
       <h:outputText value="Tache: Saisie de l'hypotheque dans la GED"/>
       </f:facet>
       <!-- TASKFORM ROWS -->
       <jbpm:datacell>
       <f:facet name="header">
       <h:outputText value="Priorite du credit de 1 a 5 :"/>
       </f:facet>
       <h:selectOneMenu value="#{var['Priorite']}">
       <f:selectItem itemLabel="1" itemValue="1" />
       <f:selectItem itemLabel="2" itemValue="2" />
       <f:selectItem itemLabel="3" itemValue="3" />
       <f:selectItem itemLabel="4" itemValue="4" />
       <f:selectItem itemLabel="5" itemValue="5" />
       </h:selectOneMenu>
       </jbpm:datacell>
       <jbpm:datacell>
       <f:facet name="header">
       <h:outputText value="Date de la saisie de l'hypotheque"/>
       </f:facet>
       <h:inputText value="#{var['Date_saisie_hypo']}" />
       </jbpm:datacell>
       <jbpm:datacell>
       <f:facet name="header">
       <h:outputText value="Reference de l'hypotheque"/>
       </f:facet>
       <h:inputText value="#{var['Ref_hypo_GED']}" />
       </jbpm:datacell>
       <jbpm:datacell>
       <f:facet name="header">
       <h:outputText value="Valider votre tache"/>
       </f:facet>
       <!-- TASKFORM BUTTONS -->
       <tf:transitionButton value="Valider"/>
       </jbpm:datacell>
      </jbpm:dataform>
      </ui:component>
      </html>
      

      i precise i'm not an expert on j2EE so my question is : can i execute the previous class (WriteFile.java) when pressing the transition button!!if it is possible please give me an idea how to do it.

      thanks and sorry if my question seem stupid!!but this what i want to do,
      any help will be appreciated!! i precise that i'm not interessted with the execution of this calss by putting it in an action and use it after or before a signal or when leaving a node !!! i want to execute this calss after pressing the transition button on an xhtml file.

      Really thnaks for all

        • 1. Re: Is it possible???
          kukeltje

          if you do not want to put it as an action on the transition.... basic jbpm functionality.... then make a jsf backing bean out of it and do not use the jbpm transition button

          • 2. Re: Is it possible???
            simplysmart1

             

            "kukeltje" wrote:
            if you do not want to put it as an action on the transition.... basic jbpm functionality.... then make a jsf backing bean out of it and do not use the jbpm transition button


            please can you give more details!!sorry but really i want more details of how exactly can i do it.

            thanks

            • 3. Re: Is it possible???
              kukeltje

              sorry, I do not have the time for that. Since it is *basic* stuff, I'd suggest reading about JSF, looking at jBPM examples (e.g. including testcase in the source) etc