Search code examples
javajspstruts2displaytagognl

Fetching value for display:column title in Struts 2


I am working on a display table version 1.2 on Struts 2 application. I am having problem with fetching value for "titleKey" in my display table column.

<display:column property="propertyName" titleKey="common.property" /> 

But here Title key is not able to display the value from properties file. common.property is available in application resources and if I do

<s:text name="common.property"/> 

It properly displays the value.


Solution

  • You can use EL expression for the title of the column. Before that the text for the title could be set to the value stack. EL expressions in Struts2 have access to the value stack when searching for variables.

    <s:set var="commonProperty" value="%{getText('common.property')}"/>
    <display:column property="propertyName" title="${commonProperty}" />