Page 1 of 1

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

Posted: Thu Jul 16, 2015 9:10 am
by Manish Kumar Singh

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


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

Posted: Sun Jul 19, 2015 5:18 am
by Alena Prykhodko

Hello Manish,

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


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

Posted: Mon Jul 20, 2015 4:55 am
by Manish Kumar Singh

Hi Alena,

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


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

Posted: Thu Jul 23, 2015 9:48 am
by Pavel Zarudniy

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


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

Posted: Thu Jul 23, 2015 10:49 am
by Manish Kumar Singh

Hi Pavel,

Can you please elaborate with an example ?


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

Posted: Thu Jul 23, 2015 7:40 pm
by Jack Bua

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.