Code generator emulates the Interface and is responsible for generating code automatically for all the information entered in the interface. 
It records all the action done by the user on the interface and converts them into a code which is saved in (.java) format 

The basic workflow of using a generator is as follows:

  1. Click the code generator button;
  2. Fill in the fields that specify the code generation parameters. 
  3. Press the Generate button to generate the code files;
  4. Save the code file and copy paste it into your project Src.
  5. Review the code generation log.

Follow the steps below to  create controller code:

  • Open the j-guar application
  • Click on Controller code generator button
    on the right top corner
    (Controller code generator button: records everything that
    you do and convert that into a code.)
  • Select any module from the main menu.

 

  • We selected Material Management -->Definition --> Materials 

 

  • The material browser will open
  • create a new record by clicking the new button or select the type.
  • Try not to make errors and not use lookups.

 

  • Material İtem card will open.
  • Make changes or fill the required information.
  • Make sure you fill all the information by typing and not using them
    lookups.
  • After filling all the information, press Save.
  • close the browser

Click again at Controller code generator button to stop recording.

 

  • A pop-up will come.
  • Use the lookup and choose a directory folder where you want to
    save your java file.

 

  • Press save
  • A .java file will be saved to your directory.
  • copy the java file and open eclipse

 

  • Paste the java file into your customization Src

 

  • The code generated by the Controller code generator.
  • If you get an error that means we need to import the required jar files
  • For importing the jar files from lbs definition please follow the steps below.

 

MMBOController
package com.EasyLPT_forCZRT.customization;
import com.lbs.control.interfaces.ILbsController;
import com.lbs.controllers.ILbsControllerTask;
import com.lbs.controllers.gen.mm.MMXFItemBrowserController;
import com.lbs.controllers.gen.mm.MMXFItemController;
import com.lbs.controllers.menu.LbsMenuController;
import com.lbs.remoteclient.IClientContext;
public class MMBOControllerSample implements ILbsControllerTask
{
	private MyItem localItem = null;
	public MMBOControllerSample(MyItem myItem)
	{
		localItem = myItem;
	}
	
	public void execute(LbsMenuController menu, IClientContext context)
	{
		try
		{
			
			ILbsController controller = menu.launchMaterials();
			if (controller instanceof MMXFItemBrowserController)
			{
				MMXFItemBrowserController controller1 = (MMXFItemBrowserController) controller;
				controller = controller1.createNew_CGCommercialGood();
				if (controller instanceof MMXFItemController)
				{
					MMXFItemController controller2 = (MMXFItemController) controller;
					controller2.setCode("MyCODE2");
					controller2.setDescription(localItem.getdescription());
					controller2.selectCheckBox_TrackbyLocation();
					controller2.selectCheckBox_DiscountInapplicable();
					controller2.selectCheckBox_Configurable();
//					controller2.setGroupCode("");
					controller2.setSearchText("mytext");
					controller2.setAux_Code(localItem.getAuxCode());
				
//					controller2.setAux_Code("");
					controller2.clickSave();
				}
			}
		}
		catch (Exception e)
		{
			//TODO handle your exceptions
		}
	}
}

 

 

  • Go to copy controller jar
  • Select all
  • Copy

 

  • Now go to Forms and create a new empty form lets call it as " ExampleForm"
  • Put a button on the form which willcreatMMBO by controllers.

 

  • Go to property menu and click on events.
  • Click one-click to create a handler.
  • Create a new method --> Next
  • Give a name to the new method and Finish

 

  • The handler of the ExampleForm will be created.
  • The Create MMBO by controller button will call the remote services

 

Handler
 public void onClickCallMethod(JLbsXUIControlEvent event) throws Exception
	{
		IClientContext context = event.getClientContext();
		
		
		RemoteMethodResponse response = context.callRemoteMethod("CSRV", "echoFunctions", new Object[]{null,"Mymessage"});
		Object [] myArray = (Object[])response.Result;
		boolean result =(Boolean) myArray[0];
		
	}
	public void onClientClick(JLbsXUIControlEvent event)
	{
		JOptionPane.showMessageDialog(null,"message client");
	}
// The button will call the remote services
	public void onClickCreateMMBO(JLbsXUIControlEvent event)
	{
IClientContext context = event.getClientContext();
		
		// Create a new object for RemoteMethodResponse
		RemoteMethodResponse response = new RemoteMethodResponse();
		try
		// Change the name of the controller and put the response under try catch
		{
			response = context.callRemoteMethod("CSRV", "createMMBOByController", new Object[]{null});
		}
		catch (Exception e)
		{
		Object [] myArray = (Object[])response.Result;
		boolean result =(Boolean) myArray[0];
		
	}
	}}

 

  • After the our-Brower form is ready we can save and deploy our project.

 

  • After deploying our project lets run it on j-guar
  • Open j-guar application:
    Username: admin
    Password: logo

 

  • Open your ExampleForm under your project.
  • Click on Create MMBO by Controller button

 

  • The button leads you to the Controller code and it runs through the code.
  • It creates step by step everything through code that we did manually
  • So the purpose of Code generator to convert everything into code has been achieved.




Telif HakkıKullanım KoşullarıGizlilik
Copyright © 2018 Logo Yazılım