0

I'm working on a portlet for showing a list of rules, for selection. And I want to focus the row of content selected on my database (rules variable loaded on init.jsp).

What I should do for focusing/highlighting exactly one row?

Should I use <c:when <c:otherwhise for all the .jsp:

I show a list of rules with this code:

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />

<liferay-ui:search-container emptyResultsMessage="there-are-no-products" delta="5">
    <liferay-ui:search-container-results>
        <% 
        List<IRRule> tempResults = ActionUtil.getRules(renderRequest);
        results = ListUtil.subList(tempResults, searchContainer.getStart(),
        searchContainer.getEnd());

        total = tempResults.size();
        pageContext.setAttribute("results", results);
        pageContext.setAttribute("total", total);
        %>
    </liferay-ui:search-container-results>

    <liferay-ui:search-container-row
        className="com.everis.oriol.inputrules.model.IRRule"
        keyProperty="ruleId"
        modelVar="rule">

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

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

        <liferay-ui:search-container-column-jsp
            path="/row.jsp"
            align="right"
            />

    </liferay-ui:search-container-row>

    <liferay-ui:search-iterator />

</liferay-ui:search-container>

In the init.jsp file I have...

<% 
long groupId = themeDisplay.getScopeGroupId();
List<IRSelect> rulesPas = IRSelectLocalServiceUtil.getRule(groupId);

String rules =  rulesPas.get(0).getRuleName();
%>

I exactly want to compare...

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

with...

rules

Thank you for your help

Prakash K
  • 11,669
  • 6
  • 51
  • 109
user1592470
  • 401
  • 2
  • 8
  • 21

1 Answers1

0

One of the ways I can think of is by setting the bold attribute of <liferay-ui:search-container-row> tag which would show the element as bold if its value is true:

<liferay-ui:search-container-row
        className="com.everis.oriol.inputrules.model.IRRule"
        keyProperty="ruleId"
        modelVar="rule"
        bold="<%=rules.equals(rule.getRuleName()) %>">

...

</liferay-ui:search-container-row>

Or by setting a CSS class for the entire row if you want more options to style the row:

<liferay-ui:search-container-row
    className="com.everis.oriol.inputrules.model.IRRule"
    keyProperty="ruleId"
    modelVar="rule">

    <%
    if (rules.equals(rule.getRuleName())) {
        // here "row" is the ResultRow object, instance for each row
        row.setClassName("my-custom-css-class");
    }
    %>

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

     ...

</liferay-ui:search-container-row>

If you want that only the rule column text in that one row should be shown differently and not the entire row then:

<liferay-ui:search-container-column-text
        name="ruleName"
        property="ruleName"
        cssClass="<%=rules.equals(rule.getRuleName()) ? \"my-custom-css-class\" : \"\" %>"
        />
Prakash K
  • 11,669
  • 6
  • 51
  • 109