Hi,
since we can't guest hour your Java data structure looks like,
I will assume something like:
public class Report
{
public List<Section> getSections();
}
public class Section
{
public List<Subsection> getSubsections();
}
public class Subsection
{
public List<String> getArticles();
}
In the java code (e.g. VelocityViewServlet subclass):
context.put("report", myReportInstance);
In the velocity template:
#foreach( $section in $report.sections )
$section.title
#**##foreach( $subsection in $section.subsections )
$subsection.title
#* *##foreach( $article in $subsection.articles )
$article#*this uses the method toString() of the java class behind
the article*#
#* *##end
#**##end
#end
If you need help on indenting or whitespace handling
just ask this list...
Cheers,
Christoph
P.S. Just before sending this, I saw that Claude already posted a
similar answer...
Verma, Abhishek (Abhishek V) wrote:
> Hi all,
> I am a new to velocity.
>
> I have a data structure in java like follow:-
>
> --Section 1
> ------SubSection1.1
> -----------Article 1
> -----------Article 2
> -----------Article 3
> ------SubSection1.2
> -----------Article 4
> -----------Article 5
> -----------Article 6
>
> --Section 2
> ------SubSection2.1
> -----------Article 7
> -----------Article 8
> -----------Article 9
> ------SubSection2.2
> -----------Article 10
> -----------Article11
> -----------Article 12
> ------SubSection2.3
> -----------Article 13
> -----------Article14
> -----------Article 15
>
> --Section 3
> ------SubSection3.1
> -----------Article 16
> ------SubSection3.2
> -----------Article 17
> -----------Article18
> -----------Article 19
> ------SubSection3.3
> -----------Article 20
>
>
> Now in the VTL i have to retreive these articles like the same structure
> Any help is appreciated
>
> ==Abhishek==
> Hewlett-Packard
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]