On Dec 8, 2004, at 3:04 PM, Leszek Gawron wrote:

I would like to add one feature to JXTG that would allow not to promote hacks like [1]. Example:

<jx:macro name="fooBar">
  <some>content</some>
</jx:macro>

you can only invoke it by <fooBar/>

If I were able to do <jx:invoke macro="fooBar"/> I would be able to pass macro name as a parameter to other macro which allows quite powerful data injection technique:

<jx:macro name="superPrettyPrintedTable">
  <jx:parameter name="headerTemplate"/>
  <jx:parameter name="elements"/>
  <jx:parameter name="rowTemplate"/>
  <!-- fancy code with lots of graphics here -->
  <table>
    <tr>
      <jx:invoke macro="${headerTemplate}"/>
    </tr>
    <jx:forEach var="currentElement"
                items="elements"
                varStatus="status">
      <tr>
        <td>${status.index}</td>
        <jx:invoke macro="${rowTemplate}" element="${currentElement}"/>
      </tr>
    </jx:forEach>
  </table>
  <!-- fancy code with lots of graphics there -->
</jx:macro>

then use the macro like this:
<jx:macro name="addressesHeaderTemplate">
  <th>City</th><th>Street</th>
</jx:macro>
<jx:macro name="addressRowTemplate">
  <jx:parameter name="address"/>
  <td>${address.city}</td>
  <td>${address.street}/td>
</jx:macro>
<jx:invoke macro="superPrettyPrintedTable"
           headerTemplate="addressHeaderTemplate"
           elements="${addresses}"
           rowTemplate="addressRowTemplate"/>


WDYT? We could deprecate jx:eval then which is not fully supported as additional Map structure has to be used as [1] shows.


It does not seem that much coding is needed. I could also strip all inner classes from JXTG at the same time as the first step for JXTG refactoring.

Sounds good to me. a non-voting +1


Glen Ezkovich HardBop Consulting glen at hard-bop.com http://www.hard-bop.com



A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to worry about answers."
- Thomas Pynchon Gravity's Rainbow




Reply via email to