index.fm Page 699 Monday, April 2, 2007 12:46 PM

Chapter Index

A Action methods, roles of, 80 AbstractFacesBean, 580 Action states, 577 accept attribute, 101 actionListener attribute, 92, 285 h:form, 104 h:command and h:commandLink, 119 acceptcharset attribute, 101 and method expressions, 69, 396 h:form, 104 MethodBinding object, 385 Accept-Language value, 45 ActionLogger class, 286 Access control application: ActionMethodBinding, 386 directory structure for, 513 Actions, 275 messages.properties, 516 ActionSource interface, 361, 385, 387, 402 noauth.html, 514 ActionSource2 interface, 359, 361, 403 UserBean., 515 addDataModelListener(DataModelListener web.xml, 513–514 listener), 214 accesskey attribute, 101, 109 Address book application, EJBs, 606 h:command and h:commandLink, 120 ADF Faces components set (Oracle), 613 h:outputLink, 123 Ajax: selection tags, 132 basic, with an XHR object and a AccordionRenderer class, 551 servlet (application), 530–532 action attribute, 71 components, 546–554 h:command and h:commandLink, 119 Direct Web Remoting (DWR), 543–546 method expressions, 69, 73, 396 form completion, 534–537 MethodBinding object, 385 fundamentals of, 530–533 Action events, 33, 275–284 hybrid components, 546–551 firing, 268, 418–418 JSF-Rico accordion hybrid, 548–551 Action listeners, 385 realtime validation, 537–542 compared to actions, 275 Rico accordion, 546–551

699 index.fm Page 700 Monday, April 2, 2007 12:46 PM

700 Index

Ajax (cont): arg attribute, creditCardValidator, 659 transmitting JSP tag attributes to Arithmetic operators, 68 JavaScript code, 552–554 ArrayDataModel, 197 Ajax4jsf, 554–568 ASP.NET, 3 defined, 554 Attribute interface, 483 homepage, 554 Attribute map, 93, 361 implementing form completion with, attribute tag, 92 555–558 Attributes interface, 483 implementing realtime validation Authentication test application: with, 558–568 login.html, 512 AjaxFaces, 571 welcome.jsp, 511–512 aliasBean (MyFaces component), 614 AuthorSearchBean.java, 521–522 alt attribute, 101, 109 autocomplete attribute, 109 h:commandLink, 120 h:graphicImage, 118 B Alternate view technologies, 571, 585–596 Backing beans, 39, 53–54 Facelets custom tags, 594–596 getScoreComponent method, 54 JSF tags, using, 590–592 BackingBean.java, 262–264 jsfc attribute, 587–590 Basic authentication, 507 page composition with templates, BasicAttributes interface, 483 592–594 BasicAttributes object, 480 XHTML views, 585–587 BEA Workshop Studio, 21 Alternative renderers, 30 Beans: Amazon E-Commerce Service, 517 backing, 39 Amazon Web Services, 516–517 chaining definitions, 61–62 answerAction method, QuizBean class, 79 compatible scopes, 62 Ant, 671 configuring, 57–63 automation of the build process with, customizing in a GUI builder, 38 24–25 defined, 8, 37–39 installing a web application with, 27 definitions, chaining, 61–62 Validator project, 572, initializing lists and maps, 59–60 659 methods, 40 Apache MyFaces components, 612–614 naming pattern for property getters library, 653, 680 and setters, 40 Apache Shale project, 666, See Shale properties, 39–41 (Apache) property values, setting, 58–59 Applet example, index.jsp, 626–627 scopes, 54–57 Applets, 625–627 application scope, 56 chart applet, 627 life cycle annotations, 57 Application class, 362 request scope, 56 Application deployment, 688 session scope, 54–56 Application interface, 386, 404 session, 39 Application scope, 56, 66 string conversions, 62–63 applicationScope parameter, 67 uses of, 39 Apply Request Values phase, 33, 219, 238, value expressions, 41–42 295 syntax of, 64–69 immediate events, firing of, 287 beginEdit method, 609 JSF life cycle, 268–269 index.fm Page 701 Monday, April 2, 2007 12:46 PM

Index 701

bgcolor attribute: Book viewer with includes: h:dataTable, 176 bookHeader.jsp, 330 h:panelGrid, 163 book.jsp, 330 Bill pay wizard, 573–575 bookMenu.jsp, 331 Bill payment dialog, entering, 576 directory structure of, 329 Binary data application: Book.java, 324–325 BinaryData.java, 632 boolean (type), properties of, 40 BinaryPhaseListener.java, 637–638 border attribute, 101 BinaryServlet.java, 629, 631–632 h:dataTable, 176 ChartData.java, 633–636 h:panelGrid, 163 ChartRenderer.java, 630–631 h:selectOneRadio and index.jsp, 630 h:selectManyCheckbox, 135 BinaryData.java, 632 selection tags, 132 BinaryPhaseListener.java, 637–638 Brackets, 64–65 BinaryServlet.java, 629, 631–632 buffer (MyFaces component), 614 binding attribute, 94, 97–99, 109, 117 Build file, 25 corejsf:spinner, 358 build.properties, 26–27 h:column, 178 build.xml, 25–26 h:command and h:commandLink, 120 Business logic, 12 h:dataTable, 177 Buttons, 119–120 h:form, 104 byte validator, Struts, 668 h:graphicImage, 118 h:message and h:messages, 158 C h:outputLink, 123 C#, support for properties, 40 h:panelGrid, 164 Cagatay Civici’s client-side validation h:panelGroup, 165 package, 668 selection tags, 132 calendar (MyFaces component), 613 Book class, 319–320 captionClass attribute, 180 Book viewer application, 316–339 h:dataTable, 176 book bean properties, 318–319 h:panelGrid, 164 bookContent.jsp, 331 Captions, 178–181 Book.java, 324–325 captionStyle attribute, 180 book.jsp, 322–323 h:dataTable, 176 common content inclusion, 326 h:panelGrid, 164 content inclusion in JSP-based cellpadding attribute: applications, 326–327 h:dataTable, 176 directory structure, 322 h:panelGrid, 163–164 with extended tile directory structure, cellspacing attribute: 337 h:dataTable, 176 book.jsp, 339 h:panelGrid, 163–164 headerMenuContentLayout.jsp, 338 ChangeLocaleBean class, 292–293, 294 tiles.xml, 338 chapterKeys property, book viewer, 319 faces-config.xml, 323–324 charset attribute, 101 JSF-specific considerations, 327–328 h:command button and h:commandLink, 119 messages.properties, 325 h:outputLink, 123 monolithic JSF pages, 320–321 Chart applet, 627 styles.css, 325–326 ChartData.java, 633–636 ChartRenderer.java, 630–631 index.fm Page 702 Monday, April 2, 2007 12:46 PM

702 Index

Checkboxes, 133–135 Component trees, 30 checkPassword method, 69 Components: Child components: showing/hiding, 653–654 and facets, 408 validating relationships between, 669 map of, 360 Components application: Choice format, 44 directory structure for, 183 Class.getResourceAsStream, 678 faces-config.xml, 185 clearCityAndState method, 557 index.jsp, 183–185 Client-side validation tag, writing, messages.properties, 186 658–666 Composite expressions, 68–69 Client-side validator application: com.sun.jndi.ldap.LdapCtxFactory, 489 CreditCardValidator.java, 661–663 Conditional rendering, JSF HTML tags, index.jsp, 665–666 100–101 UIValidatorScript.java, 663–665 Configuration file, locating, 673 Client-side view state, propagating, Configuration information management, 542–543 483–504 cn attribute, LDAP, 474 configuring a bean, 484–485 cols attribute, 109–110 container-managed resources, 487–491 Column headers and footers, specifying, external context, 486–487 178–181 Connection object, 451 columnClasses attribute, 189, 190 Container-managed authentication and h:dataTable, 176, 189 authorization, 505–516 h:panelGrid, 163–164 Container-managed resource, 462–463 Columns, applying styles to, 189 Context interface, 482 columns attribute, h:panelGrid, 163 Conversation scope, 608–609 com.corejsf package, 8 Conversion, 219–220 com.corejsf.CreditCard, 257 custom converters, programming com.corejsf.message, 43 with, 240–254 com.corejsf.Spinner, 388 of numbers and dates, 221–222 com.corejsf.TableData, 173 Conversion error messages, standard, 229 com.corejsf.UserBean, 17 Conversion errors, 225–230 com.corejsf.util, 247–248 custom error message, using, 228 com.corejsf.util.Messages, 248 error messages, displaying, 226–228 Command buttons, using, 121–122 reporting, 245 Command links, using, 125–130 standard conversion error messages, commandButton, 95 changing the text of, 228–230 commandLink, 95 convertClientId method, 390 Common layouts, 315–316 convertDateTime, 92 Commons file upload library (Apache), Converter application, 230–233 614 CreditCardConverter.java, 241–243 Commons logging (Apache), 691 CreditCard.java, 243 Commons Validator, 668 directory structure of, 231 Compatible bean scopes, 62 index.jsp, 231–232 Component families, 388–389 Messages.java, 248–250 of standard component classes, 389 messages.properties, 233 Component tag classes, responsibilities PaymentBean.java, 233 of, 376 result.jsp, 232–233 index.fm Page 703 Monday, April 2, 2007 12:46 PM

Index 703

converter attribute, 97–99, 109, 117, 224 Custom converter application, 250–254 h:outputLink, 123 Custom converter application (and selection tags, 132 saving state): Converter interface, 240, 245 CreditCardConverter.java, 438–440 Converter object, 260 directory structure of, 437 ConverterELTag, 434–435 faces-config.xml, 440–441 ConverterException, 240–241, 245, 246 result.jsp, 437–438 converterMessage attribute, 97, 109, 228 Custom converter classes, implementing, selection tags, 132 240–254 Converters, 92 directory structure of, 251 and attributes, 223–224 faces-config.xml, 253 defined, 240 index.jsp, 251–252 specifying, 243–245 messages.properties, 250, 254 and spinner component, 369–370 PaymentBean.java, 254 supplying attributes to, 260–261 result.jsp, 252 convertNumber, 92 Custom converter tags, 432–441 cookie parameter, 67 converter.tld, 432 Cookies, 55 CreditCardConverterTag.java, 434 coords attribute, 101 custom error message, using, 228 h:commandLink, 120 Custom validator application: h:outputLink, 123 directory structure of, 443 Core Java 2 (Horstmann/Cornell), 4, 62, faces-config.xml, 446–447 247, 451 index.jsp, 448–449 corejsf.com, 4, 5 RegexValidator.java, 444–445 corejsf-examples directory, 25, 28 RegexValidatorTag.java, 445–446 corejsf:spinner, attributes, 358 validator.tld, 447–448 countryChanged method, 267 Custom validator classes, implementing, createSubcontext method, 480–481 254–257 Credit card formats, 241 Custom validator tags, 441–449 CreditCardConverter.java, 241–243 Custom validators, registering, 257–259 CreditCard.java, 243 Customized error display, 656 CreditCardValidator.java, 256–257, 659, 661–663 creditCard validator, Struts, 668 Data conversion, 29 CSS styles, 99–100 Data model filter, 204 encoding, 413–414 Data source, 451 currencyCode attribute, f:convertNumber, 223 Data table tag, 171–177 currencySymbol attribute, f:convertNumber, Data tables, 170–216 223 simple table example, 173–176 Custom component tags: directory structure for, 173 implementing, 372–382 faces-config.xml, 175 spinner.tld, 374–375 index.jsp, 174 tag handler class, 376–379 message.properties, 176 TLD file, 372–375 Name.java, 174 Custom components, 29, 355 Table.java, 175 classes for implementing, 356–362 Database access, with JDBC, 451–456 developer’s toolbox, 360–361 connection leaks, plugging, 453–455 index.fm Page 704 Monday, April 2, 2007 12:46 PM

704 Index

Database access, with JDBC (cont): library source, finding, 697 connection management, 453 stack trace, deciphering, 684–687 container-managed resource, “stack trace from Hell,” avoiding, 687 462–463 stuck page, 696–697 data source, configuring, 457–473 decode method, 367 database application, 464–73 Decoding, 32, 366–372 GlassFish, configuring a database Decoding requests, 32 resource in, 457–459 Deferred evaluation of expressions, 42 prepared statements, using, 455–456 Delete application: SQL statements, issuing, 451–452 directory structure for, 200 Tomcat 5, configuring a database index.jsp, 200–201 resource in, 459–462 Name.java, 201–202 Database application, 464–473 TableData.java, 202–203 authentication error screen, 465 deleteNames method, 199 directory structure for, 193, 467 Dependency injection, 526 error.jsp, 469 destroySubcontext method, 481 faces-config.xml, 470–471 Development environments, 21–28 index.jsp, 467–468 DHTML event attributes, 102–103 internal error screen, 465 DialogLauncher class, 579–580 login screen, 464 Dialogs, 572 navigation map, 467 dir attribute, 101, 109, 117 sorry.jsp, 469 h:command and h:commandLink, 120 UserBean.java, 471–473 h:dataTable, 176 welcome screen, 464 h:form, 104 welcome.jsp, 468 h:graphicImage, 118 Database tables, 191–197 h:message and h:messages, 158 CustomerBean.java, 195–196 h:outputLink, 123 displaying, 192 h:panelGrid, 164 index.jsp, 194–195 selection tags, 132 JSTL Result class, 197 DirContext interface, 482 messages.properties, 197 DirContextFactory.java, 490 web.xml, 196 Direct Web Remoting (DWR), 543–546 dataList (MyFaces component), 614 homepage, 544 DataModel.getWrappedData method, 198 using, 545–546 dataScroller (MyFaces component), 614 Directory context, 479 dataTable (MyFaces component), 96, 614 Directory deployment, 688 Date validation application: Directory structure: BackingBean.java, 262–264 JSF applications, 9–10 directory structure of, 262 sample WAR file, 10 index.jsp, 264 Directory tree, 475 date validator, Struts, 668 disabled attribute, 101, 109 Dates, conversion of, 221–222 h:command button, 120 dateStyle attribute, f:convertDateTime, 224 h:outputLink, 123 dc attribute, LDAP, 474 selection tags, 132 Debugging, 684–697 disabledClass attribute: application deployment, 688 h:selectOneRadio and commenting out a part of a JSF page, h:selectManyCheckbox, 135 689 selection tags, 132 index.fm Page 705 Monday, April 2, 2007 12:46 PM

Index 705

Distinguished name, 473 Error page application: dn attribute, LDAP, 474 ErrorBean.java, 657–658 DOCTYPE declaration, 17 errorDisplay.jsp, 657 document.forms[id] in JavaScript, web.xml, 656–657 obtaining, 678 Error pages: Dojo, 546 customizing, 654–658 done.jsp page, 79 example of, 685 driverClassName database pool parameter, ErrorBean class, 655 Tomcat, 461 ErrorBean.java, 657–658 DTD (DOCTYPE declaration), 20 errorClass attribute, h:message and Dynamic navigation, 73–84 h:messages, 157 Dynamic reloading, 688 errorDisplay.jsp, 655 errorPage directive, 655 E errorStyle attribute, h:message and Eclipse, 21 h:messages, 157 integration of Java Studio Creator into, escape attribute, 117 24 EvaluationException, 686 XMLBuddy plugin, 17 Event handling, 266–313 EditableValueHolder interface, 361, 368– life cycle events, 268–269 369, 387, 402 Event listener tags, 285–286 Editing table cells application, 186–189 Event scope, 603 index.jsp, 188 Exadel Studio, 21 messages.properties, 189 executeQuery method, 452 @EJB and @EJBs annotations, 463 executeUpdate method, 452 EJB3, 596 Exploded directory, 688 EJB (Enterprise JavaBeans) integration, External renderers: 571–572, 596–606 calling converters from, 393–394 email validator, Struts, 668 using, 387–393 empty operator, 68 ExternalContext interface, 368, 487 enabledClass attribute: h:selectOneRadio and F h:selectManyCheckbox, 135 Facelets, 571, 585, 585–596 selection tags, 132 custom tags, 594–596 encode method, 639 JSF tags, using, 590–592 encodeBegin method, 362, 659 jsfc attribute, 587–590 encodeChildren(), 362 page composition with templates, encodeEnd(), 362 592–594 Encoding, 31, 362–366 XHTML views, 585–587 JavaScript, to avoid server roundtrips, faces-config.xml, 16–18, 22, 57 404–407 book viewer application, 323–324 enctype attribute, h:form, 104 components application, 185 End state, 572 custom converter application (and Error messages, 684 saving state), 440–441 getting from resource bundles, 246– custom converter sample application, 250 253 Error messages caused by conversion, custom validator application, 446–447 displaying, 226–228 database application, 470–471 index.fm Page 706 Monday, April 2, 2007 12:46 PM

706 Index

faces-config.xml (cont.): uploadImage.jsp, 623 Java Quiz application, 83–84 UploadRenderer.java, 620–622 JSF applications, 16–18 UploadTag.java, 622–623 library, 352 fileUpload (MyFaces component), 614 news service application, 501–503 findCreditCardValidators method, 659 number quiz, 52–53 first attribute, h:dataTable, 176 phase listener application, 302–303 f:loadBundle, 43, 56, 589 popup application, 652–653 float validator, Struts, 668 Rushmore application, 282–283 floatRange validator, Struts, 668 sorting application, 213 footerClass attribute, 179, 189 spinner application, 381–382 h:column, 178 spinner example (revisited), 401–402 h:dataTable, 176, 189 text fields and text areas application h:panelGrid, 163 (personal data application), 116 Footers, 178–181 UserBean instance, 39 for attribute, h:message and h:messages, 158 value change application, 274 Form completion, 534–537 web service test application, 521, 523– Form data, 32 524, 527 Form elements, and JavaScript, 105–106 FacesContext class, 248, 361 form tag, 95 FacesContext interface, 365–366, 368, 386, Form-based authentication, 507 404, 435, 487 formBean.java, 300–301 facesContext parameter, 67 Forms, 103–108 FacesEvent interface, 270 h:form, attributes for, 104 FacesMessage interface, 245 f:param, 292 FacesMessage object, 245 attributes for, 94 FacesTrace, 696–697 frame attribute: Facet components, 94 h:dataTable, 177 map of, 360–361 h:panelGrid, 164 facet tag, 92 Frames, 315 Facets, processing, 412–413 from-action element, 87 f:actionListener, 285 from-outcome element, 87 Fade Anything Technique library, 534 f:setPropertyActionListener, 293–294, 294 failure.jsp page, 79 f:validateDoubleRange, 235, 236 fatalClass attribute, h:message and f:validateLength, 235, 236 h:messages, 157 f:validateLongRange, 235, 236 fatalStyle attribute, h:message and f:validator, 235, 236 h:messages, 158 f:valueChangeListener, 285–286 f:attribute, 292–293 f:view element, 45 attributes for, 94 f:convertDateTime, attributes of, 224 G f:converter, 244 get method, 40 f:convertNumber, attributes of, 223 getAsString method, 241 f:convertNumber converter, 229 getCityAndStateForZip method, 545 f:facet, attributes for, 94 getConvertedValue method, 390 File upload application: getErrorMessage method, 659 directory structure for, 617 getExpressionString method, 385 UploadFilter.java, 617–619 getIncrementedValue method, 367 index.fm Page 707 Monday, April 2, 2007 12:46 PM

Index 707

getJSFState function, 542 all other component tags, 172 getMessage, 248 attributes for, 176–177 getName method, 64 specifying CSS classes, 189 getPassword method, 40 and model classes, 197 getPhaseId method, 295 value attribute, 99 getRendersChildren method, 362, 390 header parameter, 67 getRowCount(), 214 headerClass attribute, 179, 189 getRowData(), 214 h:column, 178 getRowIndex(), 214 h:dataTable, 177, 189 getURL method, 40 h:panelGrid, 164 getWrappedData method, 198–199, 214 Headers, 178–181 GlassFish, 5 applying styles to, 189 activating JSF container logging in, Headers and footers application: 694 index.jsp, 180–181 adding a single JAR file, 11–12 messages.properties, 181 administration interface, 689–690 headerValues parameter, 67 asant tool, 25 height attribute, h:graphicImage, 118 configuring a database resource in, h:form, attributes for, 104 457–459 h:graphicImage, 116–117 configuring an LDAP resource, 488– attributes for, 118 489 examples, 118 dynamic reloading, 688 Hibernate, 596 life cycle annotations, 57 Hidden fields, 112, 265 log viewer, 691 and tabbed pane component, 415 setting the logging level in, 695 Hierarchical database, defined, 473 logs, 689 h:inputSecret, 8, 108 realm configuration, 508 examples, 110–111 shutting down, 6 h:inputText, 8, 108, 187 starting, 5–6 examples, 110 welcome page, 6 value attribute, 99 globalOnly attribute, h:message and h:inputTextarea, 108 h:messages, 158 examples, 111–112 Google Maps, 529 h:message, 227, 234 graphicImage, 95 attributes for, 157–158 groupingUsed attribute, f:convertNumber, h:messages, 160, 228, 234 223 attributes for, 157–158 h:outputFormat, 44, 116–117 H attributes for, 117 h:column, 172 h:outputLink, 119 attributes for, 178 attributes for, 123 h:commandButton, 8, 119 examples, 124 attributes for, 119–120 h:outputText, 14, 116–117, 187 h:commandButton, 14 attributes for, 117 examples, 121 examples, 118 h:commandLink, 119, 305 h:panelGrid, 164–165, 181, 331 attributes for, 119–120 attributes for, 163–164 examples, 122 h:panelGroup, 181 h:dataTable, 171–177, 182, 599 attributes for, 165 index.fm Page 708 Monday, April 2, 2007 12:46 PM

708 Index

hreflang attribute, 101 image attribute, h:command button and h:commandLink, 120 h:commandLink, 119 h:outputLink, 123 Image map sample component, 625 h:selectBooleanCheckbox, 130–132 image property, book viewer, 319 attributes, 132 Images, displaying, 116–119 selection tag example, 131 immediate attribute, 109–110 h:selectManyCheckbox, 130–132 h:command button and h:commandLink, 120 attributes, 132 selection tags, 132 attributes for, 135 Immediate components, 287–290 selection tag example, 131 command components, 290 h:selectManyListbox, 130, 136, 145–146 input components, 288–290 attributes, 132 Immediate evaluation of expressions, 42 selection tag example, 131 Implementation: h:selectManyMenu, 130, 136 JSF, 13–14 attributes, 132 indexed properties, 41 selection tag example, 131 index.html, 20–21 h:selectOneListbox, 130, 136 index.jsp, 79 attributes, 132 binary data application, 630 selection tag example, 131 client-side validator application, h:selectOneMenu, 130, 136 665–666 attributes, 132 components application, 183–185 selection tag example, 131 converter application, 231–232 h:selectOneRadio, 130 custom converter sample application, attributes, 132 251–252 attributes for, 135 custom validator application, 448–449 selection tag example, 131 database application, 467–468 HTML DOCTYPE declaration, 16 database tables, 194–195 HTML frames, 315 date validation application, 264 HttpServletRequest, 516 delete application, 200–201 editing table cells application, 188 I headers and footers application, IBATIS, 596 180–181 ICEfaces, 613 Java Quiz application, 82 id attribute, 94, 97–99, 109, 117 JavaScript application, 107–108 corejsf:spinner, 358 Luhn check application, 258–259 h:column, 178 messages application, 161–162 h:commandbutton and h:commandLink, 120 news service application, 494–495 h:dataTable, 177 number quiz, 50–51 h:form, 104–105 pager application, 643 h:graphicImage, 118 panels application, 167 h:message and h:messages, 158 phase listener application, 299–300 h:outputLink, 123 popup application, 647–648 h:panelGrid, 164 Rushmore application, 278 h:panelGroup, 165 sorting application, 207–208 selection tags, 132 spinner application, 380 IDEs (integrated development text fields and text areas application environments), 4 (personal data application), 114 index.fm Page 709 Monday, April 2, 2007 12:46 PM

Index 709

validation application, 239–240 faces-config.xml, 83–84 value change application, 271–272 index.jsp, 82 web service test application, 524 message strings, 84 infoClass attribute, h:message and messages.properties, 84 h:messages, 158 navigation rule, 80–81 infoStyle attribute, h:message and Problem.java, 76 h:messages, 158 questions, 74–75 InitialDirContext interface, 482 QuizBean.java, 77–78 initParam parameter, 67 transition diagram, 81 inputDate (MyFaces component), 613 Java serialization, 416 inputHidden, 95 Java Studio Creator, 24, 613 inputHtml (MyFaces component), 613 Java Web Services Developer Pack inputSecret, 95 (JWSDP), 520 inputText, 95 JavaBeans, 12–13, See also Beans inputTextarea, 95 classic application for, 38 integer validator, Struts, 668 defined, 37–39 integerOnly attribute, f:convertNumber, 223 origin of term, 38 Integrated Development Environments Java-compatible mnemonic for digits of (IDEs), 21–22 π, 46 Internationalization, 29 javaquiz.war, application configuration support, in Java, 43 file with the navigation rules, intRange validator, Struts, 668 80 Invoke Application phase, 35, 275 JavaScript: JSF life cycle, 268 encoding to avoid server roundtrips, ismap attribute, h:graphicImage, 118 404–407 isRowAvailable(), 214 example directory structure, 107 Items, 138–144 keeping out of renderers, 551–552 f:selectItem tag, 138–140 using to access form elements, 105–106 f:selectItems tag, 140–142 JavaScript application: item groups, 142–144 index.jsp, 107–108 ItemSearch operation, Amazon messages.properties, 108 E-Commerce Service, 517–518 JavaScript libraries: ItemSearchRequest, 518–519 Fade Anything Technique library, 534 ItemSearchResponse, 521 Prototype library, 533 JavaServer Faces, and JavaScript, 105–106 J JavaServer Pages Standard Template Jarek Gawor’s LDAP Browser/Editor, Library, 42 477 java.util.Locale.getISOCountries(), 216 Java BluePrints, 613 javax.el.ValueExpression, 404, 435 conventions, 10 javax.faces.application.Application, 386, Java Database Connectivity, See JDBC 404 (Java Database Connectivity) javax.faces.application.FacesMessage, 245 Java EE (Java Enterprise Edition), 4 javax.faces.component.ActionSource, 387, standard, 4 403 tutorial, 624 javax.faces.component.ActionSource2, 403 Java Quiz application, 74–84 javax.faces.component.EditableValueHolder, directory structure of, 80 368–369, 387, 402 done.jsp, 82–83 javax.faces.component.StateHolder, 418 index.fm Page 710 Monday, April 2, 2007 12:46 PM

710 Index

javax.faces.component.UIComponent, 260, javax.naming.directory.InitialDirContext, 364–365, 366, 368, 379, 404, 413 482 javax.faces.component.UIViewRoot, 248 javax.naming.NamingEnumeration, 483 javax.faces.component.ValueHolder, 371, 403 javax.servlet.HttpServletRequest, 516 javax.faces.CONFIG_FILES initialization javax.sql.DataSource, 457 parameter, 57 JDBC (Java Database Connectivity), javax.faces.context.ExternalContext, 368, database access with, 451–456 487 data source, configuring, 457–459 javax.faces.context.FacesContext, 248, 365, database access with, 451–456 368, 386, 404, 435, 487 connection leaks, plugging, void responseComplete(), 541 453–455 javax.faces.context.ResponseWriter, connection management, 453 365–366 container-managed resource, javax.faces.convert.Converter , 245 462–463 javax.faces.event package, 270 data source, configuring, 457–473 javax.faces.event.EditableValueHolder, database application, 464–73 Validator[] getValidators(), 541 javax.faces.event.FacesEvent, 270 GlassFish, configuring a database javax.faces.event.MethodExpression- resource in, 457–459 ActionListener, 403 prepared statements, using, javax.faces.event.MethodExpressionValue- 455–456 ChangeListener, 402 SQL statements, issuing, 451–452 javax.faces.event.ValueChangeEvent, 270, Tomcat 5, configuring a database 403 resource in, 459–462 javax.faces.model package, model classes, SQL statements, issuing, 451–452 197 JDK (Java SE Development Kit) 5.0, 4 javax.faces.model.DataModel, 197, 214 JNDI (Java Naming and Directory javax.faces.model.SelectItem, 414 Interface), 462–463 javax.faces.model.SelectItemGroup, 144 JNDI tutorial, 481 javax.faces.render.Renderer class, jscookMenu (MyFaces component), 613 methods, 390 JSF applications: javax.faces.validator.MethodExpression- advanced, 9 Validator, 403 application analysis, 12–21 javax.faces.validator.Validator interface, beans, 12–13 254–256 JSF pages, 13–14 javax.faces.ViewState component, 542, navigation, 16–18 543 servlet configuration, 18–19 javax.faces.webapp.ConverterELTag, 434–435 welcome file, 20–21 javax.faces.webapp.UIComponentELTag, 379 building instructions, 10–11 javax.faces.webapp.UIComponentTag, 387 business logic, 12 javax.faces.webapp.ValidatorTag, 443–444 configuration file, 9 javax.naming.Context, 482 development environments for, 21–28 javax.naming.directory.Attribute, 483 directory structure, 9–10 javax.naming.directory.Attributes, 483 faces-config.xml file, 16–18 javax.naming.directory.BasicAttributes, index.html, 20–21 483 miscellaneous files, 9 javax.naming.directory.DirContext, 482 presentation layer, 12 index.fm Page 711 Monday, April 2, 2007 12:46 PM

Index 711

simple example of, 6–7 commenting out part of, 689 directory structure of, 10 parts of, 3 index.jsp, 7 promise of, 3 ingredients, 8–9 installation, 4–5 login screen, 6–7 tag libraries, 91–92 UserBean.java, 9 tags, 7 welcome screen, 8 trying out, 5 using with Eclipse, 669–673 source code, 10 JSF libraries (Sun Microsystems), 5, troubleshooting, 684–697 670–671 web.xml, 18–19 jsf-api, 697 .jsf extension, 19–20 jsflibs project: JSF (JavaServer Faces), See also JSF adding libraries to, 670 applications exporting libraries in, 671 built-in mechanisms for validations, including, 672 234 jsf-ri, 697 and client-side validation, 234 JSF-Rico accordion hybrid, 548–551 component hierarchy, 360 .jsp extension, 13 components, 182–186 JSP (JavaServer Pages), 3 in table cells, 182 JSR (Java Specification Request) 250, 57, components of, 4 299, 681 core tags, 92–94 jsValueChangeListener (MyFaces objects represented by, 93 component), 614 DataModel integration, 606–609 JXPlorer, 477 event handling and component code, 4 L expression language, extending, label attribute, 109 681–684 selection tags, 132 framework services, 28–30 lang attribute, 101, 109, 117 HTML tags, 94–119 h:command and h:commandLink, 120 attributes shared by, 96 h:dataTable, 177 basic attributes, 97 h:graphicImage, 118 categories of, 96 h:message and h:messages, 158 conditional rendering, 100–101 h:outputLink, 123 DHTML event attributes, 102–103 h:panelGrid, 164 HTML 4.0 pass-through attributes, selection tags, 132 101–102 languageCode attribute, 293 styles, 99–100 layout attribute: h:message h:messages implementation, 13–14 and , 158–159 h:panelGroup JSF 1.0, 5 , 165 h:selectOneRadio JSF 1.2, 4, 5 and h:selectManyCheckbox JSF DataModel integration: , 135 conversation scope, 608–609 selection tags, 132 LDAP (Lightweight Directory Access JSF Extensions project, 670, 674–675 Protocol), 473–483 life cycle, 33–35, 268 application, creating, 491–504 pager, scrolling with, 216 attributes, 473–474 pages, 12–13 browsers, 477 index.fm Page 712 Monday, April 2, 2007 12:46 PM

712 Index

LDAP (cont.): loadBundle, 93 directories, 473–474 Local values, validation of, 220 directory information, accessing, locale attribute: 479–482 f:convertDateTime, 224 directory tree, inspecting, 477 f:convertNumber, 223 distinguished name, 473 library (Apache), 691, 696 LDAP server, configuring, 474–475 logAbandoned database pool parameter, object classes, 473 Tomcat, 461 sample.ldif, 478–479 Logging, 684–697 ldapadd tool, 477 of the JSF container, turning on, LDIF (Lightweight Directory Interchange 692–693 Format), 476 request parameters, 691–692 Library, 339–353 Logical operators, 68 bookContent.jsp, 350 login/web/index.html, 20–21 bookHeader.jsp, 350 Logs, finding, 689–690 Book.java, 349 longdesc attribute, h:graphicImage, 118 bookMenu.jsp, 350 Luhn check application: bookSelector.jsp, 344, 346 directory structure of, 258 corejsf/Library.java, 346–347 index.jsp, 258–259 directory structure, 341 Luhn formula, 255 faces-config.xml, 352 lvalue mode, 64 Library.java, 344–346 Lynx, using to test a web application, 510 library.jsp, 342–343 libraryLayout.jsp, 344 M LibraryTileController.java, 348 managed-bean element, 58 messages.properties, 353 managed-bean-class tag, 17 nested tiles, 339–340 Map interface, 65 styles.css, 350–351 Maps, initializing, 59–60 tile controllers, 341 mask validator, Struts, 668 tiles.xml, 343 maxActive database pool parameter, web.xml, 352 Tomcat, 461 Library application, 316, 318 maxFractionDigits attribute, Library source, finding, 697 f:convertNumber, 223 LibraryTileController.java, 348 maxIdle database pool parameter, Tomcat, Life cycle, 33–35 461 JSF, 33–35, 268 maximum attribute, corejsf:spinner, 358 Life cycle annotations, 57 maxIntegerDigits attribute, f:convertNumber, Life cycle events, 268–269 223 Lightweight Directory Access Protocol, maxlength attribute, 101, 109 See LDAP (Lightweight maxlength validator, Struts, 667 Directory Access Protocol) Menus, 136–138 Links, 119–120 message attribute, creditCard validator, 659 ListDataModel, 197 Message bundles, 42–46 Listeners, 361 application locale, setting, 45–46 Lists, initializing, 59–60 declaring, 42 load method, java.util.Properties class, localized bundle files, 43 42 messages with variable parts, 44 index.fm Page 713 Monday, April 2, 2007 12:46 PM

Index 713

MessageFormat class, 44, 247 minFractionDigits attribute, Messages, 95, 157–163 f:convertNumber, 223 Messages application: minimum attribute, corejsf:spinner, 358 directory structure of, 161 minIntegerDigits attribute, f:convertNumber, index.jsp, 161–162 223 messages.properties, 162 minlength validator, Struts, 668 styles.css, 162 Model, defined, 28–29 Messages class, 248 Model-view-controller architecture, Messages.java, 248–250 28–29 messages.properties: more.jsp page, 79 access control application, 516 Multiple matching wildcard rules, 86 book viewer application, 325 MyEclipse, 21 components application, 186 converter application, 233 N custom converter sample application, name attribute, 94 250, 254 Name class, 173 database tables, 197 Name.java, 174, 201–202, 211 editing table cells application, 189 Naming patterns, defining properties headers and footers application, 181 with, 40 Java Quiz application, 84 NamingEnumeration class, 480 JavaScript application, 108 native2ascii, 43 library, 353 Navigation, 71–88 messages application, 162 advanced issues, 84–88 number quiz, 53 algorithm, 87–88 panels application, 167 from-action element, using, 87–88 personal information application, 156 redirection, 85–86 phase listener application, 303 static, 71–73 Rushmore application, 284 syntax diagram for elements, 85 sorting application, 214 wildcards, 86–87 spinner application, 382 Navigation elements, syntax diagram for, tabbed pane application, 309–310 85 text fields and text areas application Navigation handler, 71 (personal data application), 116 navigation-case element, 84 web service test application, 526 structure of, 87 META-INF directory, 10 navigation-rule element, 84 Method expressions: Nested tiles, 339–340 in an action attribute, 73 NetBeans, 21–22 handling, 385–386 guide for getting started with, 21 processing, 396 HTTP monitor, 693 supporting, 396–397 integration of Java Studio Creator into, syntax rules, 69 24 MethodBinding object, attributes, 385 using for JSF debugging, 22 MethodExpressionActionListener interface, News service application, 491–504 403 directory structure of, 493 MethodExpressionValidator interface, 403 faces-config.xml, 501–503 MethodExpressionValueChangeListener, 402 index.jsp, 494–495 Microsoft Active Directory, 474 login screen, 492 Microsoft ASP.NET, 3 loginError.jsp, 497 index.fm Page 714 Monday, April 2, 2007 12:46 PM

714 Index

News service application (cont.): selection tags, 132 main screen, 493 onfocus attribute, 103, 109 Name.java, 504 h:command and h:commandLink, 120 page flow, 494 h:form, 104 registration screen, 492 h:outputLink, 123 signup.jsp, 495–496 selection tags, 132 UserBean.java, 497–500 onkeydown attribute, 103, 109 UserDirectoryBean.java, 500–501 h:command and h:commandLink, 120 welcome.jsp, 496 h:dataTable, 177 newspaperTable (MyFaces component), 614 h:form, 104 NullPointerException, 686 h:graphicImage, 118 Number quiz, 47 h:outputLink, 123 bean definitions, chaining, 61–62 h:panelGrid, 164 directory structure of, 50 selection tags, 132 faces-config.xml, 52–53 onkeypress attribute, 103, 109 index.jsp, 50–51 h:command and h:commandLink, 120 messages.properties, 53 h:dataTable, 177 messsages_de.properties, 53 h:form, 104 ProblemBean.java, 47–49 h:graphicImage, 118 QuizBean.java, 51–52 h:outputLink, 123 Numbers, conversion of, 221–222 h:panelGrid, 164 numChapters property, book viewer, 319 selection tags, 132 onkeyup attribute, 103, 109 O h:command and h:commandLink, 120 o attribute, LDAP, 474 h:dataTable, 177 Object classes, 473 h:form, 104 onblur attribute, 102, 109 h:graphicImage, 118 h:command and h:commandLink, 120 h:outputLink, 123 h:outputLink, 123 h:panelGrid, 164 selection tags, 132 selection tags, 132 onchange attribute, 102, 109, 269 onmousedown attribute, 103, 109 h:command and h:commandLink, 120 h:command and h:commandLink, 120 selection tags, 132 h:dataTable, 177 onclick attribute, 103, 109 h:form, 104 h:command and h:commandLink, 120 h:graphicImage, 118 h:dataTable, 177 h:outputLink, 123 h:form, 104 h:panelGrid, 164 h:graphicImage, 118 selection tags, 132 h:outputLink, 123 onmousemove attribute, 103, 109 h:panelGrid, 164 h:command and h:commandLink, 120 selection tags, 132 h:dataTable, 177 ondblclick attribute, 103, 109 h:form, 104 h:command and h:commandLink, 120 h:graphicImage, 118 h:dataTable, 177 h:outputLink, 123 h:form, 104 h:panelGrid, 164 h:graphicImage, 118 selection tags, 132 h:outputLink, 123 onmouseout attribute, 103, 109 h:panelGrid, 164 h:command and h:commandLink, 120 index.fm Page 715 Monday, April 2, 2007 12:46 PM

Index 715

h:dataTable, 177 panelGrid, 96 h:form, 104 panelGroup, 96 h:graphicImage, 118 panelNavigation (MyFaces component), h:outputLink, 123 613 h:panelGrid, 164 panelNavigation2 (MyFaces component), selection tags, 132 613 onmouseover attribute, 103, 109 Panels, 163–168 h:command and h:commandLink, 120 Panels application: h:dataTable, 177 directory structure for, 166 h:form, 104 index.jsp, 167 h:graphicImage, 118 message.properties, 167 h:outputLink, 123 styles.css, 168 h:panelGrid, 164 panelStack (MyFaces component), 614 selection tags, 132 param parameter, 67 onmouseup attribute, 103, 109 param tag, 92 h:command and h:commandLink, 120 paramValues parameter, 67 h:dataTable, 177 Passing data from the UI to the server, h:form, 104 291 h:graphicImage, 118 password database pool parameter, h:outputLink, 123 Tomcat, 461 h:panelGrid, 164 pattern attribute: selection tags, 132 f:convertDateTime, 224 onreset attribute, 103 f:convertNumber, 223 h:form, 104 Payment dialog, 579 onselect attribute, 103, 109 definition, 577 h:commandLink, 120 Payment information, displaying, 222 selection tags, 132 PaymentBean.java, 233, 254 onsubmit attribute, 103 @PersistenceContext and h:form, 104 @PersistenceContexts openldap, 508 annotations, 463 OpenLDAP server, 474–477 @PersistenceUnit and @PersistenceUnits Operator precedence, 68 annotations, 463 org.apache.shale.faces.AbstractFacesBean, Phase events, 295–303 580 defined, 295 ou attribute, LDAP, 474 firing of, 268 outputFormat, 95 Phase listener application: outputLabel, 95 directory structure for, 299–300 outputLink, 95 faces-config.xml, 302–303 outputText, 95 FormBean.java, 300–301 index.jsp, 299–300 P messages.properties, 303 Page beans, in Java Studio Creator, 54 PhaseTracker.java, 301–302 Pager, 638–639 styles.css, 303 Pager application: Phase listeners, 295, 679 BackingBean.java, 644 using, 296 index.jsp, 643 PhaseId getPhaseId(), 271, 295 PagerRenderer.java, 640–643 phaseListener, 92 Pager widgets, scrolling with, 216 PhaseListener interface, 295 index.fm Page 716 Monday, April 2, 2007 12:46 PM

716 Index

phaseTracker.java, 301–302 Project Gutenberg web site, 317 poolPreparedStatements database pool Properties, beans, 39–41 parameter, Tomcat, 461 Property editors, 62 Popup application: Property sheet dialog, 38 BackingBean.java, 651–652 Property values, setting, 58–59 faces-config.xml, 652–653 PropertyResolver, 683–684 index2.jsp, 649–650 Prototype, 534–536, 546 index.jsp, 647–648 Prototype JavaScript library, 533 popup2.jsp, 650–651 popup.jsp, 648–649 Q popup (MyFaces component), 614 QuizBean class, 75, 76 Pop-up window: QuizBean.java, 51–52, 77–78 displaying, 644 doPopup function, 644, 646 R generating, 644–653 Radio buttons, 133–135 POST request, 32, 542 Rational Application Developer, 21 @PostConstruct, 57, 679 readonly attribute, 101, 109 @PreDestroy, 57, 679 h:commandLink, 120 Preferred language, selecting, 45–46 selection tags, 132 Prefix mapping, 19 Realtime validation, Ajax, 537–542 Prefixes, tags, 7 Redirection, 85–86 prepareStatement method, 455–456 redisplay attribute, 109–110 prependId attribute, h:form, 104 RegexValidator.java, 444–445 Presentation layer, 12 RegexValidatorTag.java, 445–446 Problem class, 75 RegisterForm.java, 272–273 ProblemBean.java, 47–49 rel attribute, 101 Problem.java, 76 h:commandLink, 120 Process Validations phase, 34, 236, 270 h:outputLink, 123 JSF life cycle, 268 Relational operators, 68 processAction method, 286 removeAbandoned database pool parameter, Processing payments, 220–221 Tomcat, 461 Programming, 669–684 removeAbandonedTimeout database pool accessing resources from a JAR file parameter, Tomcat, 461 using a JSF component, 673–677 removeDataModelListener(DataModelListener cleanup work, carrying out, 679 listener), 214 configuration file, locating, 673 Render Response phase, 33, 35, 56 form ID for generating, 678 JSF life cycle, 268 initialization, carrying out, 679 rendered attribute, 97–98, 109, 117 JSF expression language, extending, corejsf:spinner, 358 681–684 h:column, 178 JSF, using with Eclipse, 669–673 h:command and h:commandLink, 120 packaging a set of tags into a JAR file, h:dataTable, 177 677–678 h:form, 104 request scope versus session scope, h:graphicImage, 118 680–681 h:message and h:messages, 158 suppressing multiple copies of a h:outputLink, 123 JavaScript function, 679 h:panelGrid, 164 index.fm Page 717 Monday, April 2, 2007 12:46 PM

Index 717

h:panelGroup, 165 , 680 selection tags, 132 rules attribute: Renderer, 31 h:dataTable, 177 Rendering pages, 30–31 h:panelGrid, 164 Request scope, 56, 66 Runtime expression value, 374 Request values, 219–220 Rushmore application, 276–277 processing, 366–372 directory structure for, 278 as strings, 220 faces-config.xml, 282–283 requestScope parameter, 67 index.jsp, 278 required attribute, 97–98, 109, 109–110, 235 jefferson.jsp, 279–280 selection tags, 132 lincoln.jsp, 279 required validator, Struts, 667 messages.properties, 284 requiredMessage attribute, 97, 109, 236 roosevelt.jsp, 280 selection tags, 132 Rushmore.java, 281–282 @Resource and @Resources annotations, 463 washington.jsp, 281 ResourceBundle.getBundle, 678 rvalue mode, 64 resource-bundle element, 43 Resource injection, 462 S annotations, 463 saveState method, 435 ResourcePhaseListener.java, 675–677 saveState (MyFaces component), 614 ResponseWriter class, 364 ScalarDataModel, 197 ResponseWriter interface, 365 schedule (MyFaces component), 613 Restore View phase, 33 Schema declaration, to define the syntax JSF life cycle, 268 of a configuration file, 17 result set, updating, 189 Scope, beans, 54–57 ResultDataModel, 197 application scope, 56 result.jsp: life cycle annotations, 57 converter application, 232–233 request scope, 56 custom converter application, 252, session scope, 54–56 437–438 Scriptaculous, 546 web service test application, 521, Scrollable div, 215 525–526 Scrollbar, scrolling with, 215–216 ResultSet class, 452 Scrolling techniques, 214–216 ResultSetDataModel, 197 scrolling with a scrollbar, 215–216 rev attribute, 102 scrolling with pager widgets, 216 h:commandLink, 120 Seam (JBoss), 571, 596–606 h:outputLink, 123 address book application, 596–600 Rico accordion, 546–548 addContact.jsp, 599 JSF-hybrid, 548–551 adding contacts to, 597–598 rico-script.jsf, 551 addressBook.jsp, 598 rowClasses attribute, 190 configuration, 601–603 h:dataTable , 177, 189 deleting contacts from, 599 h:panelGrid, 164 editContact.jsp, 599 Rows, applying styles to, 190–191 editing contacts, 599–600 rows attribute, 102, 109–110 h:dataTable, 177 framework, 681 rssTicker (MyFaces component), 614 stateful session beans, 603–606 selectBooleanCheckbox, 95 index.fm Page 718 Monday, April 2, 2007 12:46 PM

718 Index

Selection tags, 130–132 dialog support, 585 examples, 131 entering a dialog, 576–577 personal information application, features, 572 147–149 subdialogs, 583 faces-config.xml, 156 Shale Validator, 666–668 index.jsp, 149–150 instructions for, 666–667 messages.properties, 156 shape attribute, 102 RegisterForm.java, 152–155 h:commandLink, 120 h:outputLink showInformation.jsp, 151–152 , 123 ShoppingCartBean, 56 SelectItem children, processing, 411–412 short validator, Struts, 668 SelectItem interface, 93, 414 showDateAndTime function, 531–532 selectManyCheckbox, 95 showDetail attribute, h:message and selectManyListbox, 95 h:messages, 158 selectManyMenu, 95 showSummary attribute, h:message and selectOneListbox, 95 h:messages, 158 selectOneMenu, 95 Simple JavaServer Faces application, selectOneRadio, 95 welcome.jsp, 14–15 Serializable interface, 435 size attribute, 102, 109, 111 Server roundtrips, encoding JavaScript to selection tags, 132 avoid, 404–407 sn attribute, LDAP, 474 Servlet exception attributes, 655 SOAP (Simple Object Access Protocol), Servlet filter, 674 516–519 code for, 616 Software installation, JSF, 4–5 Servlet, using to locate resources, 674–675 SortFilterModel.java, 208–210 Session, 39, 55 Sorting application: Session scope, 54–56, 66 directory structure for, 206 disadvantages of, 680 faces-config.xml, 213 sessionCreated method, 679 index.jsp, 207–208 sessionDestroyed method, 679 messages.properties, 214 sessionScope parameter, 67 Name.java, 211 set method, 40 SortFilterModel.java, 208–210 setCityAndStateForZip method, 557 styles.css, 213 setName method, 64 TableData.java, 211–212 setPassword method, 40 Spinner: setPropertyActionListener, 92 encoding JavaScript to avoid server setRowIndex method, 204 roundtrips, 404–407 setRowIndex(int index), 214 JSSpinnerRenderer.java, 406–407 setupPaymentDialog method, 577, 579 setupWireTransferDialog method, 579 external renderers: setWrappedData method, 198–199 calling converters from, 393–394 setWrappedData(Object obj), 214 using, 387–393 Shale (Apache), 571, 680 method expressions, supporting, dialog configuration, 576 396–397 dialog context sensitivity, 580–583 value change listeners, supporting, dialog definition, 572–573 394–395 dialog navigation, 577 Spinner application, 379–383 dialog scope, 578–580 CreditCardExpiration.java, 381 index.fm Page 719 Monday, April 2, 2007 12:46 PM

Index 719

directory structure for, 379 Struts, 3, 295 faces-config.xml, 381–382 Struts client-side validators, 667–668 index.jsp, 380 Struts tags, 96 messages.properties, 382 style attribute, 102, 109, 117 next.jsp, 380–381 h:command and h:commandLink, 120 styles.css, 383 h:dataTable, 177 Spinner application (revisited): h:form, 104 directory structure of, 397 h:graphicImage, 118 faces-config.xml, 401–402 h:message and h:messages, 158 Renderers.java, 398–400 h:outputLink, 123 SpinnerTag.java, 400–401 h:panelGrid, 164 Spinner component, 355–356 h:panelGroup, 165 conversion failures, 357 selection tags, 132 and converters, 369–370 Style sheet, 100 corejsf:spinner, 358 styleClass attribute, 97–98, 109, 117 defined, 356 h:column, 178 integer values, 357 h:command and h:commandLink, 120 using, 357 h:dataTable, 177, 189 Spinner component library, directory h:form, 104 structure of, 678 h:graphicImage, 118 Spinner renderer application: h:message and h:messages, 158 SpinnerRenderer.java, 391–393 h:outputLink, 123 UISpinner.java, 391 h:panelGrid, 164 spinnerLib project, h:panelGroup, 165 ResourcePhaseListener.java, selection tags, 132 675–677 Styles, 189–191 SpinnerTag class, 376–377 by column, 190 SpinnerTag tag handler, SpinnerTag.java, by row, 190–191 378 stylesheet (MyFaces component), 614 Stack trace, deciphering, 684–687 Subdialogs, 583 “Stack trace from Hell,” avoiding, 687 Submitted value, 219 Standard conversion error messages, subview tag, 92 changing the text of, 228–230 summary attribute: Standard converters, 221–233 h:dataTable, 177 Standard validation error messages, h:panelGrid, 164 236–237 Sun Java Studio Creator, 22 Standard validators, 233–244 Sun Java System Directory Server, 474 bypassing validation, 237–238 sun-web.xml, 489, 508 displaying validation errors, 236 Syntax diagram, for the managed-bean required values, 235–236 elements, 60 string lengths and numeric ranges, validating, 234 T startElement method, 364 Tabbed pane, 304–305, 355–356 startOverAction method, 80 UITabbedPane.java, 417–418 StateHolder interface, 418, 435–436 Tabbed pane application: Static navigation, 71–73 directory structure for, 306, 425 String conversions, 62–63 faces-config.xml, 311, 430–431 rules, 63 index.jsp, 307–308, 425–426 index.fm Page 720 Monday, April 2, 2007 12:46 PM

720 Index

Tabbed pane application (cont.): Ternary ? selection operator, 68 lincoln.jsp, 309 Text areas, 108–109 messages.properties, 309–310 Text, displaying, 116–119 styles.css, 310–311, 431 Text fields, 108 TabbedPaneTag.java, 429–430 Text fields and text areas application tabbedpane.tld, 427–428 (personal data application), washington.jsp, 309 112–114 Tabbed pane component, 408–409 directory structure for, 113 action event fired by, 411 faces-config.xml, 116 action events, firing, 418–418 index.jsp, 114 and CSS styles, 409–410 messages.properties, 116 CSS styles, encoding, 413–414 thankYou.jsp, 115 facets, processing, 412–413 Tile controllers, 341 features of, 409 Tiles, 331–339 hidden fields, using, 415 extending, 335–336 SelectItem children, processing, installing, 332 411–412 nested, 339–340 state, saving and restoring, 415–418 parameterizing, 334–335 Tabbed pane renderer, reusing layouts, 331–332 TabbedPaneRenderer.java, 419–424 using with the book viewer, 333–334 tabbedPane (MyFaces component), 614 Tiles JAR file, 332 TabbedPaneRenderer.java, 419–424 timeStyle attribute, f:convertDateTime, 224 TabbedPaneTag.java, 429–430 timeZone attribute, f:convertDateTime, 224 tabindex attribute, 102, 109 title attribute, 102, 109, 117 h:command and h:commandLink, 120 h:command and h:commandLink, 120 h:outputLink, 123 h:dataTable, 177 selection tags, 132 h:form, 104 TableData.java, 202–203, 211–212 h:graphicImage, 118 TableData.names method, 205 h:message and h:messages, 158 Table.java, 175 h:outputLink, 123 Tables: h:panelGrid, 164 caption, example of, 179 selection tags, 132 cells, editing, 186–189 titleKey property, book viewer, 319 columns, sorting, 204 TLD file, 372–375 models, 197–214 Tomcat, 5, 596 editing, 198–203 common Tomcat database pool sorting and filtering, 203–214 parameters, 461 rows, deleting, 198 configuring logging output, 694–695 Tag handler class, 376–379 configuring a database resource in, Tag handlers, 30 459–462 in JSF 1.1, defining, 383–387 logs, 690 Tag suffix, 359 realm configuration, 508 Tags, 359 Tool support, 30 Tapestry, 590, 596 tooltip attribute, h:message and target attribute, 102 h:messages, 158 h:commandLink, 120 tree (MyFaces component), 613 h:form, 104 tree2 (MyFaces component), 613 h:outputLink, 123 treeColumn (MyFaces component), 613 index.fm Page 721 Monday, April 2, 2007 12:46 PM

Index 721

type attribute, 102 UserBean class, 40, 56 f:convertDateTime, 224 properties of, 12–13 f:convertNumber, 223 UserBean instance, 39 h:command and h:commandLink, 120 UserBean.java, 8, 471–473, 497–500, 686 h:outputLink, 123 UserDirectoryBean.java, 500–501 username database pool parameter, U Tomcat, 461 UI class, 359 UTF-8, message bundle files and, 43 UI prefix, 359 UICommand, 32, 33, 361, 389 V components, 33 validateDoubleRange, 92 UIComponent interface, 260, 364, 368, 379, validateLength, 92 386, 404, 413 validateLongRange, 93 UIComponentELTag interface (JSF 1.2), 379 Validation, 658–669 UIComponentTag interface, 387 with bean methods, 259–260 uid attribute, LDAP, 474 bypassing, 237–238 UIData, 172, 204, 389 client-side validation tag, writing, UIForm, 389 658–666 UIGraphic, 389 components, validating relationships UIInput, 32, 361, 389 between, 669 components, 33 custom validator classes, UIMessage, 389 implementing, 254–257 UIMessages, 389 custom validators, registering, 257–259 UIOutput, 361, 389 error messages, 236–237 UIPanel, 389 key role of, 233 UISelectBoolean, 389 of relationships between multiple UISelectMany, 389 components, 260–265 UISelectOne, 389 Shale Validator, 666–668 UISpinner class, 359, 387 Validation and error handling, 29 UISpinner.java, 369–371 Validation application, 238–240 UITabbedPane class, 359, 417 directory structure of, 239 instance field, 416 index.jsp, 239–240 UITabbedPane.java, 417–418 Validation process, 219–220 UIValidatorScript.java, 663–665 Validator application, UIViewRoot, 248 CreditCardValidator.java, setLocale method of, 45 256–257 Understanding and Deploying LDAP validator attribute, 92, 97–98, 99, 109 Directory Services (Howes), 473 and method expressions, 69, 396 Update Model Values phase, 34, 220 MethodBinding object, 385 JSF life cycle, 268 selection tags, 132 UploadFilter.java, 617–619 Validator interface, 254–256, 255, 256 UploadRenderer.java, 620–622 ValidatorException, 254 UploadTag.java, 622–623 validatorMessage attribute, 97, 109, 236 url attribute, h:graphicImage, 118 selection tags, 132 url database pool parameter, Tomcat, 461 Validators, 34, 385 URL rewriting, 55 custom, programming with, 254 usemap attribute, h:graphicImage, 118 implementing, 432–449 User conversation, 572 standard, 233–244 index.fm Page 722 Monday, April 2, 2007 12:46 PM

722 Index

validatorScript component, 659, 663 ValueExpression interface, 404, 435 ValidatorTag class, 442 ValueHolder interface, 361, 371, 403 ValidatorTag interface, 443–444 var attribute, h:dataTable, 177 value attribute, 94, 97–98, 109–110, 117 VariableResolver, 683–684 binding, 145 view parameter, 67 corejsf:spinner, 358 View states, 538, 577 h:column, 178 view tag, 92 h:command and h:commandLink, 120 Visual Basic, support for properties, 40 h:dataTable, 172, 177 Visual builder tools, 22–23 h:graphicImage, 118 h:outputLink, 123 W h:panelGrid, 164 WAR file, 9–10, 688 selection tags, 132 warnClass attribute, h:message and Value change application: h:messages, 158 directory structure for, 271 warnStyle attribute, h:message and faces-config.xml, 274 h:messages, 158 index.jsp, 271–272 Web application, using Lynx for testing, messages_en_CA.properties, 274 510 messages_en_US.properties, 274 Web flow, 571 RegisterForm.java, 272–273 Shale, 572–585 Value change events, 269–274 Web service test application: firing of, 267 AuthorSearchBean.java, 521–522 Value change listeners, supporting, directory structure of, 521 394–395 error.jsp, 525–526 Value expressions, 41–42 faces-config.xml, 521, 523–524, 527 a.b, evaluating, 65–66 index.jsp, 524 beans, 41–42 messages.properties, 526 syntax of, 64–69 result.jsp, 521, 525–526 brackets, 64–65 Web services, using, 516–527 composite expressions, 68–69 Web Tools Platform (WTP), 672 list expressions, 65–66 Web user interface design, 611–658 map expressions, 65–66 applets, 625–627 map of, 361 components, finding, 611–14 method expressions, 69 error pages, customizing, 654–658 predefined objects, 57 file uploads, supporting, 614–623 resolving the initial term, 66–67 image map, displaying, 623–625 and styles, 99 large data set, displaying, 638–644 syntax of, 64–69 pop-up window, generating, 644–653 ValueChangeEvent class, 270 produce binary data in a JSF page, ValueChangeEvent interface, 270, 403 627–638 valueChangeListener attribute, 92, 97–98, showing and hiding components, 109–110, 285–286 653–654 method expression, 69 Weblets project, 674 and method expressions, 396 @WebServiceRef and @WebServiceRefs MethodBinding object, 385 annotations, 463 selection tags, 132 Webwork, 596 ValueChangeListener interface, 286 web.xml, 18–19, 507 index.fm Page 723 Monday, April 2, 2007 12:46 PM

Index 723

welcome.jsp: Wizard, 572 authentication test application, writeAttribute method, 364 511–512 writeValidationFunctions method, 659, database application, 468 660–661 news service application, 496 WSDL (Web Service Description simple JavaServer Faces application, Language) format, 516–518 496 width attribute, 102 X h:dataTable, 177 XHTML views, 585–587 h:graphicImage, 118 XML syntax, 25 h:panelGrid, 164 XMLBuddy plugin, 17 Wildcards, 86–87 Wire transfer dialog, 579 Z Wire transfer subdialog, 575, 583–585 zipChanged function, 538, 543