Results 1 to 3 of 3
  1. #1
    fl2297 is offline Member
    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Default Velocity - Using Loops for Handling lists within variables

    Hello All, I am having an issue with using loops on handling a results list if it has one or two results.

    Here is what I am trying to accomplish.

    If I have a results list variable with two results:

    Supplemental
    2nd of result list text

    Result
    1st of result list text.
    ==========================================


    If I have a results list variable with one result

    Result
    1st of result list text

    ===============================================

    Based upon the code I have listed below, this works successfully when I have a variable with two results. However, if I only have one result, the label supplemental will display and no results show. This makes sense as the if statement is looking for anything to where the resultslist variable is greater or equal to 2. The issue I am having is that I can't seem to get this to work per the result of variable with one result. I tried an elseif statement, but the results end up getting duplicated.

    Java Code:
    <SPAN style="FONT-SIZE: 14pt">Supplemental</Span><BR>
    
    
    
    #set ($a = 0)
    #foreach ($results in $reportInfo.resultslist)
        #set ($a = $a + 1)
        #if ($a >= 2)
          <BR>
    	<SPAN style="FONT-SIZE: 14pt">Result</Span>
          <BR>
        #end
        <BR>
            $resultslist
        <BR>
    Last edited by fl2297; 12-30-2012 at 01:04 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Velocity - Using Loops for Handling lists within variables

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Velocity - Using Loops for Handling lists within variables

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. variables in loops
    By mbw290 in forum New To Java
    Replies: 11
    Last Post: 11-17-2012, 04:15 PM
  2. loops and exception handling
    By George5432 in forum New To Java
    Replies: 7
    Last Post: 05-06-2012, 03:46 AM
  3. Velocity + GWT SplitLayoutPanel
    By SigmaSquared in forum Apache Velocity
    Replies: 0
    Last Post: 01-05-2012, 03:53 PM
  4. Strange Error Regarding Lists and Variables
    By GuiRitter in forum New To Java
    Replies: 6
    Last Post: 03-29-2011, 10:36 PM
  5. Velocity / XML response
    By sabatier in forum XML
    Replies: 0
    Last Post: 07-24-2007, 01:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •