Support > Repository > Business logic > Screen transition
ja | en

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: /" + screen type of transition destination + model ID + action string
Return "forward: /" + screen type of transition destination + model ID + action string

The prefix "redirect: /" or "forward: /" is required.The difference between them is "Redirect and ForwardI will explain it in the section.Please use "redirect: /" as the standard.The screen type isSCREENTYPE functionIt conforms to the specification of.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:/insertCustomer.do?action_New=New";
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:/insertCustomer.do?action_New=New&item1="+customer.getItem1();

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

TOINT(REQUEST())

Details are "Screen transition (1) Transit from detail screen to registration screen> Handling model reference itemsPlease refer to.

Give multiple parameters

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

return "redirect:/insertCustomer.do?action_New=New&item1="+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:/insertCustomer.do?action_New=New&customername="+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".

script

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:/mainMenu.do";
}

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:/mainMenu.do";
Figure 10 Cancel script

Example of operation

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.

Operation action + Model name + "_" + A string sent to the server by button operation .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

WEB-INF/script/juser/InsertJuser_Send.js

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

WEB-INF/script/customer/ShowCustomer_JFCPrintScreen.js
WEB-INF/script/customer/ShowListCustomer_JFCPrintScreen.js

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

WEB-INF/script/staff/UpdateStaff_Send.js

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

WEB-INF/script/staff/UpdateStaff_Cancel.js

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.)