TAILIEUCHUNG - Bắt đầu với IBM Websphere smash - p 16

132 Chapter 6 Response Rendering Business Logic Header Header Dynamic Content Nav Footer Dynamic Content Nav Footer Figure Updated assembly flow Listing /public/quiz/—Simple Redirect to Business Logic Listing /app/scripts/—Business Logic Controller def go() { if ( [] == null ) { = "home" } else { = "quiz" = getQuizData() } // This would be pulled from DB or config file = [ 'home' : 'Home', 'php' : 'PHP Quiz', 'groovy': 'Groovy Quiz', 'dojo' : 'Dojo Quiz', 'smash' : 'sMash Quiz' ] = "quiz/theme/" render() } Download from Using Views for Rendering 133 def getQuizData() { // Determine quiz, and get questions. return [ 'title': 'PHP Quiz', 'questions': [. | 132 Chapter 6 Response Rendering Figure Updated assembly flow Listing public quiz Simple Redirect to Business Logic invokeMethod go null Listing app scripts Business Logic Controller def go if null home else quiz getQuizData This would be pulled from DB or config file home Home php PHP Quiz groovy Groovy Quiz dojo Dojo Quiz smash sMash Quiz quiz theme render Download from Using Views for Rendering 133 def getQuizData Determine quiz and get questions. return title PHP Quiz questions q A PHP script block looks like a php . php . php . php . Other questions As you can see all of our controller and business logic is contained with the script. We essentially set our target content page and push a view variable onto the request. Finally we render our theme view template. I won t repeat the code for the theme but it s essentially the page load of HTML and includes our header footer and navigation which also had its business-specific content moved into our controller. The only difference now is we dynamically pull in our target content page as shown in Listing . The nice thing here is that it would be trivial to modify this to handle either a single or multidimensional array of target pages to include so we can have a simple mash-up environment. Listing app views quiz theme fragment -Include Our Content Page td class content quiz .gt render td The last item we should look at is the new view file shown in Listing . In our controller file we defined a complex quiz data object that we put on the request. This allows our Download from 134 Chapter 6 Response Rendering quiz view to be ignorant of the data contents and thus makes it highly reusable. The first page of our PHP quiz can now be seen in Figure .

TỪ KHÓA LIÊN QUAN
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.