Tapestry 5
  1. Tapestry 5
  2. TAP5-205

Add an empty parameter to the Loop component, to display a message when there are no items to loop over

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 5.0.15
    • Fix Version/s: 5.0.16
    • Component/s: None
    • Labels:
      None

      Description

      I have a quick suggestion to improve the Loop component:

      We should be able to specify a block to display if the loop source is
      empty (size = 0)

      <div t:type="loop" source="anEmptyList">
      <t:parameter name="empty">There is no item matching your request</
      t:parameter>
      </div>

      I know we can do this :
      <t:if test="anEmptyList">
      <div t:type="loop" source="anEmptyList">

      </div>
      <t:parameter name="else">There is no item matching your request</t:parameter>
      </t:if>

      BUT this will have the result of calling the "getAnEmptyList()" getter
      in the component code twice.
      If you access the database in the getter (as the docs suggest quite a
      few times), this will call the database twice for nothing.

      Thanks !

        Activity

        Hide
        Tobias Wehrum added a comment -

        The same would be useful for the Grid component.

        Show
        Tobias Wehrum added a comment - The same would be useful for the Grid component.
        Hide
        Igor Drobiazko added a comment -

        There is already a parameter for Grid. Check out the 'empty' parameter.

        Show
        Igor Drobiazko added a comment - There is already a parameter for Grid. Check out the 'empty' parameter.

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            D. Marquis
          • Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development