Sunday, October 30, 2011

Work Around: Popup forces user to enter required values first

 

In my previous project I came across a typical problem While trying to enter value using pop up. The problem is If other required fields on same page are not entered and button/link for generating popup pressed , then an error message appears like below. It forces us to enter required values first.

image

As a work around I have used the option [immediate=true] for the button/link responsible for the pop up to be generated. Please follow below snap shot. Earlier command link selectText has no option set as [immediate=true] and we get above error.

image

After setting the option [immediate=true] for the command link selectText, above error resolved as we redeploy it.

image

Below screen shows that all required fields are empty but it is not prompting us to enter required fields while trying to open popup as user can enter data successfully in pop up and no restriction comes from required fields.

image

Saturday, October 29, 2011

Field Validation in ADF as user Tab out

In this blog I am trying to show validation as user tab out any field in ADF. User enter data in a form field and as he tab out the field validation happens and If validation criteria does not meet error message appears.

image

An ADF application has model and ViewController project. We can create the form in ViewController project. Please follow my previous blogs for the basics of Form generation in ViewController project. So rather than spending much time on the basics like Form generation , I would like to show special things I have done here to accomplish above goal.

Step1: Create a java class and implement javax.faces.validator.Validator,java.io.Serializable. Implementation of Validator will ask for the validate(FacesContext facesContext, UIComponent uiComponent,Object object) method to be Implemented. Here I have created a java class named EmailValidator. This java file can be downloaded from http://www.box.net/shared/cux283rmjp45cl8mry2x link. Similarly we can create another java file for date validation. Please download the same from http://www.box.net/shared/trtvicb7ihesdmy6hpzx link.

Step2: Declare these java files as validator in faces-config.xml file. Please refer below snapshot

image 

Step3: Modify your form so that it will not obey default validator and follow the custom validator you have created in step2. Please follow below entry in your jsff file.

image

Please download the jsff file from below link http://www.box.net/shared/8eb7hcm4qxq0330n3eme

Please deploy and it will work as expected.

image