Question

I am getting my Model data from JSON.

I have implemented the searchContainer successfully, however I want to access the deep object elements

<liferay-ui:search-container searchContainer="${searchRecordsContainer}"  >
    <!-- In order to get the total results and also to display no. of data -->  
    <liferay-ui:search-container-results total="<%=searchContainer.getTotal() %>" results="<%=searchContainer.getResults() %>" />
    <!-- Display Row with First Name,Last Name,ScreenName and Description as columns -->
    <liferay-ui:search-container-row  className="com.demo.Records" >
            <liferay-ui:search-container-column-text name="Record Id" property="recordId"/>
            <liferay-ui:search-container-column-text name="Record Value" property="attributes.value('SOME_KEY')"/>    //how to do this??
    </liferay-ui:search-container-row>
    <!-- Iterating the Results -->
    <liferay-ui:search-iterator/>
</liferay-ui:search-container>

Model of the Records

public class Records {
    private Attributes attributes;
    private String recordId;
}
public class Attributes {
    private List<Entry> entry;
    public String getValue(String key) {
        if (this.entry == null || this.entry.isEmpty()) {
            return "";
        }
        for (Entry record : this.entry) {
            if (record.getKey() != null && record.getKey().equalsIgnoreCase(key)) {
                return record.getValue();
            }
        }
        return "";
     }

}
public class Entry {
    private String key;
    private String value;
}

So how do I call that specific method by passing some STRING value to get my desired value?

One more point, I want to do some server side processing, when user clicks on nextPage or changes recordsPerPage or Sorting, how do I handle that? Any example is much helpful

Was it helpful?

Solution

You can have modelVar record attribute for row.

And use it like record.getAttributes().getValue(key)

Regards,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top