liferay-6.2searchcontainer

Customizing how values get displayed in a Liferay SearchContainer


My Liferay entity Person has a <column name="mother" type="long" /> which points to the primary key of another instance of Person. This long shows up as a number in the SearchContainer table I created:

    <liferay-ui:search-container-column-text
        name="category"
        property="category"
    />

Now, instead of showing up as a long I would like to display the name of the person. So I wrote:

    <%
        String motherName =
            PersonLocalServiceUtil.getPerson( person.getMother() )
                .getName();
        }
    %>

    <liferay-ui:search-container-column-text
        name="mother"
        value="<%= motherName %>"
        property="mother"
    />

PROBLEM: The values that get displayed in this column are still the long numbers, not the name. Even after rebuilding and restarting.

What am I doing wrong?


Solution

  • Check the implementation of SearchContainerColumnTextTag:

    public int doEndTag() {
        ...
        if (Validator.isNotNull(_property)) {
            _value = ...
        }
    

    As you can see, you can't set both, property and value. Just set value and you are fine.