iterator - Dynamic struts2 object field name -


i'm trying generate table columns dynamically.

currently, code:

<s:iterator value='entities' var="entity">   <tr>     <s:iterator value="beanmd.fieldsmetadata" var="fieldmd" >       <td><s:property value="#entity.email"/> <!-- prints ok :  email@email.com -->        <s:property value="#fieldmd.value.name"/> <!-- prints ok :  email-->         <s:property value="#entity.%{#fieldmd.value.name}" /> <!--  nothing -->        <s:property value="#entity.%{fieldmd.value.name}" /> <!--  nothing -->        <s:property value="entity.%{fieldmd.value.name}" /> <!--  nothing -->        <s:property value="entity.%{#fieldmd.value.name}" /> <!--  nothing -->       </td>    </s:iterator>   </tr> </iterator> 
  • entities it's collection beans data.

  • beanmd.fieldsmetadata map, contains attributes of entities.

in example above, used attribute "email" example. if ask directly attribute, returns ok. if ask column name, ok. can´t find way use together.

this post seems related, struts2 nested iterator dynamic column , rows uses maps, , didn't me much.

use square brackets value bean.

<s:property value="#entity[#fieldmd.value.name]" /> 

it possible because internally ognl treats following expressions same.

so

<s:property value="date.time" /> 

and

<s:property value="date['time']" /> 

produces same result.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -