How does JSF render more than one JSP pages into 1 single view?

≡放荡痞女 提交于 2020-01-16 07:41:09

问题


I have an application where the WebContent folder has a number of .jsp pages like navigation.jsp, primarytabs.jsp etc.

The navigation.jsp contains a vertical menu and the primarytabs.jsp contains a tab on top, and some other jsps contain individual components.

When I run the application of the application server, it opens up a welcome page, and all these navigation items, and tabs and others merge into a single view and show us a well formed combination of all these components.

I did some studying and read about "composite views". But I wasn't sure if I can call this composite view or not.

Can you please enlighten me about how JSF combines all these jsps into one view and where to find that "binding" within the code so I can make the relevant changes?

Thank you very much.

More details:

Thank you very much for the answers. I have gone through the code and have seen

src="<%= request.getContextPath() %> /faces/tabs.jsp 
src="<%= request.getContextPath() %> /faces/navigator.jsp

and so on. I presume these perform the similar function that you have described above with the include tag?


回答1:


You welcome page might look something like this:

Welcome.jsp:

<jsp:include page="/include/header.jsp" />
<jsp:include page="/include/navigation.jsp" />

<!-- Content of Page -->

<jsp:include page="/include/footer.jsp" />

Think of Welcome.jsp being a refrigerator and the includes being magnets that are on the page.

If you would like to change something in the header.jsp that would change on every page it is included on, templating in a sense.




回答2:


Read about "Apache Tiles", it may give you some clue for your doubt.

And check about

 <jsp:include page"XXXXX.jsp" />. 

It is another way of doing the same.



来源:https://stackoverflow.com/questions/23679991/how-does-jsf-render-more-than-one-jsp-pages-into-1-single-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!