>>>>> On Mon, 10 Mar 2003 16:36:19 +0200, Theunis de Jongh said:

Theunis> Let's say I have 2 jelly properties : "component1.dir" and
Theunis> "component2.dir".

Theunis> Now I also have the following jelly property :
Theunis>          <j:set var="components" value="component1,
Theunis>          component2" />

Theunis> These properties are defined in an "init" goal, which is
Theunis> prerequisite to several "subgoals:". The aim is to have
Theunis> several types of properties for each type of component
Theunis> e.g. component1.name, component1.propertyfile etc.

Theunis> In a subgoal, the "components" property is tokenized using
Theunis> jelly, yielding "component1" and "component2" as tokens.

Theunis> The intention is to use it as follows :

Theunis> <j:set var="dirname" value="${token}.dir}" />

Theunis> The value for "dirname" is thus "component1.dir" and
Theunis> "component2.dir" on successive iterations.

Not quite sure if I understand what your problem is, but once you put
something in the Jelly context, you have access to it in your other
goals.  So, taking the example you presented above, you could just do
something like this (no need to tokenize, just use a real list):

  <goal name="init">

    <!-- Create a property object -->
    <j:new var="component1" className="java.util.Properties"/>
    <j:set var="dummy" value="${component1.setProperty('dir', 'directory1')}"/>
    <j:set var="dummy" value="${component1.setProperty('name', 'name1')}"/>

    <!-- Create another property object -->
    <j:new var="component2" className="java.util.Properties"/>    
    <j:set var="dummy" value="${component2.setProperty('dir', 'directory2')}"/>
    <j:set var="dummy" value="${component2.setProperty('name', 'name2')}"/>    

    <!-- Save the property objects into a list -->
    <j:new var="components" className="java.util.ArrayList"/>        
    <j:set var="dummy" value="${components.add(component1)}"/>
    <j:set var="dummy" value="${components.add(component2)}"/>

  </goal>

  <goal name="process" prereqs="init">

    <!-- Iterator over the list we created in the 'init' goal -->
    <j:forEach var="component" items="${components}">
      <echo>
        component.dir = ${component.dir}
        component.name = ${component.name}
      </echo>
    </j:forEach>
  </goal>


Hope that helps.

-Pete

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to