You are here: Home > Programming > Visual Web JSF

Visual Web JSF

Auto Validation is a method/process to check each text fields automatically for the success or error message and throwing the message according to that.

This document shows the process to be followed to do the automatic validation to the field and send the corresponding message. Steps followed are:

Create a Page: First of all open/create a JSF page.
Add Components: Add the Label and TextField component on the page.
Let the label component be Input and textfield component be tf.

Bind TextField: Add binding attribute for the textfield. Right click on the textfield and click Add binding attribute…
Create Link: Now Link the label and the textfield. For this just press ctrl+ shift and drop the label field on the text field.

Auto validate: Click on the textfield and then open the Property window. From Property window under Behavior click autoValidate.

Validate method: Now right-click on the textfield and click edit event handler  validate.

This will create a method in a java class which takes three objects as arguments viz: context: Facescontext, component: UIComponent, value: Object.

Throwing a message:

Finally you need to throw a message corresponding to the text field. For that you need to add a message component in your page. In the palette window go to standard and then inline message.

Inline Message: This is use to display message for single component, such as validation or conversion error. Creating a link between text field and inline message: So add inline message and create a link by pressing ctrl + shift and dropping the inline message on the text field

Write validation method:
Now we can write any validation function or call it inside a textfield_validate() method.

Be Sociable, Share!

Tags: , , , , , , , , , , , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

Leave a Reply