Revision history [back]

click to hide/show revision 1
initial version

asked 2021-01-20 06:14:11 +0800

RomanZK gravatar image RomanZK

How to Use VariableResolver with a ListBox

How can I use a variable resolver with a ListBox.

I have tried the following approaches:

<listbox mold="select" width="100px" selecteditem="@bind(each.attributes.accountCategory.value)"> <listitem label="${each.value}" foreach="${country}" value="${each.code}"/> </listbox>

The Lov display but the value in field accountCategory does not display.

OR

<listbox model="${country}" mold="select" width="200px" selecteditem="@bind(each.attributes.accountCategory.value)"> <template name="model" var="lov"> <listitem label="${lov.value}" value="${lov.code}"/> </template> </listbox>

The above code snippet throws errors.


Points to note:
  1. My data source is a class that has a map of attributes.

  2. I have implemented a variable resolver that returns the list of values as follows:

@Override public Object resolveVariable(String name) throws XelException {

 ....  // some code here


     List<GenericLOV> listOfValues = new ArrayList<GenericLOV>();


  listOfValues.add(new GenericLOV(new Short("566"), "Nigeria"));
  listOfValues.add(new GenericLOV(new Short("891"), "Yugoslavia"));
  listOfValues.add(new GenericLOV(new Short("894"), "Zambia"));

  ListModelList<GenericLOV> listModelLov = new ListModelList<GenericLOV>();

  listModelLov.addAll(listOfValues);


  return listModelLov;
}
  1. The GenericLov is a class that has two fields

    private Short code; private String value;

    with getters and setters

How to Use VariableResolver with a ListBox

How can I use a variable resolver with a ListBox.

I have tried the following approaches:

<?variable-resolver class="com.LovResolver"?>

<listbox  mold="select" width="100px" selecteditem="@bind(each.attributes.accountCategory.value)">
                               width="100px"
          selectedItem="@bind(each.attributes.accountCategory.value)">
     <listitem label="${each.value}" foreach="${country}" forEach="${country}" value="${each.code}"/>
                                </listbox>  

</listbox>

The Lov display but the value in field accountCategory does not display.

OR

 <listbox model="${country}" mold="select" width="200px" selecteditem="@bind(each.attributes.accountCategory.value)">
                                 width="200px"
          selectedItem="@bind(each.attributes.accountCategory.value)">
    <template name="model" var="lov">
         <listitem label="${lov.value}" value="${lov.code}"/>
                                 value="${lov.code}" />
    </template>
                                </listbox>                                  

</listbox>

The above code snippet throws errors. errors.

Points to note:

  1. note:

    1) My data source is a class that has a a map of attributes.

  2. 2) I have implemented a variable variable resolver that returns returns the list of of values as follows:

@Override
 public Object resolveVariable(String name) throws XelException 
    {

{

     ....  // some code here


      List<GenericLOV> listOfValues = new ArrayList<GenericLOV>();


   listOfValues.add(new GenericLOV(new Short("566"), "Nigeria"));
   listOfValues.add(new GenericLOV(new Short("891"), "Yugoslavia"));
   listOfValues.add(new GenericLOV(new Short("894"), "Zambia"));

   ListModelList<GenericLOV> listModelLov = new ListModelList<GenericLOV>();

   listModelLov.addAll(listOfValues);


   return listModelLov;
}
  1. 3) The GenericLov is a class that has two fields

    private Short code;
    private String value;

    value; with getters and setters

setters
Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More