How to do session management in liferay portlet? - json

One "Search" button is there in the JSP page. After taking all values for searching, the form is submitting.
In processAction(), I am getting all parameters. Using these parameters, in doView() I am consuming one API (JSON data). Creating one JSON object for input to the API and consuming it. Now I got the output JSON data and have passed it to the jsp using renderRequest.setAttribute("jsonString", json.toString());
Then showing search result using this jsonString.
Its working properly.
The issue is, its not creating multiple instances for multiple users. If one user done a search action, the same search result will show to each user if they refresh the page.
Why each user not having separate instances?
Now all users of this page can't do search action as they wish. If one user does, the same result will be shown to all. How can I fix it?
Why session of a particular user is sharing to all? Or What is the actual reason of this issue?

Related

Already Mobile Number Exists Validation Pattern html forms

Is there any pattern if already mobile number exists then the error message has to be shown in form validation.
If existing mobile numbers are present in the database, then you should make an API request to your backend using Ajax to avoid page reload. You should send the mobile number as a parameter in the request.
On the backend side, you need to check in the database that if this number already exists or not and based on your finding you should return appropriate responses.
On frontend, you need to check the response returned from the API and make appropriate decisions based on it but all the validation through the database should be done on the backend/server side.

How can I show the logged-in user in Power Apps Portal what their form submissions are?

The setup
I have a Power Apps Portal with the following pages:
Prequalification page. This has an entity form embedded inside it. The entity form is linked to the custom entity SupplierPrequal. When the user fills in and submits that form, they are redirected to the next page.
Submission List page. This has a List embedded inside it. The list should show each of the logged-in user's form submissions.
Submission Edit page. This has an entity form embedded inside it. The entity form is linked to the same custom entity SupplierPrequal and lets them attach files to a previous submission.
The problem I am facing
On the Submission List page, it shows submissions of users other than the logged in user. Here is a screenshot. You can see that the metadata for fields like [Created By] does not identify the user who submitted the form.
I was able to autopopulate the field [00_lkp_UserSubmittingForm] with the logged in username. Unfortunately this is not a unique identifier, and is also editable by the user.
I see these potential solutions, and would appreciate your advice
Change the metadata so that instead of recording the field [Created By] as "SYSTEM", it will record the logged-in user's unique identifier. Then change the view's filtering conditions, so [Created By] equals the current user.
Change the metadata so that a new field such as [00_lkp_UserSubmittingForm] will be autopopulated with the logged-in user's unique identifier. Then change the view's filtering conditions, so that new field equals the current user.
I suspect that both these approaches will require a lookup of the [External Identity] entity's field [Username]. They will probably involve configuring the entity form's tabs "Entity Reference" and "Entity Form Metadata" in Portal Management.
What I've researched
This link describes a similar problem, although the solution is for a CRM Portal, not a Power Apps Portal.
This link addresses the issue for a Canvas App, not a Portal App
This link apparently got it working, although I am still trying to understand what I need to configure.
If I understand your problem statement you wish to filter out Entity List, in your case Submission List page based on your logged in user.
As you might now, every user in Portals is a Contact record in CRM.
If I see your createdby, modifiedby and owner fields, I believe you have some background logic which runs under System (user) and does the required.
You have 2 way to solve your issue:
Either change your background logic to run under the context of running user. This will createdby, modifiedby and owner as running user and not System.
or you create a lookup field 00_lkp_UserSubmittingForm I say lookup and not plain text field. This lookup field will have relationship with contact. So you can autofill this field (lookup) with contact as user. In this way you get unique value in your 00_lkp_UserSubmittingForm field. Because it has unique guid for each user (in turn a contact)
Now with above any method what you get is current user (unique).
Then you can follow any of the below article to solve your issue.
List item
In Entity List itself, there is one option to add Filter Condition. Please check below:
Article Ref
Or follow this article

NgRx store for lists and detail data objects

I'm very new to NgRx and am trying to wrap my head around it. I understand the objective is to have a data store where different types of state reside. I'm trying to understand how to work with lists of data.
Scenario 1:
user first navigates to a list in which case an effect fires to retrieve list from backend/API. On success, the list is saved to the store and the UI component responds to the observable via | async and renders the list. The user clicks on an item to view the detail. We can either store the selected item's Id in the store then simply use a filter mechanism to retrieve the detail data from the list array in the store. Or, we can make another effect call to server for detail payload. I'm assuming the decision point here is if the list contains all of the data needed for the details page?
Scenario 2: assuming the list in the store contains all of the data required for the detail page and user clicking on an item in the list simply saves the selected item's id to the store then navigates to the detail page where the detail data is simply filtered from the list based on the selected item id in the store, what happens when the user refreshes the browser URL on the detail page? When this happens, the list is no longer in the store and neither is the selected item's id. However, the selected item's id is in the URL and route. How do you handle this scenario? Do you rebuild the list in order to retrieve the detail record?
Scenario 3: what's the best approach for handling a scenario where you have different subsets of data from the entire list. Perhaps you need to see a list of items that are 'pending' and another list of items that have been created this week, etc. It seems very inefficient to download all records into the store as the master list then simply filter out the ones needed for different views. I've read tutorials where you have the master list in store then simply have Ids in another part of the store that make up the different slices. This seems very heavy and a duplication of the database onto the client. What is the best approach for having filtered lists within a store?
Thanks for your help and insight.
Scenario 1: You're spot on!
Scenario 2: It depends.
you can store the data in localStorage for example
the list has to be fetched via the backend API
Scenario 3: keeping your state normalized is key here (you'll work with IDs). Also we don't have to load all entities at once, this can be done partially. The redux docs has a performance section that you can read.

How can I store some data only by a single request to the server and can use on several pages?

I have a dropdown list which is being used on several pages including the Home page. And I don't want to send data requests to the server for that drop-down list for all those pages. I want that drop-down list to be stored somewhere for all the pages at the time of loading the home page.
I could then use that several times on several pages without sending requests to the server each time. So that I could make my site a bit faster. Is there any way to do this?
You can make use of Singleton Service, which can be referred by all the components in your application. Give the server request to fetch data at the start of application, and store the result in the form of properties or attributes declared within the Singleton Service.
Once you have the data within service, you can simply refer that instead of giving server request every time.
Refer here for Singleton Service : How do I create a singleton service in Angular 2?

View Custom Field Passed with GetResponse Form

I'm passing document.referrer to GetResponse when a user submits the subscription form. The custom field has been added to the form at runtime as instructed in this document and the "Forward Data" option is on. Upon form submission, the parameters are posted correctly. Problem is, the value doesn't show up anywhere in the user's details in GetResponse, where it would be most useful. Where can I retrieve it?
I'm answering my own question s I've found the solution by trial and error. Not even the support people at GetResponse were able to help.
Apparently, only the custom fields that are actually added to the form designer get recorded. So if you use a custom form (not created with designer), on top of adding the <input> fields in your code, you'll have to create them first (dashboard > contacts > custom fields) and add they'll appear in the designer as well (on the right side).
After that, the passed values will show up in the contact's detail card. To retrieve the values for more than one contact in bulk, you'll have to export the contacts to csv, xml or xls, as support says there is no way to display additional columns on the contacts page. The alternative, if you are looking for a specific value, is to filter by the custom field on the contacts page (left side, 'add custom field').