List Record - Current Row Number - How link click on star rating changes value

Going through the "Developing Web Apps" training course.

Exercise in context for my question here: "Web Blocks Exercise"

Scenario for my question: The user star rating input is gotten by click on a star among the listed 5 stars in the list records widget. Each star is embedded in link widget. (done per exercise instructions).

Upon clicking a star for rating, a screen action is called which contains an event which has an integer input parameter that is to contain the numeric value of the star clicked.

The value of that input parameter in that event is set to - "ListRecord.List.CurrentRowNumber + 1"

Question: How does the respective star click (link click) result in changing the value of the CurrentRowNumber property of that ListRecord?

I see how every other object/function in the widget is linked, but can't see how this CurrentRowNumber property value is changed upon clicking the star.

Please help.

mvp_badge
MVP
Solution

Hi David,


Yes, that's an excellent recap of what happens with the CurrentRowNumber and what happens in this exercise.


Kind Regards,
João

mvp_badge
MVP

Hi,


You have a list of 5 records (5 stars). The current row number represents the order / place of each record in a given list. When you click the first record of the list, then the current row number of that record is 0 (since it is zero-based). On the second star it will be 1 and so on, so forth.


The current row number, given its definition i explained above, is a concept that only applies to a list.


Kind regards,

João

Yes I know that Joao.

My question was: How does the link-click result in updating the current row number? i.e. I see no connection from a star-link-click and to to the list records widget and it's row number property.

The star-link-click result in triggering the screen action, which then triggers and event, and in that event the CurrentRowNumber property is used.

But I cannot see how the star-link-click results in updating the CurrentRowNumber property of the List Records widgets, which was the basis of my question.

Will you please explain this if you can?

mvp_badge
MVP

Hi David,


I am not sure if I understand your question.

The current row number as I mentioned is the position of the list, so it does not get updated. Each star represents a record in the list and thus each one, has a given CurrentRownNumber from 0 to 4.

So when the user clicks a star (let's say the third star) , the following will happen:

  1. The StarClickedEvent event of StarDisplay block will be triggered with CurrentRowNumber (2) + 1 (which is 3);
  2. The handler OnRatingEvent in the MovieDetail screen, where StarDisplayBlock is being used, will be triggered and its logic will run. This logic will: a) update the star detail in the database to 3; b) refresh the query and c) AJAX refresh the UserRatingContainer, where the StarDisplayBlock will run. This will cause the block to rerun again, fetching now 3 stars filled from the database.


Kind Regards,
João


Thank you Joao, i see more clarity, but not specifically the answer I was seeking.

Notwithstanding, thanks to your input I can now phrase my question my specifically.

What I seek is an observable connection between every object in the logic.

  1. I can see that a link widget encapsulates each star in the list records widget.
  2. I can then see the the link widget triggers a screen action

But what I cant see is: how a link click result in updating the CurrentRowNumber property of the List Records widget?

I can only see that each star is linked to the screen action, that’s all. But how does the CurrentRowNumber property get updated to the position of the star in the List Records?

The CurrentRowNumber property of the List Records widget must be dynamic, how is it updated by a link click on the star?

Is the RowNumber automatically added to each star’s link in a url parameter, and from which the CurrentRowNumber this is generated through some built in function within the widget?

** I hope you can see that I am trying to objectively see the connection between every used object in the logic being built.

Thank you in advance for your patient help.

mvp_badge
MVP

Hi David,


When using a List, ListRecords, Table or TableRecords widget, you only implement the contents of a row.


Nonetheless, what you will see on the screen will have as many rows as the numbers on the list (you can see the preview, shows three lines to hint the developer this effect).

The values for each line take into account the Current record, meaning it will present the first value from the list on the first row of the table, and so on, so forth. The CurrentRowNumber is nothing more than the position of that record in the table.

If we adapt this to your example, you are coding only one star in a list of 5 rows and you are using the position of the list (CurrentRowNumber) as a clever mechanism to attribute the value to the star (if it is the first star in the list , then it represents the rating of 1, if it is second, then it represents a rating of 2, and so on).

The CurrentRowNumber is a property managed automatically by the platform like I mentioned above, that's why it automatically has a different value in each row.


Kind Regards,
João


Hi David,


the short answer is : the platform automatically takes care of that : if an event happens in a given row of a table or list element, the code behind will have the CurrentRowNumber available to work with.

As to how it is done, if you are for example working with a traditional application, just inspect your page in chrome, you will see that each link element has his own id, and that this id is also passed back in the postback to the server, so the outsystems software knows how to populate the CurrentRowNumber for you.

Hope this helps you with understanding the missing link between what you do in service studio, and what happens in the application.

Dorine

Thank you Joao & Dorine & Joao. Digesting what you both answered this far and paraphrased below.. pls tell me now if what I see is correct.

  1. As Joao said, in OS we only implement the logic for one row, and the platform automatically builds the same logic for the rest of the rows.

    In the case of this exercise, OS automatically builds links for each following star in the list records.

  2. As Dorine said, each link has an ID.

    Therefore in the case of this exercise, I assume that when the platform builds the links for the rest of the rows (rest of the stars in this case), each following link for each following star in the list gets its own unique id.

  3. When any star in the list is clicked, the unique id of that link is also part of the postback, from which the platform then automatically generates the values in the various properties for that row; CurrentRowNumber being one of those.

    In the case of this exercise, lets say if the the 4th star was clicked, then the link of that star together with its unique id is sent to server, from which the platform automatically generates the value in the CurrentRowNumber property of the list records widget.

  4. The reason why we need to add "+1" to the CurrentRowNumber (for the value in the input parameter of the event) is because row numbers in the list records widget are numbered from 0 not 1, and star rating starts from 1 not 0.
mvp_badge
MVP
Solution

Hi David,


Yes, that's an excellent recap of what happens with the CurrentRowNumber and what happens in this exercise.


Kind Regards,
João

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.