Book Image

Mastering JavaServer Faces 2.2

By : Anghel Leonard
Book Image

Mastering JavaServer Faces 2.2

By: Anghel Leonard

Overview of this book

Table of Contents (20 chapters)
Mastering JavaServer Faces 2.2
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
The JSF Life Cycle
Index

Writing contracts for composite components


In this section, you will see how to write contracts for composite components. For this, we will use the Temperature composite component developed in Chapter 10, JSF Custom Components. The implementation section in the code is given as follows:

<cc:implementation>
  <div id="#{cc.clientId}:tempconv_main">
    <h:outputLabel id="tempconv_smlabel" for="tempconv_selectonemenu" value="Convert to:"/>
    <h:selectOneMenu id="tempconv_selectonemenu" binding="#{cc.unittoI}">
      <f:selectItem itemValue="fahrenheit" itemLabel="fahrenheit" />
      <f:selectItem itemValue="celsius" itemLabel="celsius" />
    </h:selectOneMenu>
    <h:outputLabel id="tempconv_iflabel" for="tempconv_inputfield" value="Insert value:"/>
    <h:inputText id="tempconv_inputfield" binding="#{cc.temptI}"/>
    <h:commandButton id="tempconv_button" value="Convert">
      <f:ajax execute="@form" render="@form"/>
 ...