Validation by java

<af:column>
<af:inputText required="true" validator="#{Class7.check}" id="krik2" value="#{Class7.krikor}" >
</af:inputText>
</af:column>
<af:column>
<af:inputText required="true" >
</af:inputText>
</af:column>
public void check(FacesContext facesContext, UIComponent uiComponent, Object newValue)
String krikor = newValue.toString();
if ( krikor.equals("belowcolumn")
FacesMessage message = new FacesMessage();
message.setSummary("they cant be equal.");
throw new ValidatorException(message);
How Cn I in check method, get the value of the other column so that i compare them>???

Please provide a propper use case and jdev version you are using.
Are us using adf rich faces?
You can traverse the component tree to get the component 'below' (what ever that mean). But this would depend on the layout of the page. So this is not the way I would go. Give the input text you want to check against an id, find the component with this id in the component tree get the value of the component and do the comparison.
If you bind the input text 'below' to a backing bean you don't even have to ssearch for the component in the tree.
Timo

Similar Messages

  • How to write validation in java sript item should not allow more than 20 ch

    HI,
    I need to write validation in java script for a item it should not allow more than 20 characters.
    Thanks
    Nr

    If this answers your question, please mark your question as answered (so everyone knows it is answered) and assign points where you see fit..
    Thank you,
    Tony Miller
    Webster, TX

  • DOM validation using Java is extremely slow

    I have a large XML file ~8MB. When I do validation on it using java api, takes ~5 hours to process it.
    I have narrowed down the problem to xs:unique rules in the schema file. When I remove these rules, validation takes ~1 min.
    I have tried using MSXML parser with unique rules and it take about 30 min.
    My question is how could I speed up the validation in Java with these unique rules in the schema.
    Any help will be greatly appreciated.
    Thanks.

    Basically, you are saying removing the unique elements
    from schema and do the checking myself. This means
    everytime the schema is updated with new unique rules,
    I will have to modify the code to check for unique
    elements.
    Is there any other way to tackle this problem?You can choose what processing is done with the XML parser, and what is done within java, if you control the schema. Uniqueness is one that I have preferred to perform in java, since I often perform other validations in java anyway, and it works well. Just my opinion.
    If you post some XML/XSD code and list the parser you are using, someone that uses xs:unique may find something they can help you with.
    -Scott

  • Range Validation in Java

    Hi,
    I am having a doubt in Range Validation
    I having the following as input, i will maintain a Default Values,
    StartId, EndId as Constant in my program
    Example :
    StartID= "0000000" Format will be "XXXXXXX"
    EndID = "0000100" Format will be "XXXXXXX"
    From the UI, i will have the option to enter a text. If the User has to enter the same Format "XXXXXXX", the format validation I performed using reg Expression,
    I need to perform the Range validation here, if the user Enters value say
    "0000700" < it is not within the StartId & EndId Range, then i need to say Error.
    How can i perform Range Validation in java.?
    Any Ideas please..

    It can be done with regexp but it's probably easier to parse the start and end ids and the entered value into integers and perform the validation using a normal if statement.

  • DB procedure validation versus JAVA method validation

    Hi ,
    We have an application that is developed with Oracle Forms as well as Java (ADF )
    Now since ADF is the newer application, it was told to reduce the development time but provide efficient code. Now with Forms each field validation called a procedure and returned an error.
    For example if Name is validated, They have a procedure VALIDATE_NAME proc. Why they have separated this is cause based on different customers and different products, the name validation differs. So the in parameters are Field val, Product, customertype... etc. Like this, there are 20 VALIDATE_FIELD procedures for respective fields.
    Now to reduce duplication, I can call each procedure on each field. but that would means 20 DB additional calls for each procedure. If I write this logic in java it means I increase development time and probably increase probability of error.
    Which is the best practice for VALIDATION.

    Hi,
    you already mentioned the pros and cons of the approaches. I don't think that it is good practice to directly call the PLSQL validation from Java as it means you wont be able to change it easily in the future. I would look for an abstraction layer that initially (for the time being) accesses the database for validation (maybe caching some validation policies upon application instance start) and later then can be changed to use pure Java validation rules. One thing coming to my mind would be something like a rules engine that reads the validation conditions from the database and that is accessed from Java. If your manager says you should reduce development time then my impression is that the choice is not yours and you will have to use the database (though it feels wrong).
    Frank

  • Validation of Java Version

    Hello,
    I'm building a program that before it runs the program need to verify the version of Java.
    If the version is less that version 1.4, the program won't start.
    How I make the validation of Java version ?
    tks

    Ok.
    But, this command return a value String.
    In general, the version is like 1.4.2_03.
    Then, How I compare whith others versions ?
    Example,
    My program will run only in the Java version bigger than 1.3.
    The command getProperty return the string 1.4.2_03.
    It's my problem ...
    Tks

  • Problem with XSD validation in Java 5

    Hi everyone,
    my application creates in memory schema using JDOM. In Java 6 validation runs fine, but in Java 5 (which is the target platform currently) it fails.
    I tried a second test with just parsing an existing XSD document (not created using JDOM) and that works.
    The textual representation of both (file and JDOM generated) are identical. If I replace the XSD file with the JDOM output, the "file test" runs fine, too.
    Here's the test code:
        protected void assertXsdValid(Source xsdSource, InputSource xmlInputSource) throws SAXException, ParserConfigurationException, IOException {
            isValid = true;
            SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            sf.setErrorHandler(myErrorHandler);
            Schema schema = sf.newSchema(xsdSource); // <<--------- THIS LINE FAILS IN JAVA 5
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            dbf.setSchema(schema);
            DocumentBuilder db = dbf.newDocumentBuilder();
            db.setErrorHandler(myErrorHandler);
            db.parse(xmlInputSource);
            assertTrue(isValid);
        }This is the XSD:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://some.org/metamodel" elementFormDefault="qualified">
      <xs:element name="system">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="name" type="xs:string" />
            <xs:element name="vendor" type="xs:string" />
            <xs:element name="version" type="xs:decimal" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>This is the error message I get:
    ERROR: org.xml.sax.SAXParseException: s4s-att-invalid-value: Invalid attribute value for 'type' in element 'element'. Recorded reason: UndeclaredPrefix: Cannot resolve 'xs:string' as a QName: the prefix 'xs' is not declared.
    This is how I call the test code in the JDOM test:
            assertXsdValid(new JDOMSource(xsdDoc), new JDOMSource(xmlDoc).getInputSource());If I change the code to parsing not the JDOMSource, but a StreamSource reading the textual representation of the XSD, it works fine!
            assertXsdValid(new StreamSource(new ByteArrayInputStream(new XMLOutputter().outputString(xsdDoc).getBytes())), new JDOMSource(xmlDoc).getInputSource());But this is not what I want (I expect suboptimal performance with large XSD documents). So, if it works with Java 6, then why doesn't it work with Java 5?
    How can I use the Java 6 JAXP in Java 5?
    Thank you.

    A new user name?
    I can think of ways round your problem but can you first provide a reference that indicates that byte 0x80 is the MS936 encoding for the Euro?
    P.S. This is a forum and the vast majority of participants, including me, have no direct relationship with Oracle so getting definitive answers from Oracle via this forum is unlikely. If you think you have found a bug in 1.5 and/or 1.6, and I am not convinced you have, you need to report it via the bug database. If it is a bug then the response time for a fix is likely to be months rather than days.
    P.P.S No I can't explain why it works in 1.7!

  • Xml vs schema validation by java multimapping: ParserException

    Hello guys,
    I was looking for an answer everywhere, but with no succes.
    Problem:
    I am using SAP NetWeaver BI 7.0
    My interface mapping looks like this:
    1 XML INPUT ---> JAVA MAPPING ---> n XML OUTPUTS
    O found out, tha by setting occurence to "0..onbounded", causes, that also input is comming as "0..onbounded" xml. That I don't understant, but OK, can live with that. In runtime it looks that on the output, my xml root element is wrapped to this structure:
    <b>Messages
    |__Message1
        |__SDS_XSD_ZPPM_POB</b>
    What is frustrated problem for me, that I need to validate on the output in my Java Mapping the xml document against the schema but I always get this error:
    <i>Fatal Error: com.sap.engine.lib.xml.parser.ParserException:
    ERRORS :
    cvc-element : element information item '/:Messages[1]' is not associated with element declaration and do not has an attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is type.</i>
    This is the begin of the xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <Messages xmlns="http://xxx.sk/is_xx">
       <Message1>
          <SDS_XSD_ZPPM_POB>
    This is the begin of the schema definition:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema targetNamespace="http://sap.com/xi/XI/SplitAndMerge" xmlns:p0="http://xxx.sk/is_xx"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://sap.com/xi/XI/SplitAndMerge">
       <xsd:element name="Messages" xmlns:p0="http://xxx.sk/is_xx">
          <xsd:complexType>
             <xsd:sequence>
                <xsd:element name="Message1" form="qualified">
                   <xsd:complexType>
                      <xsd:sequence>
                         <xsd:element ref="SDS_XSD_ZPPM_POB" minOccurs="0" maxOccurs="unbounded"
                            xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
                      </xsd:sequence>
                   </xsd:complexType>
                </xsd:element>
             </xsd:sequence>
          </xsd:complexType>
       </xsd:element>
    Without validation everything works perfect.
    CAN ANYBODY HELP WITH SOME CLUE?
    Thanks a lot
    Rasto
    Message was edited by:
            Peter Guzik

    No I didn't.
    Here is the result of my fixes:
    <b>XML:</b>
    <?xml version="1.0" encoding="UTF-8"?>
    <Messages xmlns="http://sap.com/xi/XI/SplitAndMerge">
       <Message1>
          <SDS_XSD_ZPPM_POB>
             <pob>010</pob>
    <b>XSD:</b>
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema targetNamespace="http://sap.com/xi/XI/SplitAndMerge" xmlns:p0="http://xxx.sk/is_sds"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://sap.com/xi/XI/SplitAndMerge">
       <xsd:element name="Messages">
          <xsd:complexType>
             <xsd:sequence>
                <xsd:element name="Message1" form="qualified">
                   <xsd:complexType>
                      <xsd:sequence>
                         <xsd:element ref="SDS_XSD_ZPPM_POB" minOccurs="0" maxOccurs="unbounded"
                            xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
                      </xsd:sequence>
    <b>RESULT EXCEPTION:</b>
    Fatal Error: com.sap.engine.lib.xml.parser.ParserException:
    ERRORS :
    cvc-element : element information item '/:Messages[1]/:Message1[1]/:SDS_XSD_ZPPM_POB[1]/:pob[1]' is not associated with element declaration and do not has an attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is type.
    cvc-element : element information item '/:Messages[1]/:Message1[1]/:SDS_XSD_ZPPM_POB[1]' is not valid with respect to it's complex type definition..
    cvc-element : element information item '/:Messages[1]/:Message1[1]' is not valid with respect to it's complex type definition..
    cvc-element : element information item '/:Messages[1]' is not valid with respect to it's complex type definition..
    If there is an error in xml, according this message it is impossible to find it..

  • XML Validation using java for SQL Injection and script validation

    I have an input coming from xml file.
    I have to read that input and validate the input against sql injections and scripts.
    I require help now how to read this xml data and validate against the above two options.
    I am a java developer.
    in this context what is marshelling?

    http://www.ibm.com/developerworks/library/x-javaxmlvalidapi.html?ca=dgr-lnxw07Java-XML-Val
    http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/validation/package-summary.html
    The following code validates the xml against a xml schema
    // define the type of schema - we use W3C:
    String schemaLang = "http://www.w3.org/2001/XMLSchema";
    SchemaFactory factory = SchemaFactory.newInstance(schemaLang);
    Schema schema = factory.newSchema(new StreamSource("sample.xsd"));
    Validator validator = schema.newValidator();
    // at last perform validation:
    validator.validate(new StreamSource("sample.xml"));Message was edited by:
    haishai

  • Flex validation in Java

    I am using a product called Crystal Xcelsius to design and
    develop dashboards for banking customers. The product using Flex
    controls with an Excel spreadsheet to show data. It then supports
    data connections to refresh or update that data. After setting all
    this up, it compiles it down to a Flash (SWF) file that can be
    delivered to our client.
    On the client's machine, the SWF file is loaded into a
    database and then served up to the users as needed. Also loaded
    into the database are the SQL queries which will be used to provide
    the data needed to refresh the connections.
    These SWF files and queries can be provided by us, but we
    also let our clients use Xcelsius to create their own and then
    upload them into our application. What I am looking for is a way to
    validate the SWF file as part of the import process. Specifically,
    since they are providing an SWF and a set of queries with
    connection names and range names, I want to parse the SWF file and
    make sure that the data connections in the SWF file match the
    queries that they have provided with the SWF file. I want to make
    sure that all connections in the SWF file have queries provided,
    and that there are no queries that were provided which don't map to
    connections in the SWF file.
    I can take care of the mapping, the part I don't know about
    is getting the list of connections specified in the SWF file. Since
    the server that is importing these files is running Java, are there
    any Java components or libraries I can use to look into a SWF file
    and get the list of data connections in the file?
    Any help, thoughts, or suggestions would be appreciated.
    -Benjamin

    James,
    If you want client-side validation you must use vbscript or preferrable javascript.
    To do client-side validation in your get or post method use java to validate the incoming paramters.
    By the way if you move to a jsps/struts/jsf environment you'll get more help from the system in dealing with these kinds of problems. Developing sizable applications using only servlets will be very difficult.

  • Trigger validations MDM JAVA API

    Hi all,
    I got an issue trying to invoke the validations in the MDM Web Dynpro using the JAVA API; first of al I m creating the record before the user can edit it; in that first moment, the record is checked out and the validations are not executed, that is right, but later, when the user is editing the record, we want to force the user to type all the information using only a specific event (Save button) but even if the record is correct, the validations messages are still showing in the user interface.
    try {
        ModifyRecordCommand cmd = new ModifyRecordCommand(connectionPool);
        cmd.setRecord(material);
        cmd.setSession(usrSessionIdAdm);
        cmd.execute();
    } catch (ValidationException e) {
        RetrieveValidationsCommand valComm = new RetrieveValidationsCommand(connectionPool);
        valComm.setSession(usrSessionIdAdm);
        valComm.setTupleDefinitionId(tdIdTuple);
        valComm.execute();
        ValidationPropertiesResult valResult = valComm.getValidationPropertiesResult();
        ValidationProperties[] valProp = valResult.getValidations();
    Any idea about how to do it?
    Thank you!
    Claudia
    Edited by: Claudia Gómez on Mar 6, 2012 7:24 PM

    HI,
    are you using MDM Webdynpro component?
    you can call validation via the item detail interface,  no need to call via this command.
    Best regards,
    John

  • [INS-08109]Unexpected error validating input-java.lang.NulpointerException

    RAC 11gR2 Grid installation:
    ================
    I got java.lang.NullpointerException during RAC 11gR2 cluster installation.
    [INS-08109] Unexpected error occurred while validating inputs at state QuickInstallUI'.
    Summary:java.lang.NullpointerException
    Are you sure you want to continue ?
    If you click yes it goes back to where to started and the same error would occurs again if you try again. If you click no it will just exit the installer.
    Any help is appreciated. Thanks.
    I cannot go ahead with this error.
    Please find attached screenshot.
    Before starting ./runInstaller i have done with all prerequisite checks and also run
    ./runcluvfy.sh stage -pre crsinst -n isvm-lnx-brm03,isvm-lnx-brm04 -verbose
    Thanks,

    Very stupid installer !
    I've omitted my email, then pressed no in the next message, it passed that step!

  • Url validation in java

    Hello everyone,
    I have a page in which I need to check whether the url entered by a user in the given textbox is valid or not.
    eg.
    user enter: http://forum.java.sun.com/post!default.jspa?forumID=31
    I need to check whether http://forum.java.sun.com/post!default.jspa?forumID=31
    is valid or not.
    Which method should I use?
    Can anyone help me out?
    Please advice.

    I need to check whether the entered url is there in the web world or not.
    For example the user may enter http://abcdef.com which doesn't exist at all
    That's not validation, it's checking for availability. To do that, use the openStream() method of the URL class. When you are done, you have to close() the stream.     try {
           new URL(yourString).openStream().close();
           // available
         catch (MalformedURLException ex) {
           // invalid
         catch (IOException ex) {
           // unavailable
         }

  • Date validations in java

    hi there,
    I have just started using java, jsp and servlets.
    I am facing the following problem.
    I am getting a date string as an input and i want to have a date validation in my servlet to check whether the date is valid and existing and is not greater than the system date.
    Of course this can be implemented using simple if else logic but i wanted to know whether such validations can be done by using a class like "Calendar" so that i can catch exceptions and use sendRedirect.
    Your invaluable responses eagerly awaited.
    Regards,
    ninad.

    Um, Java progamming? Not in the forum. We deal with JES Messaging Server only. Please try one of the developer forums where programming is discussed.

  • XML Validation with Java

    I have created a XML file with dom4j and the file confirmed to be valid when I read the file with Internet Explorer, a online XML validator and a free XML editor called "CookTop". However, when I attemp to read the XML file during the execution of an ant task I always get the XML parsing exception that one of my tag is not closed. I have even wrapped that test inside the tag as CDATA but that does not help as well. Do any one know what's happening? Here's my environment:
    JDK: 1.4.2_05
    Xerces: 2.6.2
    Ant: 1.5.3
    Thanks so much in advance.
    I've been pumping my head into the wall for hours : p

    Can i know where to download the CookTop?or CookTop2?

  • Schema Validation with Java and Document object

    Hi, I am working on a project that will validate an xml Document object from a child class. I seem to have completed XSD validation with new DOMSource(doc) and using schema factory, which doesn't support DTD validation. And now I am attempting to validate the DTD. It seems like all the examples I've seen are trying to parse files, and I am struggling with finding a way to validate it directly against the document object.
    The child class creates the xml document which is passed back to the parent class, and I need to do the validation in the parent class, so I need away to validate against the document object. This will be an assertion in Fitnesse if anyone is familar with it.
    private void doSchemaValidationCommand(int rowCount, Document doc, String xpathExpression)
             String validationPath = getText(rowCount,1);
             String extensionSeparator = ".";
             Boolean error = false;
             String ext = null;
             try
             int dot = validationPath.lastIndexOf(extensionSeparator);
            ext = validationPath.substring(dot + 1);
             catch(Exception e)
                  this.wrong(rowCount, 1, e.getMessage());
             if (ext.equalsIgnoreCase("xsd"))
             try {
             SchemaFactory factory =
                SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            File schemaLocation = new File(validationPath);
            Schema schema = factory.newSchema(schemaLocation);
            Validator validator = schema.newValidator();
            try {
                validator.validate(new DOMSource(doc));
            catch (SAXException ex) {
                this.wrong(rowCount, 1, ex.getMessage());
                error = true;
            catch (IOException ex)  {
                 this.wrong(rowCount, 1, ex.getMessage());
                 error = true;
           catch (SAXException ex) {
               this.wrong(rowCount, 1, ex.getMessage());
               error = true;
           catch (Exception ex){
                this.wrong(rowCount, 1, ex.getMessage());
                error = true;
             else if (ext.equalsIgnoreCase("dtd"))
                  try {
             }

    I tried this but it doesn't give me any validation of whether or not it was completed successfully, it just adds a tag for the dtd to the xml and doesn't seem to do anything further with it, am I missing any steps?
    else if (ext.equalsIgnoreCase("dtd"))
                  try {
                       DOMSource source = new DOMSource(doc);
                       StreamResult result = new StreamResult(System.out);
                       TransformerFactory tf = TransformerFactory.newInstance();
                       Transformer transformer = tf.newTransformer();
                       transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, validationPath);
                       transformer.transform(source, result);
                  catch(Exception e)
                       this.wrong(rowCount, 1, e.getMessage());
                       error = true;
             }Edited by: sarcasteak on Apr 13, 2009 1:33 PM

Maybe you are looking for