Support > Repository > Repetition > [Application] Managing the read status of data with a repeating container
ja | en

Here is an example of keeping user's browsing record repeatedly in a container. You can search in unread/read status. R7.10

Here is an example of preparing data items that can handle read information in the "customer" model.Immediately after registration, the "browsing record" is empty.

Fig. 1 Data immediately after registration

Log on as "User 1"

Log on with the account "User 1" prepared in advance.An item called "unread state" is prepared as a search condition.

Figure 2 Search can be done in unread state

If the unread state is "read", no data is found.

Figure 3 There is no data read

Conversely, if you set the unread state to "unread", you will find the data.

Figure 4 Unread data exists

Open the data detail screen.With this timing, the read information is registered in the browsing record (repeating container).

Figure 5 Opening the detail screen
To be precise, immediately after drawing detailed display data on the screen, read information is registered.As a result, the read information is not yet displayed on the screen in Figure 5.

I will search again.Now you can see that there is no "unread" data.

Figure 6 There is no unread data

Conversely, "read" data will be found.

Fig. 7 Existing data exists

I will check the data again.You can see that the account name and browsing date time are added to the browsing record.

Fig. 8 Browsing record has been updated

Log on as "User 2"

Log on with another account "User 2".You can see that the same data is "unread".

Figure 9 When logged on with user 2

View data with multiple users

Each time more than one account views data, a browsing record is added.

Figure 10 Example of browsing record added

The setting points are two.One should be able to search by "unread state".The other is to prepare a repeating container called "browsing record".

Figure 11 Definition of customer model

The browsing record is as follows.

item name Item ID Type
Viewing record accessrec Repeat container
No accessrec/rid Repeating Container ID
Viewer accessrec/ruserid String
Browsing date time accessrec/raccessdatetime Date Time

Unread state

Use the option model "unread state master" provided by the system.This model does not create tables in the database.

Figure 12 Using unread state master as search condition

In "Search Control> Read/Unread Management", specify the item that stores the viewer in the repeating container as the item to be used for searching in the read/unread state.

Figure 13 Setting items to be used for searching for read/unread status

Since this item is used only for searching, DB is not saved, except for the search screen, it is a hidden item.Specifically, please make the following settings.

Learn more> Database details> Save values ​​in the database as "invalid".

Figure 14 Saving values ​​in the database, set as "invalid"

Input control> common> hidden/read only, let's be "hidden in full screen".

Figure 15 When input, make it hidden in full screen

Input control> model reference> prepare unselected, is set to "invalid".

Figure 16 Do not prepare unselected

Output control> Detailed screen> Common> Hidden item is set to "valid".

Fig. 17 Hidden items when outputting

Repeat container viewing record

The browsing record is read-only.

Fig. 18 Make it read only

Set initial display number to 0.All add/insert/delete/move buttons are invalid.

Fig. 19 Invalidate buttons

script

Set the script of "Screen> Controller".Timing is when the detail screen is displayed.

Figure 20 Script settings

The script should be as follows.Please properly substitute the name of the model and item.

var AccessRecordClass = Java.type("jp.jasminesoft.wagby.model.customer.Accessrec");
/*stdout.println(customer);*/
var userid = p.user.username;
/*stdout.println("私は"+userid);*/
var array = customer.accessrec;
var checked = false;
for (var i=0;i<array.length;i++) {
    /*stdout.println(array[i].ruserid+","+array[i].raccessdatetime);*/
    if (array[i].ruserid == userid) {
        checked = true;
        break;
    }
}
if (checked == false) {
    var customerService = p.appctx.getBean("CustomerEntityService");
    var n_customer = customerService.findById(customer.customerid, true);/*再取得*/
    var accessrecord = new AccessRecordClass();
    accessrecord.ruserid = userid;
    accessrecord.raccessdatetime = ExcelFunction.NOW();
    n_customer.addAccessrec(accessrecord);
    customerService.update(n_customer);
    /*stdout.println(n_customer);*/
}
  • In the first half, I check each container repeatedly and check if my own (p.user.username) has already been read.
  • If it is unread, we will retrieve the object from the service object again, add 1 iteration container, and update it.

When directly specifying the URL etc. and making transition to the detail screen, please attach the parameter action_Show = Show as the link destination as follows.

http://localhost:8921/wagby/showModel1.do?pkey=1000&action_Show=Show

This is because event names are required to call controller scripts.(For the event name, the character string after action_ is used.)

  • This function is effective in the normal search screen, the search window in the subwindow, and the form screen.
  • It does not work on the download screen.
  • In this example we used a repeating container as an item to store the ID of the user you visited, but you can use repeating items or checkboxes besides that.