Java Mailing List Archive

http://www.gg3721.com/

Home » user.groovy »

[groovy-user] Using Groovy to Render a jQuery Treeview

Anders Viklund

2008-08-06

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi,

I would like to use Groovy to transform html files into a jQuery Treeview format.


Here is an example of an input file:

<li>
  <img src="../images/speaker-grey.gif"/>
  <font color="#7f7f7f">
    <b>Root</b>
  </font>
  <ul>
    <li>
      <span class="folder">Order</span>
      <ul>
        <li>
          <span class="file">id = 1234</span>
        </li>
        <li>
          <span class="file">type = order.cancel</span>
        </li>
        <li>
          <span class="folder">Parameter</span>
          <ul>
            <li>
              <span class="file">id = 5678</span>
            </li>
          </ul>
        </li>
        <li>
          <span class="folder">Item</span>
          <ul>
            <li>
              <span class="file">id = 910</span>
            </li>
            <li>
              <span class="file">type = access</span>
            </li>
          </ul>
        </li>
      </ul>
    </li>
  </ul>
</li>



.. and this is what the result should look like:

<ul class="filetree treeview">
  <li class="expandable lastExpandable">
    <div class="hitarea expandable-hitarea lastExpandable-hitarea"/>
    <img src="../images/speaker-grey.gif"/>
    <font color="#7f7f7f">
      <b>Root</b>
    </font>
    <ul style="display: none;">
      <li class="collapsable lastCollapsable">
        <div class="hitarea collapsable-hitarea lastCollapsable-hitarea"/>
        <span class="folder">Order</span>
        <ul>
          <li>
            <span class="file">id = 1234</span>
          </li>
          <li>
            <span class="file">type = order.cancel</span>
          </li>
          <li class="collapsable">
            <div class="hitarea collapsable-hitarea"/>
            <span class="folder">Parameter</span>
            <ul>
              <li class="last">
                <span class="file">id = 5678</span>
              </li>
            </ul>
          </li>
          <li class="collapsable lastCollapsable">
            <div class="hitarea collapsable-hitarea lastCollapsable-hitarea"/>
            <span class="folder">Item</span>
            <ul>
              <li>
                <span class="file">id = 910</span>
              </li>
              <li class="last">
                <span class="file">type = access</span>
              </li>
            </ul>
          </li>
        </ul>
      </li>
    </ul>
  </li>
</ul>


This the structure of this tree:

Root
  Order
    id = 1234
    type = order.cancel
    Parameter
      id = 5678
      Item
        id = 910
        type = access


Any ideas how to do this are highly appreciated!


Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it!
©2008 gg3721.com - Jax Systems, LLC, U.S.A.