Viewing page code for a JSF page
About this task
When you create a JSF page, an empty Java class with the same name is generated in the pagecode package. For example if you create a Facelet page named CustomerList.xhtml, the class pagecode.CustomerList is created. This class is registered as a request scope managed bean in the Faces configuration file, with the name of the Java class prefixed with pc_, so the CustomerList class is registered as the managed bean pc_CustomerList. This managed bean is used for the root of most of the value and method binding expressions in the Facelet page.

Page code managed beans are repositories for convenience methods for accessing relevant data from the page, such as UI components, other managed beans, and action logic. These methods are usually coupled with private references to the data, which are lazy initialized by the accessor methods.
To view the contents of the Java page code file for a JSF page:
Procedure
- Right-click within a blank area of the page in the Design, Split or Source view.
- Click Edit Page Code.
Results
By default, a page code file is generated for each JSF page, but you can change this at any time in the Preferences settings. You also have the options to delete page code file information when you delete a JSF page and to generate fields and getters in the page code file for all Faces components.
- Click .
- Expand .
When you create the first JSF file in a Web project, the parent class for all the generated page code, pagecode.PageCodeBase, is generated into the project. This is a good location to add common functions that you want to use in all of your page code.
The parent for all page code comes with a number of convenience methods to be used in the action logic. These methods assist in finding components in the UI tree, manual navigation, and logging, among other functions.
Example of UI components in page code
About this task
<h:commandButton type="submit" value="Submit" styleClass="commandButton" id="selectButton"
action="#{pc_CustomerSelect.doSelectButtonAction}">
</h:commandButton>
protected UINamingContainer subview1;
protected HtmlCommandButton selectButton;
protected HtmlForm form1;
protected UINamingContainer getSubview1() {
if (subview1 == null) {
subview1 = (UINamingContainer) findComponentInRoot("subview1");
}
return subview1;
}
protected HtmlCommandButton getSelectButton() {
if (selectButton == null) {
selectButton = (HtmlCommandButton) findComponentInRoot("selectButton");
}
return selectButton;
}
protected HtmlForm getForm1() {
if (form1 == null) {
form1 = (HtmlForm) findComponentInRoot("form1");
}
return form1;
}
}