Support > Repository > Business logic > Writable script
ja | en

You can write scripts called at the timing of processing on Designer.

Open "Screen> Script".Specify the execution timing and write the script.

Figure 1 Script input
Execution timingDescription
Registration "Initial value> At the time of registration" was doneafterIt is called.You can modify data just before registration.The data after this processing is saved in the database.
Perform "initial value> when registering"beforeWhen you call,Prepare function preprocesscan do.7.11
Registration (creation of initial data) "Initial value> when registering screen is displayed" was doneafterIt is called.You can modify the data for new registration.The data after this processing is displayed on the registration screen.
"Initial value> when registering screen is displayed" is performedbeforeWhen you call,Prepare function preprocesscan do.7.11
update "Initial value> When updating" was doneafterIt is called.You can modify the data just before updating.The data after this processing is saved in the database.
Perform "initial value> when updating"beforeWhen you call,Prepare function preprocesscan do.7.11
Detailed screen display "Initial value> when displaying detailed screen" was doneafterIt is called.You can modify the data just before display.The data after this processing is displayed on the detail screen.(It is not reflected in the database.It can be used when it is necessary to modify internal data just before display.For example, it hides some data when displayed.)
"Initial value> when displaying detailed screen" is performedbeforeWhen you call,Prepare function preprocesscan do.7.11
Detailed screen display (update) The value of the database is read at the time of opening the update screen, but this script will be called after that.It can be used when you want the user to input after modifying the update target data.
Detailed screen display (list) The value of the database is read at the time of opening the list screen, but this script is called after that.It can be used when it is necessary to modify the internal data just before the list display.
Calculation This script is invoked after executing the predefined automatic calculation formula.It can be used to implement more complicated processing which can not be described by automatic calculation formula.

In addition, when preparing this script, it is necessary that some form of arithmetic operation expression is specified in the model.(It may be a dummy definition like meaningless setting, for example, "set the value to 0", so please use the four arithmetic operation.)
Mass update "Search/list display screen> Display bulk update button"Is described.
Input check/Consistency check It is executed after functions such as mandatory check and character count check prepared by standard.(To be exact, it will be the last processing of the input check.)

Transaction processing

Transaction processing is described in model item detail definition.Detail is"Cross-model calculation (transaction)I will explain it.

Figure 2 Script for transaction control

Screen transition

You can also create a script to be executed at the timing of screen transition.Detail is"Screen transitionI will explain it.

A file with the extension ". Js" is generated from the script entered in Designer. The actual file is prepared in wagbyapp/webapp/$ (APPNAME)/WEB-INF/script/model ID folder.

$ (APPNAME)Project identifieris.The standard is "wagby".
Execution timingfile name
Registration Model IDHelper_beforeInsert.js
Registration (creation of initial data) Model IDHelper_initialize.js
update Model IDHelper_beforeUpdate.js
Detailed screen display Model IDHelper_beforeShow.js
Detailed screen display (update) Model IDHelper_beforeShowInUpdate.js
Detailed screen display (list) Model IDHelper_beforeShowInShowList.js
Calculation Model IDHelper_calc.js
Mass update ShowList Model IDController_do_updateRule.js
Check the input Model IDPInputCheckHelper_input_check.js
transaction Model IDEntityService_doTransactionBy $ {Item ID with transaction set} InsertTransaction.js
Model IDEntityService_doTransactionBy $ {Item ID that set the transaction} UpdateTransaction.js
Model IDEntityService_doTransactionBy $ {Item ID with transaction set up} DeleteTransaction.js
Screen transition Operation action + model ID + "_" + character string sent to the server by button operation .js

The "camel notation" rule is applied to "item ID" included in the above file name.

  • If the item ID is a compound word, start writing the beginning with lowercase letters.If the item ID is Item 123, in the script it will be item 123.
  • If "_" (underscore) is included in the item ID, that "_" is removed and the next letter is capitalized.For example, customer_id is customerId.Kana_name will be kanaName.
  • If the first character after capture of an underscore is lowercase letters and the second letter is uppercase letters, the beginning is also capitalized.For example, p_number becomes pNumber, and eventually it becomes PNumber.

You can find out what kind of script file is called at what timing by the following method.

  1. Open the jfcbase.properties contained in the webapps \ $ (APPNAME) \ WEB-INF \ classes folder of the built application with a text editor.
  2. Find the next line and remove the ";" at the beginning.
    (Before correction)
    ;jp.jasminesoft.jfc.ScriptCodeRunner.isOutputStatusToConsole=true
    ;jp.jasminesoft.jfc.ScriptCodeRunner4Controller.isOutputStatusToConsole=true
    (Revised)
    jp.jasminesoft.jfc.ScriptCodeRunner.isOutputStatusToConsole=true
    jp.jasminesoft.jfc.ScriptCodeRunner4Controller.isOutputStatusToConsole=true

  3. Start the application.
  4. Each time you manipulate the application, you see which script file you tried to execute on the Tomcat console.(It will not be executed unless the file exists.)