खोज…


टिप्पणियों

JSF वेब एप्लिकेशन के लिए आम लेआउट बनाने के लिए विशेष टैग प्रदान करता है जिसे फेसलेट टैग कहा जाता है। ये टैग एक जगह पर कई पृष्ठों के सामान्य भागों को प्रबंधित करने के लिए लचीलापन देते हैं।

नेमस्पेस:

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>

यह फ़ाइल अनुप्रयोग के लिए टेम्पलेट के रूप में कार्य करेगी। अब हम अपनी दृश्य निर्देशिका में एक विशिष्ट दृश्य परिभाषित करेंगे।

/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 विशेषता पर एक नज़र डालें, यह जेएसएफ को उस टेम्पलेट का उपयोग करने के लिए कहता है जिसे हम चाहते हैं। फिर, <ui:define> का उपयोग करते हुए हम विशिष्ट सामग्री को सम्मिलित करने के लिए परिभाषित करते हैं जहां इसे टेम्पलेट में बताया गया है। क्लाइंट में /home.xhtml एक्सेस करना पूरे परिणाम को प्रस्तुत करेगा।



Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow