Re: How to generate the output for a given java collection object
Rajvinder Pal <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Ok.I think i want to see a proffessionaly written ftl sample file.Could you point me to any such file from web or personally you might have written.I just want to know how a ftl file looks like in a real time application. Thanks, Rajvinder From: Daniel Dekany <[email protected]> To: Rajvinder Pal <[email protected]> Cc: FreeMarker-user <[email protected]> Sent: Sunday, September 25, 2011 12:51 AM Subject: Re: [FreeMarker-user] How to generate the output for a given java collection object Saturday, September 24, 2011, 7:28:40 PM, Rajvinder Pal wrote: > Thanks, in that case i will prefer to write template with proper > formating.I will use compress directive in template and let browser format the html display for me. I would not use compress, unless the bandwidth you save indeed matters. It's a *runtime* compression, and is actually yet another legacy, from FM 1.x I believe. -- Best regards, Daniel Dekany > Regards, > Rajvinder > > > > From: Daniel Dekany <[email protected]> > To: Rajvinder Pal <[email protected]> > Cc: FreeMarker-user <[email protected]> > Sent: Saturday, September 24, 2011 10:13 PM > Subject: Re: [FreeMarker-user] How to generate the output for a given java collection object > > Saturday, September 24, 2011, 5:00:00 PM, Rajvinder Pal wrote: > >> Thanks Daniel! finally i am able to get the expected output with your suggesstion:- >> >> <#list itemMap?keys as key> >> ${key} >> <#list itemMap(key) as item>${item} </#list> >> </#list> >> >> I was trying to evaluate the FreeMarker for a requirement to >> generate the html table dynamically.I felt FreeMarker is bit tricky >> to solve the problem. > > Well, there are some old warts (legacies...) that users has to get > over... the two main warts are that FTL has no map type (only a > string-keys-only one) and that FTL doesn't have null (but treats > null-s coming from Java as missing variables). > >> But the mailing list response is amazing.te >> with respect to generating output i am facing one more challenge it >> may be very silly to ask but since i am new to FreeMarker i want to >> know, how can we write template with proper indention but still >> able to get the get the output html in proper indention. > > Sadly, you can't... nor in any other template language that I know of. > It's actually a rather tricky thing to do properly (much easier to do > almost properly), unless the template language understands HTML/XML > (FreeMarker doesn't), AND you are generating HTML/XML, and even then > it would mean some runtime overhead. You may find some tricks here > regarding white-space handling: > > http://freemarker.org/docs/dgui_misc_whitespace.html > > but they won't give you proper indentation. > >> for example suppose my template logic looks like:- >> >> for each bean >> print <beean..... >> <# if condition.....> >> <#if condition .... > >> <#if condition > >> print <inner tag....... >> >> >> >> The above logic will print something similar to this:- >> >> <bean..... >> <inner >> >> >> >> IN the above output, indention is too much for second . >> How can we have template as well generated output in proper xml >> type format? i mean with proper indention > > You had to apply something on the output Writer that understands the > output format and reformats it... Of course, that will have its cost > in resource usage. > ------------------------------------------------------------------------------ All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2 _______________________________________________ FreeMarker-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freemarker-user