This lesson is part of the Perspective Pages, Views, and Containers course. You can browse the rest of the lessons below.

LESSON LIST

Autoplay Off
Take topic challenge

Description

Similar to the Vision Module's Client Tags, Session Props allow you to store data within a Session. Components in a session are able to reference values stored in a Session Prop.

Video recorded using: Ignition 8.0

Transcript

(open in window)

[00:00] In this lesson we'll take a look at the Perspective Module's Session Props. Session Props are properties that are available throughout the entire session. Each instance of the session gets its own copy of the Session Props and they can contain unique values. So for our example I have two Views here. So I have a Docked View which has a Label in it, I have my Primary View which has a Text Field component. I would like to be able to type into the Text Field component and then move the value to the Label. There are a couple ways to approach this, you can use Message Handlers through scripting, but I could also just create my own custom Session Prop, and basically use that as a link between the two components. So let's actually look at the Session Props. If we come down to the little cog icon here and click on it, that takes us back to the root of the Perspective Module in our project, and that list of properties on the right-hand side, these would be our Session Props. So we have a bunch of built-in ones that are ready to go for you and these are available throughout the entire session. So for example, if you wanted to bind something on one of your Views to the geolocation properties, it's very easy to set up. You can additionally create your own down below under the custom section. So when you create a custom Session Prop, it's fundamentally very similar to the Vision Module's client tags. So to create a Session Prop, you can just click on the little Add Custom Properties area here, I'll create a value property, and we'll just give the key a name, I'll just type in myText. So let's go back to our components, and then we'll bind them to this property, and again we'll use this property as sort of a middle man or in between, between those two components. So back on my Docked View here, I'll select my Label component, we'll find the text property, click on the binding icon, and if we head over to the Property type binding, don't have to worry about typing in here, we can just use the little Property Browser button. And we won't worry about finding anything inside of our View, again these Session Props live in the session, they're available anywhere. So we'd want to go over to the session area. We'll go down to the custom folder, we'll grab myText, and we'll hit OK. You can see that it's kicking in already, it's using that default value that was just there when we created our property. I'll hit OK here, we'll switch over to the primary View, and we'll basically do the same thing. I'll select my text field, go to the binding icon, do a property binding, and again we'll go ahead and just grab the exact same property. So session, custom, myText, and hit OK. Now in this case, I want my users to be able to type into the Text Field. So if they do that, then I want to write back to the custom prop, so in this case we definitely want the binding to be bidirectional. We'll hit OK here, and let's try this out in the Designer before we go to our session. I'll put it into Preview mode, and if I type something over here, I can head back to the root of the Perspective Module, we can see that the value of myText has changed, and of course if we go back to my Docked View, so the last part in this little chain here, we can see that the text property on the label has updated. So that's all fine and dandy but let's save our project. I'll save again. And if I go back to the root of our Perspective Module here, you can see that I did create a page initially which has my Docked View and my Primary View. We'll go ahead and just launch this real quick, and when my browser comes up here you can see our two components, change the text in here, and we see that it worked. So hopefully that gives you a good idea as to what the Session Prop is. It's basically a way for you to take one value, put it into a spot that's available throughout the entire session, and then your other components in your other Views can bind to it or use it in some useful way.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.

close

Share this video