javajspjstlnetuibeehive

How to use if clause inside a netui data repeater


I'm looking for method to inject value into a <c:if test>. The code below works if I substitute

<% out.print(request.getSession().getAttribute("UserName").toString()); %>

with some constants. But how can I parse a value in <%%> tag into a <c:if test>?

<netui-data:repeater dataSource="pageFlow.availableBooks">
    <tr>
        <td><netui:label value="${container.item.bookName}" /></td>
        <td>
            <c:if test="${container.item.createdBy == '<% out.print(request.getSession().getAttribute("UserName").toString()); %>'}">
            <netui:anchor action="removeBookAction" value="Remove" formSubmit="true">
                <netui:parameter name="bookID" value="${container.item.bookID}" />
            </netui:anchor>
            </c:if>
        </td>
    </tr>
</netui-data:repeater>

Thanks in advance!


Solution

  • You can use sessionScope to read the value from session scope. The following will help you to resolve:

    <c:if test="${container.item.createdBy == sessionScope.UserName}">