Monday, November 02, 2009

JSF 1.2: Woodstock and Facelets

I have been asked if there is an example of how to use facelets. In this example application, I have changed the default namespace in my NetBeans project to w from webuijsf to make it simpler to see. In this example I display the customers from the sample database which is part of the default installation of NetBeans.

Here is what it looks like displayed:


Here is the facelets view:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:w="http://www.sun.com/webui/webuijsf">
<body>
<ui:composition template="/template-client.xhtml">
<ui:define name="title">
Customers
</ui:define>
<ui:define name="body">
<w:head id="head1">
<w:link id="link1" url="/resources/stylesheet.css"/>
</w:head>
<w:body id="body1" style="-rave-layout: grid">
<w:form id="form1">
<w:table augmentTitle="false" id="table1" style="position: absolute; left: 48px; top: 48px" title="Table" width="0">
<w:tableRowGroup id="tableRowGroup1" rows="10" sourceData="#{CustomerBean.customerDataProvider}" sourceVar="currentRow">
<w:tableColumn headerText="CUSTOMER_ID" id="tableColumn1" sort="CUSTOMER.CUSTOMER_ID">
<w:staticText id="staticText1" text="#{currentRow.value['CUSTOMER.CUSTOMER_ID']}"/>
</w:tableColumn>
<w:tableColumn headerText="DISCOUNT_CODE" id="tableColumn2" sort="CUSTOMER.DISCOUNT_CODE">
<w:staticText id="staticText2" text="#{currentRow.value['CUSTOMER.DISCOUNT_CODE']}"/>
</w:tableColumn>
<w:tableColumn headerText="ZIP" id="tableColumn3" sort="CUSTOMER.ZIP">
<w:staticText id="staticText3" text="#{currentRow.value['CUSTOMER.ZIP']}"/>
</w:tableColumn>
<w:tableColumn headerText="NAME" id="tableColumn4" sort="CUSTOMER.NAME">
<w:staticText id="staticText4" text="#{currentRow.value['CUSTOMER.NAME']}"/>
</w:tableColumn>
<w:tableColumn headerText="ADDRESSLINE1" id="tableColumn5" sort="CUSTOMER.ADDRESSLINE1">
<w:staticText id="staticText5" text="#{currentRow.value['CUSTOMER.ADDRESSLINE1']}"/>
</w:tableColumn>
<w:tableColumn headerText="ADDRESSLINE2" id="tableColumn6" sort="CUSTOMER.ADDRESSLINE2">
<w:staticText id="staticText6" text="#{currentRow.value['CUSTOMER.ADDRESSLINE2']}"/>
</w:tableColumn>
<w:tableColumn headerText="CITY" id="tableColumn7" sort="CUSTOMER.CITY">
<w:staticText id="staticText7" text="#{currentRow.value['CUSTOMER.CITY']}"/>
</w:tableColumn>
<w:tableColumn headerText="STATE" id="tableColumn8" sort="CUSTOMER.STATE">
<w:staticText id="staticText8" text="#{currentRow.value['CUSTOMER.STATE']}"/>
</w:tableColumn>
<w:tableColumn headerText="PHONE" id="tableColumn9" sort="CUSTOMER.PHONE">
<w:staticText id="staticText9" text="#{currentRow.value['CUSTOMER.PHONE']}"/>
</w:tableColumn>
<w:tableColumn headerText="FAX" id="tableColumn10" sort="CUSTOMER.FAX">
<w:staticText id="staticText10" text="#{currentRow.value['CUSTOMER.FAX']}"/>
</w:tableColumn>
<w:tableColumn headerText="EMAIL" id="tableColumn11" sort="CUSTOMER.EMAIL">
<w:staticText id="staticText11" text="#{currentRow.value['CUSTOMER.EMAIL']}"/>
</w:tableColumn>
<w:tableColumn headerText="CREDIT_LIMIT" id="tableColumn12" sort="CUSTOMER.CREDIT_LIMIT">
<w:staticText id="staticText12" text="#{currentRow.value['CUSTOMER.CREDIT_LIMIT']}"/>
</w:tableColumn>
</w:tableRowGroup>
</w:table>
</w:form>
</w:body>
</ui:define>
</ui:composition>
</body>
</html>
view raw customers.xhtml hosted with ❤ by GitHub
The source code can be found on BitBucket here:WoodstockFaceletsExample

0 comments :

Popular Posts