1 / 4

JavaServer Faces: Common Mistakes

JavaServer Faces: Common Mistakes. Compiled from courses.coreservlets.com. Pressing Button and Nothing Happens. In JSF1, many error conditions simply result in the system redisplaying the form  JSF2 gives better help! No error messages or warnings

westbrook
Télécharger la présentation

JavaServer Faces: Common Mistakes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JavaServer Faces: Common Mistakes Compiled from courses.coreservlets.com

  2. Pressing Button and NothingHappens • In JSF1, many error conditions simply result in the system redisplaying the form  JSF2 gives better help! • No error messages or warnings • Very confusing to beginning developers • Debugging strategies for these situations • Many of the errors cause the process to abort at certain points. Knowing how far things got is very helpful. • Use print statements or IDE breakpoints • in the controller method • in the empty constructor • public MyBean() { System.out.println("MyBean built"); } • in the bean setter methods

  3. Pressing Button and NothingHappens: Common Cases • Return value of controller method does not match from-outcome of navigation-case • Remember values are case sensitive • Controller method returns null • This is often done on purpose to redisplay the form, but can be done accidentally as well. • Type conversion error • You declare field to be of type int, but value is not an integer when you submit. • Validation error • You declare field to be required and/or of certain length, but no/incorrect value is given when you submit. • Missing getter/setter method • You associate textfield with bean property foo, but there is no set/getFoomethod in your bean.

  4. Other Common Cases • Using from-action instead of from-outcome • Forgetting # in action of h:commandButton • Typo in from-view-id • Missing h:form • If you use h:inputText with no surrounding h:form, textfields will still appear but nothing will happen when you press submit button Use IDE’s autocomplete feature to help!

More Related