Documentation

Trace:

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
jvx:client:gui:temporary_values [2019/08/26 11:16]
admin
jvx:client:gui:temporary_values [2019/08/26 11:42] (current)
admin
Line 3: Line 3:
  
 Sometimes it's important to store/cache temporary information. It's no problem to create or use a variable to save such information. This is also the recommended solution because it makes the code readable and references can be found. But sometimes it's good to have an alternative to clean code because sometimes you want to add information to existing objects, quick and easy. Sometimes it's important to store/cache temporary information. It's no problem to create or use a variable to save such information. This is also the recommended solution because it makes the code readable and references can be found. But sometimes it's good to have an alternative to clean code because sometimes you want to add information to existing objects, quick and easy.
 +
 +=== Instance values ===
  
 As example, you could open a work-screen and add additional metadata like readonly or allowed users. To solve this problem, you could save the screen in a HashMap with metadata as values. This information should be saved in the Application because the screen has access to the application. This makes things a little bit complicated. As example, you could open a work-screen and add additional metadata like readonly or allowed users. To solve this problem, you could save the screen in a HashMap with metadata as values. This information should be saved in the Application because the screen has access to the application. This makes things a little bit complicated.
Line 34: Line 36:
  
 <code java> <code java>
 +@Override
 protected void afterLogin() protected void afterLogin()
 { {
Line 41: Line 44:
 } }
 </​code>​ </​code>​
-We save the **"​application mode"​** in the launcher and this information is available in every screen or any other class which has access to the launcher. ​+We save the **"​application mode"​** in the launcher and this information is available in every screen or any other class which has access to the launcher. It's not possible to add variables to the launcher or to change the class directly, so it's a good alternative to use custom objects to add metadata and to avoid HashMap for simple caching. 
 + 
 +==== Global values ==== 
 + 
 +We have another alternative for above instance values. It's also possible to use our [[jvx:​common:​util:​classes#​the_object_cache|ObjectCache]],​ e.g. 
 + 
 +<code java> 
 +//available for 1 minute 
 +ObjectCache.put(IConstants.APPMODE,​ AppMode.AUTHENTICATED,​ 60000); 
 +</​code>​ 
 +The ObjectCache is a static cache and can be used to use values without application context. It's also possible to use an **ObjectCacheInstance** which isn't static.
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information