Reactive Web Application With respective Traditional Web Applications

Hi All,

I thought of migrating my traditional web application to reactive web application so now I have few doubts regarding reactive web application as there is no preparation actions topic in reactive how to active the below scenario:

I was using a tab content widget and each tab contains data of the particular status (Draft, Approved, Rejected and submitted) from a table data. 

so for this, I was using preparation action where I was calling aggregate widget of the table data(once) and then I was calling the filter function for each status:

But this is not possible in Reactive Web Application as it does not contains preparation and we need to get data from the aggregate widget directly.

I know we can achieve this by using more than one aggregate widgets each for status, Apart from this solution do we have any other?

Thanks in advance


Hi

I think you can use the OnAfterFetch of the aggregate and filter the result there. 

Cheers 

Hello Gandeev,


From my understanding as well, I believe you can move that action to OnAfterFetch of GetMenuItems.

Although I am somehow confused on your process flow.

Why is there a condition there? When does that evaluate to false?


- Emman

John Emmanuel Si wrote:

Hello Gandeev,


From my understanding as well, I believe you can move that action to OnAfterFetch of GetMenuItems.

Although I am somehow confused on your process flow.

Why is there a condition there? When does that evaluate to false?


- Emman

Hi

that condition was to check the user role normal users should not see all status and only admin can 


Hi Gandeev,

In this case, a simple filter in the query itself would work.

E.g.

CheckManagerRole() or (Entity.SomeField = 1 or Entity.SomeField = 2)

In this case, a manager would make the first part TRUE to all rows, while someone that is not a manager would return only rows with SomeField set to 1 or 2.

This is just an example. You can make more complex filters, of course. This way you can use a single aggregate/SQL without the extra overhead of logic to filter.

Cheers

Eduardo Jauch wrote:

Hi Gandeev,

In this case, a simple filter in the query itself would work.

E.g.

CheckManagerRole() or (Entity.SomeField = 1 or Entity.SomeField = 2)

In this case, a manager would make the first part TRUE to all rows, while someone that is not a manager would return only rows with SomeField set to 1 or 2.

This is just an example. You can make more complex filters, of course. This way you can use a single aggregate/SQL without the extra overhead of logic to filter.

Cheers

Sorry I did not understand :( 

In which query ??

In my example i gave you only two status but there are way more status are there and both users and admins should get data related to those status and users should get only those records which were created by them in respective tabs and for admins irrespective of who created,he should be able to see those in respective tabs (Status)

I think solution which you provide initially might work (onafterfetch)

Hi, 

You have an aggregate to fetch data. Depending on the tyoe of user, you are filtering this list. 

There are many inconveniences with this approach. 

And you can setup the filters in the aggregate in a way it brings the data already filtered correctly depending on the user, even if they are complex. 

Cheers 


Eduardo Jauch wrote:

Hi, 

You have an aggregate to fetch data. Depending on the tyoe of user, you are filtering this list. 

There are many inconveniences with this approach. 

And you can setup the filters in the aggregate in a way it brings the data already filtered correctly depending on the user, even if they are complex. 

Cheers 


So if I understand correctly you want me to get the user role before fetching data through aggregate and by using the user role I should fetch only relevant data instead of filtering it after fetching??

if that’s is correct then yeah I see the point in that but what about data? As it’s divided into four stages (approved,Rejected,New,InWork).

if I click on “in work “ tab then I should get only related to inwork similar with other tabs.

As I m using content tabs everything is in single screen,Means I must use onfetchafter right ?? 


Ah... I see your point. 

This way doing everything in a single operation will not work. And probably not even the OnAfterFetch. 

I would do differently. I would have 4 different aggregates, one for each tab/stage, with the option to load on demand for the ones that are not immediately visible, and than load the others when showing the tab. 

This way you fetch data only when required, but don't have to filter sthis data as you are fetching only the data required.

Cheers 

Hello Gandeev,


I think me and Eduardo answered your question with consideration that your operation is small, and you want an alternative to a separated aggregate. Even so, with your current explanation with an increase of status in mind, then I would also recommend to do separate aggregate instead. Please do note that separate aggregate is the best practice for fetching data for reactive web apps, since we promote on-demand fetching with lowest load possible to each request to enhance user experience.


Hope this helps!

- Emman

Hi Gandeev,

I am showing you how to create separate aggregate in reactive web apps. It is quite similar to Mobile Apps. Please check the Screens I have attached.

Thank you,

Sudip

Hello Everyone,


Thanks for your inputs :)

But my question already stated that "I know we can achieve this by using more than one aggregate widgets each for status, Apart from this solution do we have any other?"

I think there is no other way other than using individual Aggregrate (But i see one issue here as in my example I only mentioned 4 cases, If in case I have more 10 cases then?) 

Hello Gandeev,


Yes, and that is why we responded that the alternative is to do it using the OnAfterFetch event of your singular aggregate. :)

If you have 10 cases, then you will simply have more if statements inside the OnAfterFetch, just like how it would've looked like in Preparation. :)


Hope this help!

- Emman

Solution

Hello Gandeev, 

I see a few possibilities here. 

1. Use the OnAfterFetch to filter the aggregate. Problem: Every time you change the tab view, you will have to fetch data again (hit the server), or manually call the OnAfterFetch action (better).

2. Filter the aggregate. This will require some extra logic. Problem: Every time you need different data, you will have to refresh the aggregate. Advantage: You fetch only the required data at start, not all of it. 

3. You donexactly as you're doing, but using a Data Action. Problem: younhave to fetch all data. 

So, I would avoid any method that requires to fetch all data when not all data will be immediately visible. 

Cheers. 


Solution

Eduardo Jauch wrote:

Hello Gandeev, 

I see a few possibilities here. 

1. Use the OnAfterFetch to filter the aggregate. Problem: Every time you change the tab view, you will have to fetch data again (hit the server), or manually call the OnAfterFetch action (better).

2. Filter the aggregate. This will require some extra logic. Problem: Every time you need different data, you will have to refresh the aggregate. Advantage: You fetch only the required data at start, not all of it. 

3. You donexactly as you're doing, but using a Data Action. Problem: younhave to fetch all data. 

So, I would avoid any method that requires to fetch all data when not all data will be immediately visible. 

Cheers. 



Hi Eduardo 

Thank you for your valuable input :)

Also, Eduardo’s idea about using the rolecheck inside the aggregate is pretty good, as it is more secure than making code on the client side that depends on roles.