Initializing help system before first use

View Properties

It is often necessary to track some state or user input specifically for the view.

This will not be represented in the model and only exists for the lifetime of the view. For example, you may need to track the value from a form input so that you can respond to changes or you may have a number of tabs within the view and you need to track the current tab selected.

At a basic level you would use jQuery to listen for changes and to capture the current value:

HTML
<select id="country">
   <option value="uk">United Kingdom</option>
   <option value="fr">France</option>
</select>
JavaScript
$('#country').on('change', function(event) {
   var selectedCountry = $(event.target).val();
});
If you want other parts of your view to respond to changes to the selected country you can create a view property. View properties are simply key-value pairs that are stored against the view object.
$('#country').on('change', function(event) {
   view.setViewProperty('selectedCountry', 
       $(event.target).val());
});
You can create or update them at any time while the view is running. You can get the current value for a view property from your code, however the really useful thing about them is that they work with scenario observers. You can configure scenario observers to subscribe to view properties and they will update whenever the specified view properties change.
// Subscribe to view properties
view.withFirstScenario()
   .withViewProperties('selectedCountry')
   .withEntities('Population')
   .notify(function(scenario, viewProperties) {
       var populations = scenario.getArray('Population');
       var country = viewProperties.get('selectedCountry');
       // This will get the population value for the 
       // selected country
       var population = populations.getValue([country]);
   })
   .start();

The notify callback will be passed a second argument which is an accessor object for the observed view properties, known as the MaskedViewProperties. This will throw an error if you try to access any view properties not previously declared for that scenario observer.

© 2001-2020 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.