Documentation

Trace: Temporary Values

(jvx:client:gui)

Temporary Values

This is an old revision of the document!


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.

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.

To make everything easier, every UI resource (e.g. a component) has the methods:

public Object pubObject(String pName, Object pValue);
public Object getObject(String pName);
public Collection<String> getObjectNames();
 
public ResourceHandler eventResourceChanged();
public ResourceHandler eventResourceChanged(String pObjectName);

So it's super easy to add temporary information to any UI resource. We recommend to use constants as object names, to find references easily. If you use hardcoded strings, it will be hard to find the usage in your whole application.

Here's a short example:

public void doOpenStatus()
{
    IWorkScreen wosc = getApplication().openWorkScreen(StatusWorkScreenc.class.getName());
 
    ((WorkScreen)wosc).putObject(IConstants.STATE, ScreenState.New);
}

We save a simple “state” for the screen, directly in the screen instance.

It's also possible to use the launcher or application, e.g.

protected void afterLogin()
{
    super.afterLogin();
 
    getLauncher().putObject(IConstants.APPMODE, AppMode.AUTHENTICATED);
}

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.

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information