-
Notifications
You must be signed in to change notification settings - Fork 71
Maintaining State
Traditional web development passes state between pages as parameters in link URLs or hidden form fields. In Seaside, all the links are generated for you. How do you maintain state?
After an action callback finishes, the same component instance gets redisplayed. You can use its instance variables to store user interface state. These instance variables can be initialized in the component’s #initialize
method. For example, you could add a simple ’counter’ instance variable, and increase it every time the user clicks a certain link:
initialize
super initialize.
counter := 0
renderContentOn: html
html heading: 'The counter is ', counter asString.
html anchor
callback: [ counter := counter + 1 ];
with: 'increase'
In the example above when you use the back button the state will not be reverted. If you want the state to be reverted you have to either tracking the state of the entire component
states
^ Array with: self
Or by only tracking the state of the "counter" instance variable with a WAValueHolder
initialize
super initialize.
counter := WAValueHolder with: 0
renderContentOn: html
html heading: 'The counter is ', counter value asString.
html anchor
callback: [ counter value: counter counter + 1 ];
with: 'increase'
states
^ Array with: counter
Changelogs
- (newer changelogs, see https://github.com/SeasideSt/Seaside/releases)
- 3.4.0
- 3.3.0
- 3.2.4
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.11
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 2.8
- 2.7
- Past Releases
Development
Documentation
- Configuration and Preferences
- Embedding Subcomponents
- Maintaining State
- Generating HTML
- CSS and Javascript
- Debugging Seaside Applications
- Links, Forms and Callbacks
- Development Tools
- Call and Answer
- Naming URLs
- Security Features
- Securing Seaside Applications
- Seaside-REST
- Add-On Libraries
- Persistence
- Gettext
- FileLibrary
- The Render Tree
- PDF Generation
- Long-Term Issues
- Ajaxification
- Web Components
- Big Issues
Sprints