Đang chuẩn bị liên kết để tải về tài liệu:
Practical Apache Struts2 Web 2.0 Projects retail phần 8

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

bên dưới mỗi khác, hơn là theo chiều ngang bên cạnh nhau thay vì tạo ra các mẫu cá nhân, chúng tôi sẽ tạo ra một chủ đề mà cho phép bạn mở rộng khi hai trường hợp này là dự án phát triển.Hình 6-4. Sự kiện Thông tin chi tiết Enter trang hiển thị các kết quả của thất bại tùy chỉnh trình xác nhận | 232 CHAPTER 8 SEARCHING AND LISTINGS s iterator status rowstatus value parameters.event.options s property value name s if test rowstatus.last false s if s iterator li ul p Figure 8-8. The advanced search results using a new eventListing.jsp template theme Consolidating List Actions The final consideration for the search use cases is whether the code can be optimized or consolidated. From the very beginning the listEventResults.jsp template was developed with reusability in mind. Because there were several search uses cases and each needed to display results a common results page was developed. To provide the generic canvas that any CHAPTER 8 SEARCHING AND LISTINGS 233 action could use the template used properties from the calling action to provide context information to the user. The downside of this approach is that each and every calling action is now required to provide these properties. When the search actions were being developed the commonality required to render the result was missed and it s now time to return and extract the common elements. The first step is to create a base class and extract the common elements. Each of these elements has been covered in detail previously The property and setter that allows the Eventservice business service to be used by the action The property and getter for the list of resulting events The property and getter for the description of the search that was just performed A getter that allows the JSP to select the correct template to render the event details The base class BaseSearchAction listing is shown next is the result of extracting the common elements. To ensure that developers subclass the action class correctly and all the elements necessary to render the results are provided the class is made abstract along with the getEventTemplate method. public abstract class BaseSearchAction extends BaseAction protected String userInfo protected List Event results protected EventService service public void setEventService .