Like what you see? Have a play with our trial version.

Error rendering macro 'rw-search'

null

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

This section provides information in setting up a basic UI for the UIP API. 

 

Setting up a basic UI with UIP is exceedingly simple and requires very little code.

In short, a plugin may define its UI as a list of Parameter objects which define how to display and persist the required user input data.


The three below methods plus some understanding of the Parameter class and ViewOptions are all that is required to create a simple static UI.


protected void setupParameters()

Plugins should implement this method to provide the API with the UI definitions required for configuration. Generally, the plugin will create Parameter objects and add them by calling addParameter(Parameter).


Example:

 

@Override
protected void setupParameters() {
    Parameter p = new Parameter();
    ... 

    addParameter(p);
}

 

 

protected final void addParameter(Parameter p)

Plugins should use this method to notify the API of any new parameters it creates. Note that new parameters will not be persisted if they are added outside of the setupParameters method. See above example.


public final Object getParameterValue(String key)

This method returns the current value for the parameter with unique key ‘key’.

Example:

Object paramVal = getParameterValue("SOME_KEY");
if (paramVal != null && paramVal.equals("INTERESTING_CONFIG")) {
   // Do something interesting
   ...
}


public void setParameterValue(String key, Object value)

This method sets the stored value for a parameter key.


Example:

 

Object paramVal = getParameterValue("SOME_KEY");
if (shouldChangeThisValue(paramVal)) {
   Object newValue = new Object();
   setParameterValue("SOME_KEY", newValue);
}

 


public void clearParameterValue(String key)

Equivalent to calling setParameterValue(key, null); except that this method also removes the parameter key from the parameter values map.

 

Example:

Object paramVal = getParameterValue("SOME_KEY");
if (shouldRemoveThisValue(paramVal)) {
   clearParameterValue("SOME_KEY");
}

 

 

public void getParameter(String key)

Retrieves a previously set up parameter with the given key. Returns null if no parameter with this key exists.


Example:

 

if (needToUpdateParameter()) {
   Parameter p = getParameter("SOME_KEY");
   ... 
}

 




 Previous topic:

Next topic:





  • No labels