Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Not Null validation Not Working In Ui Component (programmatically)

Mohamed DEVOct 10 2017 — edited Oct 28 2017

version : Jdeveloper 11g r2

Below is a validator method which belongs to an attribute in a page ,but not working with me

Attribute Type =    String

validator         =    validatorStoreName()

but in case i change the if condition to be like this "if (newValue.length()>0 || newValue!=null ) " it works fine

public void validatorStoreName(FacesContext facesContext, UIComponent uIComponent, Object object) {
     

        FacesContext fc = FacesContext.getCurrentInstance();

        String newValue = (String)object;     


        if (newValue.length()==0 || newValue==null ) {


             System.out.println("null 1_____ "+"object= "+object+" newvalue= "+newValue);


             FacesMessage message =new FacesMessage(FacesMessage.SEVERITY_ERROR, "Null Value not allowed",null);


             fc.addMessage(uIComponent.getClientId(fc), message);


             ((RichInputText)uIComponent).setValid(false);
         }
         else {
             System.out.println("object= "+object+" newvalue= "+newValue);
         }
     }

Take in consideration " I'm beginner "

Thanks in advance

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 25 2017
Added on Oct 10 2017
15 comments
652 views