수색…
비고
JSF는 facelets 태그라는 웹 애플리케이션의 공통 레이아웃을 작성하는 특수 태그를 제공합니다. 이 태그는 여러 페이지의 공통 부분을 한 곳에서 관리 할 수있는 유연성을 제공합니다.
네임 스페이스 :
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
템플릿을 만드는 방법
하나의 응용 프로그램에 대한 템플리트 설정
/WEB-INF 폴더 아래에 template.xhtml 이라는 이름의 파일을 만듭니다. 이렇게하면 프레임 워크에 대해서만 템플릿 파일에 액세스 할 수 있습니다.
/WEB-INF/template.xhtml
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<h:head>
<title><ui:define name="title">Default title</ui:define></title>
</h:head>
<h:body>
<!-- Some styles that we might include for our whole application -->
<h:outputStylesheet name="css/template.css" />
<!-- Shared content for the application, e.g. a header, this can be an include -->
<div>
Application Header
</div>
<!-- The content we want to define in our template client -->
<div>
<ui:insert name="content" />
</div>
</h:body>
</html>
이 파일은 응용 프로그램의 템플리트 역할을합니다. 이제 view 디렉토리에 특정 뷰를 정의 할 것입니다.
/home.xhtml
<ui:composition template="/WEB-INF/template.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:define name="title">Home</ui:define>
<ui:define name="content">
Welcome to the application!
</ui:define>
</ui:composition>
이 클라이언트보기에서 template 속성을 살펴보면 JSF가 원하는 템플리트를 사용하도록 지시합니다. 그런 다음 <ui:define> 을 사용하여 템플릿에 지정된 위치에 삽입 할 특정 내용을 정의합니다. 클라이언트에서 /home.xhtml 에 액세스하면 전체 결과가 렌더링됩니다.
Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow