Support > Wagby Developer Network(R7) > Customize with Java > Create customization code with Eclipse
ja | en

I will explain how to create Java customization code through a simple sample.

Place the customization code in the customize folder.There are the following rules.

Java code
Store it in customize/java.
setting file
Files such as properties are stored in customize/resources.
Files published on the Web
Files that are published on the web such as HTML, JSP, image files, etc. are stored in customize/webapp.
Figure 1 Customize Folder

In this example, we will create a Java customization code that embeds values ​​as initial values ​​at the time of new registration for the "customer" model.

Although this example can be realized with standard functions, it is explained as an example of Java customization code.

In the project explorer, click the mouse right click button in the customize/java folder and select "New> Other ...".

Figure 2 Creating a new file

Specify the Java class in the new wizard.

Figure 3 Creating a Java class

Specify package name, class name, super class.

In this example we are targeting the customer model.The package name is based on the standard "jp.jasminesoft.wagby".

As shown in this example, the customization class inherits the automatically generated class (CustomerHelper in this case) and sets the prefix with "My" as the class name.

Figure 4 Naming customization classes

A template of the customized class is generated.(FIG. 5)

Figure 5 A customized class template is prepared

Next, overwrite (override) the method that is automatically generated. Right click on the mouse on the edit screen to display the menu.Select "Source> Method Override/Implementation ...".

Figure 6 Overriding methods

In this case, specify the autoize method initialize.(This method is provided to set the initial value of the object displayed on the new registration screen.)

Figure 7 Specifying methods

A method is provided.Standard is to execute methods of parent class.

Figure 8 Prepared Customization Method

Add the following code.

Customer.setName ("Natsume Soseki");

We have set the initial value of the name field.

Figure 9 Adding code

After creating customization code, you need to build (difference build) with WagbyDesigner.

* If Tomcat is running, it is good to stop and build it once.

Code in the customize folder is automatically placed in the web application when building with Wagby Designer. The contents of the java folder are compiled and stored in WEB-INF \ classes. The content of the resources folder is stored in WEB-INF \ classes as is. The content of the webapp folder is stored in the corresponding folder.

Figure 10 Building with WagbyDesigner

With the build process, WEB-INF \ applicationContext \ customer.xml will be overwritten.I will use MyCustomerHelper (which is a customized class) instead of CustomerHelper.

This is an example of executing a built application.On the new registration screen, you can see that the specified value is set.

Figure 11 Running Customized Application

After creating the customization code, it can be automatically generated again. The procedure in this case is as follows.

  1. Stop the Web application and exit Eclipse.
  2. Automatically generate and build with WagbyDesigner.
  3. Start Eclipse and refresh the project.