cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a value from a Java bean

droverflow
Champ in-the-making
Champ in-the-making
Hi all,

I'm trying to create a Java bean and use it inside an expression, but can't figure out how to get it to work…

<activiti:formProperty id="firstName" name="First name" type="string" value="${Person.getFirstname()}" writable="false" />


package beans;

import java.io.Serializable;

public class Person implements Serializable {

   private static final long serialVersionUID = 1L;
   
   private String firstname = "xxx";
   
   public Person() {
      firstname = "xxx";
   }
   
   public void setFirstname() {
      firstname = "xxx";
   }
   
   public String getFirstname() {
      return firstname;
   }
}

1. Do I have to create a .class or a .jar file out of my Java file?
2. In which directory do I have to put the created file?
3. Do I have to configure anything else (e.g. edit a config file)?
4. Do I have to restart Tomcat?
5. Anything else that is important?

I know that these are very basic questions, but unfortunately the Activiti user guide is not very appropriate for beginners… Smiley Sad

Any help appreciated!

Regards,
Doc
2 REPLIES 2

trademak
Star Contributor
Star Contributor
Hi,

If you are looking for a more comprehensive introduction take a look at my Activiti in Action book.
I expect you want to use the Activiti Explorer to run the process?
If yes then you'll need to create a JAR file with your class implementation. This JAR file must be deployed in the WEB-INF/lib directory of the Activiti Explorer web application. And yes Tomcat has to be restarted.
And if you are not using the class as a Spring bean you'll also have to create a process variable with the bean instance.

Best regards,

roig
Champ in-the-making
Champ in-the-making
You will first need to understand the architecture you want to use in your application.
  • Do you want to embed only the engine and create your own web-app (e.g. Jetty embedded)? if so then you will need to add the class to your class path.

  • Do you want to use the web-explorer (i.e. use the demo?), then you will need to add it to the war file (I believe there is a way to dynamically add classes to the war - google it)

  • I will follow trademak advise and say that reading Aactiviti in action is a great starting point.