Wiki

Clone wiki

XALPI / LovValues

Dealing with Lov Values

For each List of Values in a .xeolov File a class representing the List will be created, and an instance for each pair value/label is added as a public static final field to allow easy referencing:

Consider the following Lov definition (representing time between ocurrences):

#!xml
<Lov retainValues="No" name="timeBetween">
  <description>Time between occurences</description>
    <details>
    <item>
      <value>1</value>
      <label>10 minutes</label>
         </item>
     <item>
       <value>2</value>
       <label>15 minutes</label>
      </item>
    </details>
    </Lov>

This will will originate the following class:

#!java

public class TimeBetweenLov implements LovPair {

    private final static String NAME_LOV = "timeBetween";
    private String xeolov_label;
    private String xeolov_value;

    public static final TimeBetweenLov _10_MINUTES = new TimeBetweenLov ("10 MINUTES","1");
    public static final TimeBetweenLov _15_MINUTES = new TimeBetweenLov ("15 MINUTES","2");

        // (...)
        //Details omitted for brevity
        // (...)

    protected TimeBetweenLov(String label, String value)
    {
        this.xeolov_label = label;
        this.xeolov_value = value;
    }

    public static TimeBetweenLov valueOf(String value, EboContext ctx){
       //Implementation omitted for brevity 
    }

    public String getLabel() {
        return xeolov_label;
    }

    public String getValue() {
        return xeolov_value;
    }

If you have a given Model that has an attribute that references the timeBetween Lov, the interface for the .xeomodel will be like the following: (assume the attribute name as "interval")

#!java

public interface Example {
     public TimeBetweenLov getInterval();
     public void setInterval(TimeBetweenLov newInterval);
}
The previous interface means that you can do the following:

#!java

Example example = ExampleManager.create();
example.setInterval(TimeBetweenLov._10_MINUTES);
TimeBetweenLov interval = example.getInterval();

System.out.println(interval.getLabel()); //Prints "10 minutes"
System.out.println(interval.getValue()); //Prints "1"

Updated