Manish Kumar Singh
Posts: 0
Joined: Fri May 22, 2015 6:22 am

Confused between Services and Values................!

Hi,

Kindly read carefully

I have two pages, "Pg1" and "Pg2".
When "Pg1" load, It calls a REST service "R1"
"R1" have multiple values, by default first value "Val1" will be selected
Based on "Val1" another REST service "R2" will invoke.

Now, Select "Val4" on "Pg1"
Based on "Val4" another REST service "R2" will invoke.
Now, I clicks on any value (which is the result of "R2") "Pg2" loads.

On the click of back button of "Pg2", It again loads "Pg1"
When "Pg1" load, It calls the REST service "R1"
"R1" have multiple values, by default first value "Val1" will be selected !

What I want ??????????

On the click of back button of "Pg2", It again loads "Pg1"
When "Pg1" load, It calls the REST service "R1"
"R1" have multiple values, Here I do not want by default value.
I want that, the previously selected value will be selected and their respective service will be called.

Please Help

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Confused between Services and Values................!

Hello Manish,

One thing to clarify, after you click backbutton on Pg2 you want to have previous service R1 result to be shown?

Manish Kumar Singh
Posts: 0
Joined: Fri May 22, 2015 6:22 am

Confused between Services and Values................!

Hi Alena,

On click of backbutton on Pg2, It redirects to Pg1 and Invoke R1 with previously selected value.

Pavel Zarudniy
Posts: 0
Joined: Mon Jul 06, 2015 8:56 am

Confused between Services and Values................!

Hi Manish,
You can store your value to local Storage(for example) every time when new value selected. Then restore it after service call successful complete

Manish Kumar Singh
Posts: 0
Joined: Fri May 22, 2015 6:22 am

Confused between Services and Values................!

Hi Pavel,

Can you please elaborate with an example ?

Jack Bua
Posts: 0
Joined: Sun Jun 28, 2015 10:16 pm

Confused between Services and Values................!

I am doing something similar to this. In my app a page pulls up a contact who may or may not have an account and location values on their record, but if they do, I want those values to show, but if not, I want the default value of the select menu to show. If that is close to what you want then here is how:

Assuming that you have a select component that is being populated by the service and your default selection has only a label and not an actual value like in the picture below

Image

Then you should try adding a mapping to the service's success event that takes from your storage and places into the component.

Image

In this example, TEST_selected_value is a simple string type storage variable with two child values, "name" and "number", just like the values in the collection that the service is from.
Note: you will have to setup a modal for this variable in order to make it like this

The JS code on the mapping from the variable to the select menu is:

var def;
if (value){
var def = value;
} else {
var def = "Select One...";
}
return def;

I'm new to JS so that can probably be done better, but it works.
Finally, on the value change event of the select component, map its selected value back to the storage variable.

Image

This is a variation from what I have going on in my app, but a little changing to fit your needs should get it how you want it.

Return to “Issues”