Render Map & lt; String, Object & gt; In the freemarker table

I am getting error while rendering Map to freemarker template table. below is the map what i am getting from controller with actual values.

Map hramonths ={4={id=4, empjoindate=16 Nov 2007, description=Apr-2012, editable=T}, 5={id=5, empjoindate=16 Nov 2007, description=May-2012, editable=T}, 6={id=6, empjoindate=16 Nov 2007, description=Jun-2012, editable=T}, 7={id=7, empjoindate=16 Nov 2007, description=Jul-2012, editable=T}, 8={id=8, empjoindate=16 Nov 2007, description=Aug-2012, editable=T}, 9={id=9, empjoindate=16 Nov 2007, description=Sep-2012, editable=T}, 10={id=10, empjoindate=16 Nov 2007, description=Oct-2012, editable=T}, 11={id=11, empjoindate=16 Nov 2007, description=Nov-2012, editable=T}, 12={id=12, empjoindate=16 Nov 2007, description=Dec-2012, editable=T}, 1={id=1, empjoindate=16 Nov 2007, description=Jan-2013, editable=T}, 2={id=2, empjoindate=16 Nov 2007, description=Feb-2013, editable=T}, 3={id=3, empjoindate=16 Nov 2007, description=Mar-2013, editable=T}}

from my controller now i want to render this values to my freemarker template like

                
                    
                        
                             
                        
                    
                    
                        ${indication.description}  
                    
                    
                        
                        
                            
                                
                            
                        
                        <select name="indicator_${indication.id}"  disabled="true"  disabled="true">
                            
                                <option value="${indicator.cid}"  selected >
                                    ${indicator.description}
                                
                            
                        
                    
                    
                        
                            
                                
                                    <input type="text" align="right" name="rent_${indication.id}_${rent.cid}"
                                        value="$DelphiNumber.formatNumber("$!rent.rent")"
                                        
                                        readonly="true" class="rbox" 
                                        
                                            readonly="true" class="rbox"
                                        
                                        
                                            onBlur="isnumeric(this.form,this),updateHRATotalAll(this.form,'blurtype')"
                                     />
                                
                            
                        
                            
                            
                        
            
        
    

but i am getting error

Expected collection or sequence. hramonths evaluated instead to freemarker.template.SimpleHash on line 199, column 40 in WEB-INF/classes/com/greytip/cougar/module/epayroll/v2/freemarker/salary/it-declaration.ftl. The problematic instruction: ---------- ==> list hramonths as indication [on line 199, column 33 in WEB-INF/classes/com/greytip/cougar/module/epayroll/v2/freemarker/salary/it-declaration.ftl] ----------  Java backtrace for programmers: ---------- freemarker.template.TemplateException: Expected collection or sequence. hramonths evaluated instead to freemarker.template.SimpleHash on line 199, column 40

How do i render it on a table please any one help me.

Replace you Map
with List
. So it looks like:

List hramonths =[
    {id=4, empjoindate=16 Nov 2007, description=Apr-2012, editable=T},
    {id=5, empjoindate=16 Nov 2007, description=May-2012, editable=T},
    {id=6, empjoindate=16 Nov 2007, description=Jun-2012, editable=T}]

You can use get all values from map:

Collection hramonthsValues = hramonths.values();
Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合编程 » Render Map & lt&semi; String&comma; Object & gt&semi; In the freemarker table

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录