Creating a Custom Validator

I follow the step in http://www.netbeans.org/kb/articles/jAstrologer-validate.html, I have a problem on Creating a Custom Validator, I always get error on Netbean , How the EmailValidator implements Validator in here , what concept I miss
package Hell.validator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
* @author root
public class EmailValidator implements Validator {
  public void validate(FacesContext facesContext,
            UIComponent uIComponent, Object value) throws ValidatorException {
        //Get the component's contents and cast it to a String
         String enteredEmail = (String)value;
        //Set the email pattern string
        Pattern p = Pattern.compile(".+@.+\\.[a-z]+");
        //Match the given string with the pattern
        Matcher m = p.matcher(enteredEmail);
        //Check whether match is found
        boolean matchFound = m.matches();
        if (!matchFound) {
            FacesMessage message = new FacesMessage();
            message.setDetail("Email not valid - The email must be in the format [email protected]");
            message.setSummary("Email not valid - The email must be in the format [email protected]");
            message.setSeverity(FacesMessage.SEVERITY_ERROR);
            throw new ValidatorException(message);
}

Darryl.Burke wrote:
Never heard of that error.Neither do I.

Similar Messages

  • Implementing Custom Validation Logic for Payment Disbursements

    Hi All,
    Is there anyone here, who has implemented Custom Validation Logic for disbursements in Oracle payments.
    Theory: Under Payments Setup Administrator -> Formats -> Formats, we can setup a payment format and even attach a XML template. Apart from this we can setup Pre-defined validations or user Defined validations.
    For Pre-defined validations / seeded validations, Oracle has provided an API
    IBY_VALIDATIONSETS_PUB.evaluateCondition. We can use this API, and call a custom package by using the keyword 'CUSTOM' in the call.
    Has anyone played around with this package and successfully implemented custom validations. Does anyone have a sample code on how to implement this. The Payment Manager Implementation guide is of little help.
    Thanks

    This document was very helpful to me in creating a custom validation.
    http://docs.oracle.com/cd/E18727_01/doc.121/e13416/T387353T419293.htm

  • How to highlight invalid component in custom validator?

    Hi
    I have created a custom validator to verify two DateField components, and the doValidation() is working so far so good.
    The question is, how to highlight the two DateField components when the validation failed?

    The problem is solved by override the actualListeners() to return the two DateFields.

  • Custom Validator Types in BC4J

    HI,
    I am having a few problems implementing a custom validator type. Through following the documentation, I have created a new type via the registered rules tabs attached to my business components project. The created class extends oracle.jbo.server.rules.JboCompare Validator.
    Once registered, the class appears in the validation tab of the edit Entity wizard as expected.
    However, when I try to enforce a validation rule based on the created bean, I get the following :
    Cannot create an instance of the validation rule bean or editor.
    Validation rule class may not be in classpath.
    Exception oracle.jbo.dt.object.JboException(ClassNotFoundException)
    The class created is definately in the classpath for my project. I have also tried creating the class inititally, and then adding the class to the registered rules, as opposed to creating a new class via registered rules.
    Is this a bug, or have I missed something?
    Thanks,
    DB
    null

    Sorry for the delay in response on this -- it took me some time to track down the problem.
    When you create a customer validator, the class is added to your current project. However, the IDE doesn't include the myclasses directory as part of it's class path.
    The workaround is to edit the [JDeveloper_home]\bin\jdeveloper.ini, and add your current projects class output path to the IDEClassPath (e.g. IDEClassPath=..\lib\jdeveloper_intl.zip;...;..\myclasses)
    Thanks for the info. I have logged this as a bug, so hopefully we can resolve it in a future release.
    -- Brian

  • Custom validation rules

    Using adf/bc with jdev 10.1.3.3. I've created a custom validation rule class according to the instructions in the adf guide. In that class, I've defined just one property, along with its getters/setters. I've registered my rule in the business component project and associated the rule to an entity attribute via the entity object editor. My problem is that I don't see any way for me to set the property/value of the property that's defined in the validation rule class. For example, in the SRDemo app, in the entity editor for ServiceRequest, if you highlight Validation in the left pane then select the AttributeMustExistInViewRowRule for the Status attribute and click the Edit button, you can set various property values that have been defined in the validation rule class. These values appear to then be updated to that entity's xml file. When I'm in my entity object editor and i've assigned a validation rule to an attribute, I can type in the error message text in the Edit Validation Rule dialog, but it says there are no properties to edit! I guess I haven't wired something together quite right? Note, I have not created the customizer and bean info classes for the design time aspect of this stuff. I assume that you do not absolutely need these classes to create and work with a customr validation rule? Anyone know what I'm doing wrong?

    ok, i figured out the problem. The property/value fields in the Edit Validation Rule dialog will not appear until you've actually compiled the custom validation rule class. I had tried to create the validation rule class, register it with the bc project, and assign it to an entity attribute all without first compiling the class. I stumbled upon this 'fix' in jdev's help, which leads me to another question. For the help topic entitled Creating Custom Declarative Validation Rules for Oracle ADF Business Components, the instructions have you create a class that implements JbiValidator and provide implementation for the method vetoableChange, from which you typically call validateValue. The adf guide's example has the custom validation rule class that extends AbstractValidator and implements JboValidatorInterface. In this example, you provide implementation for the validate method. What's the difference between these two approaches and when should I use one over the other? Thanks.

  • Custom validator only works on one field

    I created a custom validator called FormatValidator, which validates input based on a regular expression. I also created a custom tag for the validator.
    Everything works fine when I use the tag only once in a JSF page. However, when I use the tag more than once, I get the following exception:
    java.lang.NullPointerException: value
         at javax.faces.webapp.UIComponentTag.isValueReference(UIComponentTag.java:227)
         at javax.faces.webapp.ValidatorTag.createValidator(ValidatorTag.java:82)
         at com.ml.gmi.eds.nigel.web.taglib.FormatValidatorTag.createValidator(FormatValidatorTag.java:34)
         at javax.faces.webapp.ValidatorTag.doStartTag(ValidatorTag.java:55)
    Any ideas why?

    If you have tried another set of headphones and get the same result there is a problem with the jack on the nano. Get a flashlight and check the jack, if you see debris clean it out. Otherwise you will have to get it serviced.

  • Spry Text Field Custom Validation Patern PHP

    I am using PHP and I'm not sure but I believe I may be unable
    to create a custom validation pattern. What I would like to do; is
    create a user pattern that forces Alpha and Numeric characters
    only, with no spaces for use in Spry Text Fields for User Names and
    Passwords. Has anyone got any advice?

    Sorry :) This was a case of RTFM. I have found what Ineeded
    in the documentation. I have listed below what I was looking for,
    just in case anyone else is looking for it. Not quite what I was
    hoping for, but better than a slap in the face with a wet kipper.
    "0"
    Whole numbers between 0 and 9
    "A"
    Uppercase alphabetic characters
    "a"
    Lowercase alphabetic characters
    "B"; "b"
    Case-insensitive alphabetic characters
    "X"
    Uppercase alphanumeric characters
    "x"
    Lowercase alphanumeric characters
    "Y"; "y"
    Case-insensitive alphanumeric characters
    Any character

  • Jbo Custom Validation

    Is it possible to create a custom validation bean and assign it at the entity level? Currently, I have only been able to assign a custom validation bean to an attribute of an entity and have it work correctly.

    Ok, is there anyone else doing anything remotely like I am attempting to do? Or this is another case of it is not supported?

  • SelectBooleanCheckbox required=true not working - need custom validator?

    To All:
    Searched the web (and this forum) and saw only one post related to this issue and it concluded that a custom validator was necessary.
    I want to have the required attribute make the selectBooleanCheckbox actually required when the form is submitted.
    1. Is it true that I have to wrtie a custom validator? It seems by now MyFaces or somewhere out there a validator must exist
    OR
    2. Does someone know how to make a checkbox required in JSF?
    Many Thanks!
    Matt

    The problem with a selectBooleanCheckbox is that it will ALWAYS return a value. Thus, if you set it to required, it doesn't matter if it's checked or unchecked, it has returned a value. It would incorrect to assume that setting the required flag to true would mean the checkbox must be checked. What if it's required to be unchecked?
    Anyways, the bottom line is that you will have to create a custom validator to ensure that the checkbox is checked (or unchecked, depending on what your requirements might be). However, this is simpler than you might be thinking. Use the validator attribute and a method in your backing bean to perform the check.
    Like this:
    <h:selectBooleanCheckbox id="myRequiredCheckbox"
              value="#{backBean.requiredBox}" validator="#{backBean.checked}" />backBean will have something like the following validator method (this one throws an error if the box isn't checked):
         public void checked(FacesContext context, UIComponent component,
              Object value) throws ValidatorException {
              if (context == null || component == null || value == null)
                   throw new NullPointerException();
              Boolean isChecked = (Boolean)value;
              if (!isChecked .booleanValue()) {
                   FacesMessage msg = new FacesMessage("You must check the box before proceeding.");
                   msg.setSeverity(FacesMessage.SEVERITY_ERROR);
                   throw new ValidatorException(msg);
         }See, pretty easy eh?
    CowKing

  • Perform custom validation on invoices created via iSupplier portal in R12

    Hello,
    It seems that since R12, invoices created on iSupplier portal are no longer loaded via Payables open interface tables (while ASBN's still are). It is nice that they are loaded immediately but now we do not have any way to perform custom validation that we normally do via AP_INTERFACE_WORKFLOW_PKG.do_custom_validation procedure.
    Is there any way to modify how iSupplier portal inserts Invoice data into AP tables? In particular we would like to choose specific document category for certain suppliers.
    Many thanks in advance,
    Kamil

    Hi Friends,
    Apologies to have put this in SCM-Costing Category. I just posted the same thing in Financials Category.
    Please ignore this, if found irrelevant under this category.
    Thanks,
    AAR

  • How do you create custom validation rule in WS 9.2?!?!?!

    Hello,
    I am using Workshop 9.2. I created a page flow, and want to do some form validations.
    I saw the simple 9.2 example, but it is only good for very basic validation, what if you have to validate the form field against a database, must you write a custom validation rule? HOW would you do this in 9.2 so that will still stay with the workshop/netui paradigm?
    http://beehive.apache.org/docs/1.0.1/netui/validation.html
    Keith

    Hi Keith,
    Staying within the declarative validation framework the answer is probably that you do need to write a custom validation rule and refer to it using the @Jpf.ValidateCustomRule annotation.
    The NetUI Annotation Reference shows how the Struts validations are supported via the framework.
    http://beehive.apache.org/docs/1.0.1/netui/annotations/pageflow_annotations.html
    Specifically, if you look through the @Jpf.Validate* annotations, while most of these are "canned" common validations, there are a few that are more open-ended, such as @Jpf.ValidateMask and @Jpf.ValidateValidWhen.
    Those two let you write the validation logic in the annotation while @Jpf.ValidateCustomeRule only refers to a custom rule in the struts validator file.
    In any case, there is a validation rule editor which should help in authoring and managing the annotations. In the Page Flow Explorer or Page Flow Editor just right click on the action or form bean bean of interest and choose Validation Rules and the appropriate scope.
    I hope that's of some use,
    Troy

  • How to create the custom table?

    Hi, how to create the custom table and how to integrate the table with defferent R/3?
    my requiremnt is i have to create the two tables and those i have to integrate with the existed R/3 and using those R/3 i have to update my custom tables .....can give me some idea?
    Tks
    DPk

    how to create the custom table
    There are two approach in creating a table.
    1. Bottom-up approach
    2. Top-down approach.
    Both are valid and you can choose which approach is suitable for you. I always use the bottom-up approach. Here are the steps to create the tables with this approach.
    1. SE11 will take you to the DDIC and enter the name of the new table to be created. Let us say Zname. Click create.
    2. Enter the short discription of the table and enter the field of the table. If it is primary key and you have to check the box.
    3. Enter the data element and double click it, you will be asked to save and will take you to data element discription page. Enter the short discription of the data element and enter the information of domain like the length of field and type of field.
    4. If you wanted to use the existing domain then its fine, or else, you have to create one. Enter the domain name in the data element page and double click it. Page will ask to save and jump to domain creation page.
    5. In the domain page, you have to save the information which you have already given in the data elements page and check it. Before going to data element page, you have to activate the domain.
    6. Go to data element page and save, check and activate.
    7. Go to main table page and save, check, and activate.
    8. Also, you have to save the technical settings of the table.
    The table is now ready for operation. You can use it in your program or you can use it to enter information.
    Check table: It is the table which will have all the information about the Foreign keys which are the primary keys in the check table.
    It can be created by creating the foreign key from the main table. Click foreign key in the main table and it will take you to a page which will ask for table name and field to which foreign key relation has to be associated. Enter the information and you can create the check table automatically.
    SM30 is used for maintenance of the table, that is to realease the errors occured during the creation of the table.
    how to integrate the table with defferent R/3
    Transport the Table to the another server/client/qas/prd
    Kanagaraja L

  • Creating a Custom CharsetProvider

    I am led to believe that using the java.nio package, creating and registering a new custom CharsetProvider is a breeze ;)
    All I want to do, is register a custom Charset, which will be used to encode three Danish characters into specific byte values. Here's the mapping:
    0xC5  -> 0x81  (The A with the circle on top)
    0xC6 -> 0x92  (The A with an E stuck on the side. Nicked from the Greeks methinks)
    0xD8 -> 0x9D  (The 'teenage metal band' O, i.e. an O with a backslash through it)Then with this custom Charset in place and registered as a valid extension, I create new custom encoded Strings by...
    String customString = new String("danish characters", "MY_DANISH_ENC1")and when I call...
    byte[] encodeByteArray = customString.getBytes()..where appropriate, I receive the encoded bytes 0x81 0x92 0x9D ..and everything is fabulous and superb.
    Ok, so here's what I tried:
    1) Create a new DanishCharsetProvider which extends CharsetProvider and returns a new DanishCharset when its charset() method is called.
    2) Create associated DanishCharsetDecoder and DanishCharsetEncoder classes
    3) Create a custom DanishCharset class which extends Charset and returns new DanishCharsetDecoder and DanishCharsetEncoder classes.
    4) Register the new DanishCharsetProvider creating a JAR file with META-INF/services/java.nio.charset.spi.CharsetProvider
    However, has anyone ever tried to implement the CharsetEncoder and CharsetDecoder methods? I mean, what is encodeLoop all about and what is a CoderResult? Where does actual the mapping of the bytes occur? Is this where DanishCharset comes into play?
    I've read the API, searched the forum, raked the Java source code, tried to de-caf classes in charsets.jar, but still haven't come across an actual example of how character encoding is done. Surely somebody, somewhere has done this before?
    What's worse is, I'm not even Danish!

    Apologies, this post should be in the Java Programming Forum.
    http://forum.java.sun.com/thread.jsp?forum=31&thread=504392&tstart=0&trange=15

  • Unable to Create a custom folder in Discoverer Administrator

    Hi,
    I have a discoverer report which is based on on standard query(Which cant be modified).The requirement is to add a new column to it which doesn't exist in that folder.I can create a custom folder and add the column to the report,but the problem is whenever i create the folder and hit the Validate SQL button it is throwing the error " *The custom SQL entered is not valid SQL statement - ORA-00942: table or view does not exist* "
    I have all the privileges for the user and when I am trying to validate the existing queries ,it is throwing the same error .
    Discoverer Version - 4 i
    Oracle Application - 11.5.9
    Appreciate your help .
    Thanks ,
    Vijay

    Hi,
    Creating new folders should be done when you are logged on as an application user.
    If your application user does not have admin access to the EUL then log on the Disco Admin as the EUL owner and grant full admin privileges to an applications user or responsibility.
    Then logon to Disco Admin with that user or responsibility. You should then be able to create and import folders.
    Rod West

  • Creating a custom java module for excel to xml conversion.

    Hi Gurus,
    I am creating a custom java module in sap nwds 7.3 for Excel to XML Conversion. But I am getting following error
    Classpath dependency validator message.
    Classpath entry  will not be exported or published. Runtime ClassNotFoundExceptions may result. 
    I imported the Jars from a different PI system and i am using NWDS in local PC with creating a separate folder with all JARs and also imported them using build path option.
    This issue is occuring for all the jars imported.
    I am using following code.
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.AbstractTrace;
    import java.util.HashMap;
    import jxl.Cell;
    import jxl.Workbook;
    public class JavaMappingExcelToXML implements StreamTransformation{
    private Map map = null;
    private AbstractTrace trace = null;
    public void setParameter(Map arg0) {
    map = arg0; // Store reference to the mapping parameters
    if (map == null) {
    this.map = new HashMap();
    public static void main(String args[]) { //FOR EXTERNAL STANDALONE TESTING
    try {
    FileInputStream fin = new FileInputStream ("c:/ashu.xls"); //INPUT FILE (PAYLOAD)
    FileOutputStream fout = new FileOutputStream ("C:/Users/ashutosh.a.upadhyay/My Documents/ashuXML2.xml"); //OUTPUT FILE (PAYLOAD)
    JavaMappingXLStoXML mapping = new JavaMappingXLStoXML ();
    mapping.execute(fin, fout);
    catch (Exception e1) {
    e1.printStackTrace();
    public void execute(InputStream inputstream, OutputStream outputstream) {
    String msgType = "Message Type name will come here";
    String nameSpace = "Namespace Name will come here";
    String xmldata = "";
    try {
    Workbook wb = Workbook.getWorkbook(inputstream);
    xmldata ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+ "<ns0:"+msgType+" "+"xmlns:ns0=\""+nameSpace+"\n">";
    Cell[] cells ;
    Cell[] cellNames ;
    cellNames = wb.getSheet(0).getRow(0);
    for(int j=1;j<wb.getSheet(0).getRows();j++){
    xmldata = xmldata+"\n<Record>\n";
    cells = wb.getSheet(0).getRow(j);
    for(int i=0;i<wb.getSheet(0).getColumns();i++){
    xmldata = xmldata+"\t<"+cellNames[i].getContents()+">"+cells[i].getContents()+"</"+cellNames[i].getContents()+">\n";
    xmldata = xmldata+"</Record>";
    xmldata = xmldata+"\n</ns0:"+msgType+">";
    System.out.print(xmldata);
    xmldata.getBytes();
    wb.close();
    byte by[] = xmldata.getBytes();
    outputstream.write(by);
    inputstream.close();
    outputstream.close();
    System.out.println("\n"+"File processed");
    catch (Exception e) {
    e.printStackTrace();
    Request you to guide how to resolve this issue.
    Thanks  in advance

    Hi Gurus,
    I am creating a custom java module in sap nwds 7.3 for Excel to XML Conversion. But I am getting following error
    Classpath dependency validator message.
    Classpath entry  will not be exported or published. Runtime ClassNotFoundExceptions may result. 
    I imported the Jars from a different PI system and i am using NWDS in local PC with creating a separate folder with all JARs and also imported them using build path option.
    This issue is occuring for all the jars imported.
    I am using following code.
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.AbstractTrace;
    import java.util.HashMap;
    import jxl.Cell;
    import jxl.Workbook;
    public class JavaMappingExcelToXML implements StreamTransformation{
    private Map map = null;
    private AbstractTrace trace = null;
    public void setParameter(Map arg0) {
    map = arg0; // Store reference to the mapping parameters
    if (map == null) {
    this.map = new HashMap();
    public static void main(String args[]) { //FOR EXTERNAL STANDALONE TESTING
    try {
    FileInputStream fin = new FileInputStream ("c:/ashu.xls"); //INPUT FILE (PAYLOAD)
    FileOutputStream fout = new FileOutputStream ("C:/Users/ashutosh.a.upadhyay/My Documents/ashuXML2.xml"); //OUTPUT FILE (PAYLOAD)
    JavaMappingXLStoXML mapping = new JavaMappingXLStoXML ();
    mapping.execute(fin, fout);
    catch (Exception e1) {
    e1.printStackTrace();
    public void execute(InputStream inputstream, OutputStream outputstream) {
    String msgType = "Message Type name will come here";
    String nameSpace = "Namespace Name will come here";
    String xmldata = "";
    try {
    Workbook wb = Workbook.getWorkbook(inputstream);
    xmldata ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+ "<ns0:"+msgType+" "+"xmlns:ns0=\""+nameSpace+"\n">";
    Cell[] cells ;
    Cell[] cellNames ;
    cellNames = wb.getSheet(0).getRow(0);
    for(int j=1;j<wb.getSheet(0).getRows();j++){
    xmldata = xmldata+"\n<Record>\n";
    cells = wb.getSheet(0).getRow(j);
    for(int i=0;i<wb.getSheet(0).getColumns();i++){
    xmldata = xmldata+"\t<"+cellNames[i].getContents()+">"+cells[i].getContents()+"</"+cellNames[i].getContents()+">\n";
    xmldata = xmldata+"</Record>";
    xmldata = xmldata+"\n</ns0:"+msgType+">";
    System.out.print(xmldata);
    xmldata.getBytes();
    wb.close();
    byte by[] = xmldata.getBytes();
    outputstream.write(by);
    inputstream.close();
    outputstream.close();
    System.out.println("\n"+"File processed");
    catch (Exception e) {
    e.printStackTrace();
    Request you to guide how to resolve this issue.
    Thanks  in advance

Maybe you are looking for

  • HELP: Error while consuming Web Service: ClassCastException

    Hi, I am trying to consume a web service that I deployed on Tomcat/Axis. Any guideline will be helpful. I generated stubs using WSDL2Java utility from Axis. The method I am trying to call is getFibo(), which returns an object FiboHolder. Unfortunatel

  • IPod touch will not Sync to my new Computer

    Recently I have got a new computer, and when I upgraded to Windows 7 decided to move my music from my laptop to the new computer. After transferring all my music to my new computer, I then plugged in my iPod, and tried to Sync it to this. First of al

  • How to call a webService from WebDynPro ABAP ?

    We are trying to call a webService from WebDynPro-ABAP application. It is not working, While if we are calling the WebService from a Report, it is working. How exactly do we call a WebService from a WebDynPro-ABAP application? What are the main steps

  • Re:Setting background color in BSP using HTMLB

    Hi All, I am new to BSP's and i am using htmlb tags .The problem is i am able to set the background color of the page using html but i want the same using htmlb tags.Is there any tag to do this or shall i have to use themes?.Please help me in this is

  • Import of structure of folders

    Hi I have a question in my  dev system I have created  many folders  then  my question is Can I import these structure from dev to QA on cfolders? Regards Danny