In this code I get authorId for each author's name from bookListArray
and show it for each book, using iterating element aBook
. How can I refactor my code with no scriplets? How can I iterate my bookListArray
in .java code?
<liferay-ui:search-container>
<liferay-ui:search-container-results results="${bookListArray}" />
<liferay-ui:search-container-row className="builder.model.Book" keyProperty="bookId" modelVar="aBook">
<liferay-ui:search-container-column-text property="bookName" name="book-Name" />
<liferay-ui:search-container-column-text property="bookDescription" name="description" />
<%
Author bookAuthor = AuthorLocalServiceUtil.getAuthor(aBook.getAuthorId());
%>
<liferay-ui:search-container-column-text value="<%=bookAuthor.getAuthorName() %>" name="Author" />
<liferay-ui:search-container-column-jsp path="/html/actionBook.jsp" align="right" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
It's my author and book lists:
List<Book> bookList = BookLocalServiceUtil.getBooks(QueryUtil.ALL_POS, QueryUtil.ALL_POS);
List<Author> authorList = AuthorLocalServiceUtil.getAuthors(QueryUtil.ALL_POS, QueryUtil.ALL_POS);
request.setAttribute("bookListArray", bookList);
request.setAttribute("authorListArray", authorList);
if you want to look at my project you can do it here: https://github.com/AlBoldyrev/Library/blob/master/bundles/tomcat-7.0.62/webapps/LibraryBook-portlet/WEB-INF/src/com/softwerke/BookAndAuthor.java