Support > Repository > Business logic > Screen transition

I will explain how to change Wagby's standard screen transition using script. R7.8

Set "Screen> Script> Controller".

First of all, you specify the script of which screen to write.

Figure 1 Entering a script - Specifying a screen

"Execution timing" is prepared for each screen.The script is called after the specified timing is over.

Figure 2 Input of script - specification of execution timing

Difference between helper 'registration' and controller 'registration'

When helper is registered, the XXXHelper # beforeInsert method calls the script.This is called "just before" to register in the database.

On the other hand, the registration process of the controller is called just before the database registration process etc. are all completed and control is transferred to the screen display (JSP).

From this difference, please describe the business logic such as "add/modify data at the time of registration" in helper's "registration time".In this case, the modified value is saved in the database.

Change Wagby standard screen transition rule

The purpose of creating a controller script is to change the Wagby standard screen transition rule. Specifically, it is described as follows.

return "redirect:/" + 遷移先の画面種別 + モデルID + アクション文字列
return "forward:/" + 遷移先の画面種別 + モデルID + アクション文字列

The prefix "redirect: /" or "forward: /" is required.The difference between them is explained in the section on "Redirect and Forward".Please use "redirect: /" as the standard.The screen type conforms to the specification of the SCREENTYPE function.The model ID is capitalized at the beginning.(Example: For customer model, it is Customer.Please check the action string with the sample from the next section.

Describe additional code with screen transition intact

If there is no change in the screen transition, you can omit the return statement.Write only the additional code.

In order to carry out consecutive registration processing, it is an example in which it switches to the registration screen again after ending the registration screen.

return "redirect:/";
Figure 3 Writing a script to operate when registering a customer model

Give parameters

You can pass the value selected on the previous registration screen to the recalled registration screen and display it as the initial value.

For example, to pass the value of another item reference (list box) item item 1, do as follows.

return "redirect:/"+customer.getItem1();

On the receiving side (item 1), write the following formula in the initial value (when the registration screen is displayed).


For details, refer to "Transition from screen transition (1) Details screen to registration screen> Handling of model reference items".

Give multiple parameters

To assign more than one parameter, separate each parameter with &.

return "redirect:/"+customer.getItem1()+"&item2="+customer.getItem2();

Apply the REQUEST () function to the initial value (when the registration screen is displayed) for all receiving side items.

Give a Japanese character string as a parameter

Consideration of character encoding is necessary when assigning a Japanese character string (including a character string other than the English-speaking region, including) as a parameter.

Here I will show you how to use utility class jp.jasminesoft.util.WebStringEncodeUtilities provided by Wagby.

var WebUtils = Java.type("jp.jasminesoft.util.WebStringEncodeUtilities");
return "redirect:/"+WebUtils.encodeString(customer.getCustomername());

Suppose you have created a "staff" model that is 1: 1 linked with the logon account model "juser" provided by the system.At this time, it meets the following requirements.

  • From the menu, you can update the "staff" model of yourself (logon ID) only.
  • Search screen and list screen are unnecessary.
  • After updating, make sure to return to the menu immediately instead of the detail screen.

Prepare a staff model

  1. Since the staff has a 1: 1 relationship with juser, we will make the staff's primary key identical to juser's primary key.Specifically, the primary key "staff ID" item should refer to the primary key item userid of the juser model.
    Figure 1 Staff ID is 1: 1 related to juser item
  2. The primary key "Staff ID" item is read-only.
    Figure 2 Read-only setting
  3. The primary key "staff ID" item is a hidden item when searching.
    Figure 3 Hidden setting when searching (combined with setting to search condition)
  4. In the main key "Staff ID" itemI will set the initial value as "Logon ID".This is set when registering, displaying, updating and searching.
    Figure 4 Setting initial values
  5. "Display search screen and list display screen at the same timeEnable ".
  6. "When the search result is one case, the screen is changed to the update screen"Is set to" always ".
    Fig. 5 Screen operation setting (1)
    Fig. 6 Screen operation setting (2)
  7. Change the label name displayed on the menu from "Staff Search" to "Staff Update".


Set the script to be called when the save button is pressed on the update screen.Move to the menu screen.

if (p.errors.sizeJfcwarn() == 0 && p.errors.sizeJfcerror() == 0) {
    return "redirect:/";

P.errors.sizeJfcwarn () returns the number of warning messages.P.errors.sizeJfcerror () returns the number of error messages.If there is a warning or error in the input check, the screen transition rule is not specified.

Figure 9 Updating script

Also prepare a script called when the Cancel button is pressed on the update screen.We will only return here.

return "redirect:/";
Figure 10 Cancel script

An example

When "Staff Update" is selected from the menu, an update screen of the staff linked to the logon account opens.Although this actually opens the search list screen, it is realized together with setting to transition to the update screen when the search result is one.

Figure 6 Update button provided in the menu (entity is the search screen)

When you press the Save button or Cancel button, you will return to the menu screen.

Figure 7 Example of pressing save button
Figure 8 Returning to the menu (updating is done)

When specifying the next screen transition destination with return, specify either the prefix forward or redirect.The difference between the two is as follows.

Figure 9 Forward and Redirect
forward redirect
Process flow Take the request (request) from the browser to the destination specified by forward. Once the process is returned to the browser, the browser continues to make a new request (request) to the redirect destination.
Proper use From the viewpoint of the browser, it is effective when it can be regarded as "one (series)" processing including the processing at the forward destination.Used for limited purposes, such as returning to the same screen. It is effective when you want to complete the process once and want to proceed to the next process.When transitioning to another screen, in principle use this.
Viewpoint of user (browser) Completion by one communication.Inside "Process 2" is also done, but the user does not notice it.Although the result is transmitted from process 2, it is interpreted that the user is "the result of requesting process 1". Communication occurs twice.Upon receiving the first result, a request to open the next screen occurs.
The value of p.request It can also be used in the destination specified by forward.Note that in the case of screens with different transition destinations, if the transition source value is inherited, it will cause malfunction. It can not be used on the destination specified by redirect.
Displayed on the screen "Registration completed successfully."Messages such as are held in p.request.If forward is used (after forwarding destination processing) a message will be displayed on the screen.If redirect is used, no message will be displayed.

Generated script file

Scripts that run are generated in the WEB-INF/script/model ID folder according to the following file naming convention.

操作アクション + モデル名 + "_" + ボタン操作でサーバに送られる文字列.js

This script indicates that the predetermined action process has endedlaterIt is called.Specific examples of file names are shown below.

A script file called after the juser model registration process


A script file called after the "display in print format" button of the customer model


Staff script file to be called after pressing "update" button of model


Staff script file called after pressing "cancel" button on model


It is not available on the list update screen

You can not write a script on the list update screen.This is because there is a danger of erroneous operation due to script behavior change due to the internal operation being complicated.

You can not specify the screen transition after outputting the form

You can not specify screen transition in the script of the form output (including batch output).(Even if you specify it, it will be ignored.)