- PrimeFaces Theme Development
- Andy Bailey Sudheer Jonna
- 430字
- 2021-07-09 21:12:25
Creating a Mini Showcase page
In the following section, we will create pages with PrimeFaces components so that we can see how themes affect their look and feel. It is a mini showcase because we will not add every available PrimeFaces component.
Perform the following steps to create a Mini Showcase page:
- Right-click on the
chapter2
folder and move the mouse over New. Select the Facelets Template Client option and name itmorecomponents
. - Choose
chaptersTemplate
as the page template and click on Finish. - Add an appropriate page title in the
define name="title"
tag. I used the following:<ui:define name="title"> A mini ShowCase of PrimeFaces components </ui:define>
- Then, add the following code in the content
define
tag. I included thedefine
tag for completeness; the relevant code is highlighted:<ui:define name="content"> <h:form id="mainForm"> <h:panelGrid columns="2"> <p:outputLabel value="PrimeFaces Input:"/><p:inputText/> <p:outputLabel value="PrimeFaces Spinner"/><p:spinner/> <p:outputLabel value="PrimeFaces Panel"/> <p:panel header="An simple panel" toggleable="true" toggleTitle="Click to close/open"> <p:commandButton value="Show dialog" onclick= "PF('simpleDialog').show();"process="@this"/> </p:panel> </h:panelGrid> <p:dataList value="#{themesService.themes}" var="theme"> #{theme} </p:dataList> <p:dialog id="dialog1" widgetVar="simpleDialog" modal="true"> <p:commandButton id="closeDialog" value="Close the dialog" onclick="PF('simpleDialog').hide();" process="@this"/> </p:dialog> </h:form> </ui:define>
There is no need to go into the different components here. The important thing is that we have a set of components with different features that will look different according to the theme currently being used.
- Save the file and open
chaptersTemplate
. Then, add a link to the page that we just created by adding the following highlighted code to the Chapter 2 submenu:<p:submenu id="chapter2" label="Chapter 2"> <p:menuitem id="c2difference" value="Differences" url="/chapter2/difference.xhtml"/> <p:menuitem id="c2morecomponents" value="Mini Showcase" url="/chapter2/morecomponents.xhtml"/> </p:submenu>
- Now, save the changes that we made. To make sure that the project runs correctly, we need to clean and build the project before running it again.
- When the project is up and running again, use the Chapter 2 submenu to navigate to the Mini Showcase page. You will see something similar to the following screenshot:
In the preceding screenshot, the afternoon theme was chosen. This is a good opportunity if you wish to try out the different available themes to see how things look.
The Show dialog button actually opens a modal dialog box, which contains a button to close the dialog box again. Try it to see how the dialog box looks. Note that we cannot change the current theme with the dialog box left open. This is because a modal dialog box masks the rest of the page and only allows interaction with the dialog box itself. We use a modal dialog box here because of the pane used to mask the rest of the page. It normally has a translucent background, but this can change depending on the theme.
- 測試驅動開發:入門、實戰與進階
- 劍指JVM:虛擬機實踐與性能調優
- Web Scraping with Python
- JavaScript 網頁編程從入門到精通 (清華社"視頻大講堂"大系·網絡開發視頻大講堂)
- 你不知道的JavaScript(中卷)
- Python機器學習經典實例
- 零基礎學Python網絡爬蟲案例實戰全流程詳解(入門與提高篇)
- Access 2010數據庫應用技術(第2版)
- Python從入門到精通
- Java 9 Programming By Example
- HTML5+CSS3+JavaScript 從入門到項目實踐(超值版)
- Python大規模機器學習
- Selenium WebDriver Practical Guide
- SQL Server 2014 Development Essentials
- 讀故事學編程:Python王國歷險記