TAILIEUCHUNG - Mastering JavaServer™ Face phần 9

Việc thực hiện getSharedRenderer luôn nhìn lên Renderer cho . Chiến lược này cung cấp sự linh hoạt tuyệt vời để thành phần của bạn trong tay các nhà phát triển khác. Nếu nhà phát triển khác lựa chọn sử dụng các thành phần cuộn nhưng muốn làm cho nó với một Renderer khác nhau, | 366 Chapter 10 Renderer identified by whatever the component s rendererType method returns. The implementation of getSharedRenderer always looks up the Renderer for . This strategy provides great flexibility to your component in the hands of other developers. If another developer chooses to use the scroller component but wants to render it with a different Renderer they are free to do that but they can always revert to the packaged Renderer by simply setting the rendererType attribute to null. One final point about local rendering on components that is important to remember The implementation of decode could have been done with a copy of the code from the Renderer what we have been trying to avoid . In that case the Renderer and the component would tend to have divergent implementations that is over time bugs would be fixed in one place but not the other and so on which could lead to a lot of confusion and trouble in using the scroller. Remember to implement the rendering functionality only once in a default Renderer then delegate processing to that implementation. Encoding The next group of methods handles encoding the component into HTML. The encodeBegin method is shown again for quick reference public void encodeBegin FacesContext context throws lOException getClass .getName encodeBegin if context null NullPointerException npe new NullPointerException FacesContext is null while trying to encode getId .getName encode npe throw npe if getRendererType null Renderer renderer getSharedRenderer context context this else render kit render context As you can see much of the same functionality is present in this method as in the decode method we just looked at. In the same way that we want to avoid copying and pasting the decode functionality we want to avoid copying and pasting the encode functionality. All three encode methods have the same basic structure they just .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.