Re: Listing enumerations

Tim Pizey <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <CAArDntiG5i7f+QQgSXMeqEYTviqzUGjy-8n_pd+o2=ozXRiN_Q@mail.gmail.com>
On 9 March 2012 21:26, Daniel Dekany  wrote:
> What's the Java class and method behind database.displayTables?

It was:

  public Enumeration<Table> displayTables() {
    return displayTables(PoemThread.inSession() ?
PoemThread.transaction() : null);
  }


I have changed the template to
<#list melati.database.getDisplayTables() as table>

which uses

  public List<Table> getDisplayTables() {
    return EnumUtils.list(displayTables());
  }

which has moved me on to the next problem!

(Melati, being ancient) does use a lot of Enumerations)

thanks for all your help
Tim



> --
> Best regards,
>  Daniel Dekany
>
>
> Friday, March 9, 2012, 6:31:24 PM, Tim Pizey wrote:
>
>> Hi,
>>
>> I have a method which returns an Enumeration, but when it is rendered
>> with #list or #foreach
>> an exception is thrown:
>>
>> ?size is unsupported for: freemarker.ext.beans.OverloadedMethodModel
>> The problematic instruction:
>> ----------
> ==>> list melati.database.displayTables as table [on line 67, column 50
>> in org/melati/admin/Top.fml]
>> ----------
>>
>> Java backtrace for programmers:
>> ----------
>> freemarker.template.TemplateModelException: ?size is unsupported for:
>> freemarker.ext.beans.OverloadedMethodModel
>>         at
>> freemarker.ext.beans.OverloadedMethodModel.size(OverloadedMethodModel.java:149)
>>         at
>> freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:174)
>>         at freemarker.core.Environment.visit(Environment.java:428)
>>
>> The template is:
>>
>> <select name="table" OnChange="submit();" title="Select table to edit">
>> <#assign lasttype = "">
>> <#assign selected = false>
>> <#list melati.database.displayTables as table>
>>   <#if !table.tableInfo.category.equals(lasttype)>
>>     <option value="">&nbsp;</option>
>>     <option value="">${table.tableInfo.category.name}</option>
>>     <option value="">============</option>
>>   </#if>
>>   <#assign lasttype = table.tableInfo.category>
>>   <option value="${table.name}"
>>   <#if !selected>
>>    <#if melati.table>
>>     <#if melati.table.equals(table)>
>>     selected="selected"
>>      <#assign selected = true>
>>    </#if>
>>    <#else>
>>     <#if table.getName().equals(admin.getPrimaryDisplayTable(melati))>
>>      selected="selected"
>>       <#assign selected = true>
>>     </#if>
>>    </#if>
>>   </#if>> ${ml.rendered(table.displayName)}</option>
>> </#list></select>
>>
>>
>> I am using BeanWrapper.
>>
>> The documentation for #list
>> http://freemarker.sourceforge.net/docs/ref_directive_list.html
>> says, as far as I can understand, that an enumeration and and iterator
>> should be usable.
>>
>> Sorry if this is a newbie error.
>>
>> thanks in advance
>> Tim
>
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user



-- 
Tim Pizey
http://pizey.net/~timp

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.