Validating a date using Struts

Hoi all,
I am trying to validate a date in struts,
I have googled for a information and searched the forum but didn't find anything useful, I might have been asking the wrong questions.
I have set up my validate.xml and it captures a date that is like : aa/01/3000 and returns an error specifying that the date is wrong but when i type in 45/01/3000 the date is accepted as a valid date and I cannot understands why, the date validation is built in isn�t it ??
Any help will be appreciated

Uhmmm i don�t have it sorted.......
I have been trying to validate a specific date that info can be seen in my original post on top, This is what i have so far in my Validation.xml file
<form name="searchForm">
    <field property="startDate" depends="date">     
       <arg0 >
       <var><var-name>datePatternStrict</var-name><var-value>dd/MM/yyyy</var-value></var>                    
               </field>          
               <field property="endDate" depends="date">               
                  <var><var-name>datePatternStrict</var-name><var-value>dd/MM/yyyy</var-value></var>                    
               </field>                    
               <field property="endDate" depends="validwhenDate" >               
                    <var>
                         <var-name>test</var-name>
                         <var-value>(startEndDateCompare!= -1)</var-value>
                    </var>
               </field>               
          </form>endDate and startDate are both strings and the startEndDateCompare is a method in the searchForm.java file that compares the parsed date values of the string dates of endDate and startDate via a simple date format, If this doesn�t make sense let me know and I'll try to elaborate
now my questions is what am I doing wrong??
The validation still registers that 01/aa/3000 is an invalid date but not 45/01/3000 this is still validated as a correct date.
Thank for any help.

Similar Messages

  • Validating a date using SimpleDateFormat

    I'm trying to use the SimpleDateFormat for validating dates in a
    web application. I want all dates to be input as "dd-mm-yyyy".
    So, if the user wants to input "01 Dec. 2001" it must be in the format
    "01-12-2001" and not "1-12-2001" or "01-12-01". Unfortunately, the
    DateFormat seems to be very lenient even though I explicitly call setLenient()
    specifying "false".
    Is there a way to accomplish what I want?
    The attached program outputs:
    "Thu Dec 01 00:00:00 CET 0001"
    import java.text.*;          
    public class Foo {          
    public static void main(java.lang.String[] args) {
    DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
    df.setLenient(false);          
    try {               
    System.out.println(df.parse("1-12-1"));     
    } catch(Exception e) {     
    e.printStackTrace();     
    Regards,
    S. Bro

    Input is one thing, output is another. Your are doing the right thing, but the Date object cannot guess how you want it to be printed (so it use a default format that you get).
    You can use another SimpleDateFormat for the output, or reuse the one you already created. Changing the line with the System.out.... for
    System.out.println(df.format(df.parse("1-12-1")));
    will get want I think you are looking for.

  • Table for Valid to date in BOM item

    Hi Exeprts,
    Can any one help me on this in which db table Valid to date:DATUB is Updates with reference to Change Number.
    Best Regards,
    Venkata Siva.
    Edited by: venkata siva reddy on Apr 27, 2011 9:28 PM

    Hi
    The Valid-to date will always be set to 31.12.9999. Instead you can get the valid-to date using the below logic.
    -> Get all the BOM from T415A table for the material number into T_T415A
    -->LOOP AT t_t415a.
        ON CHANGE OF t_t415a-matnr OR t_t415a-werks OR t_t415a-stlal.
          IF sy-tabix NE 1.
            MOVE : v_matnr TO t_dates-matnr,
                   v_werks TO t_dates-werks,
                   v_stlan TO t_dates-stlan,
                   v_datuv TO t_dates-datuv,
                   v_stlal  TO t_dates-stlal.
            IF v_matnr NE t_t415a-matnr.
              t_dates-datub = c_99991231.
            ELSE.
              t_dates-datub = t_t415a-datuv - 1.
            ENDIF.
            APPEND t_dates.
            CLEAR :
            v_matnr,
            v_werks,
            v_stlan,
            v_datuv,
            v_stlal.
          ENDIF.
        ENDON.
        v_matnr = t_t415a-matnr.
        v_werks = t_t415a-werks.
        v_stlan = t_t415a-stlan.
        v_datuv = t_t415a-datuv.
        v_stlal = t_t415a-stlal.
      ENDLOOP.
    Regards
    Dhurga

  • How to set the Valid-to-date (datub) of a BOM item

    Is there a way I can set the "Valid-to-date" of a BOM item?
    According to SAP documentation...
    Quote
    <i>"If you change a BOM using a change number, the system determines the valid-to date dynamically."</i>
    Unquote
    I want to "expire" a BOM item. Meaning I want to set the valid-to-date to a date in the past.
    Is this possible at all?
    Thanks for any input.
    Fred

    Ferry,
    Thanks for you reply.
    I do not see a field for the "Valid-to" date in the function module - CS_BOM_EXPL_MAT_V2. There is one for the "Valid-From" date called DATUV. But I would like to change the "Valid-from" date of the BOM item.
    Or is there another way to set the BOM item's valid-to date using this function module which I am missing?
    Fred

  • Can I use Struts Validator Plugin's html:javascript tag?

    Hi:
    Is it possible to incorporate the client-side validation using Struts Validator
    Plugin's tag <html:javascript>?
    i.e.
    1) Insert the following tag to A.jsp and define a taglib:
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
    <html:javascript formName="aForm" staticJavascript="true"/>
    2) Define validation.xml as follows:
    <form-validation>
    <formset>
    <form name="aForm">
    <field property="aField"
    depends="required">
    <msg name="required" key="FieldMissingError"/>
    </field>
    </form>
    </formset>
    </form-validation>
    3) Insert the onSubmit event in aForm:
    <netui:form action="SubmitAForm" style="border-width:1px;" onSubmit="validateAForm(this)">

    Instead of writing something like this -
    <p class="logos">Logo1<a href="...></a></p>
    <p class="logos">Logo2<a href="...></a></p>
    <p class="logos">Logo3<a href="...></a></p>
    <p class="logos">Logo4<a href="...></a></p>
    <p class="logos">Logo5<a href="...></a></p>
    <p class="logos">Logo6<a href="...></a></p>
    Why not have something like this -
    <div id="logodiv">
    <p>Logo1<a href="...></a></p>
    <p>Logo2<a href="...></a></p>
    <p>Logo3<a href="...></a></p>
    <p>Logo4<a href="...></a></p>
    <p>Logo5<a href="...></a></p>
    <p>Logo6<a href="...></a></p>
    </div>
    with CSS like this -
    #logodiv p { ... }

  • [b]Data Grid in jsp using Struts [/b]

    I need to develop a data grid in JSP using struts .
    I am using Tomcat web server , Intellij IDEA IDE.
    If any one has code, please sent it.
    Thanks in Advance.

    hi,
    Use Struts-Layout datagrid framework to full fill your needs
    Related Topic link
    here is the clear documentation for your topic
    http://struts.application-servers.com/datagrid/index.html
    here is the download link
    (Struts-Layout datagrid framework)
    http://deltha.uh.cu/java/docs/struts-layout-1.0-docs/download.html
    related discuss
    http://forum.java.sun.com/thread.jspa?threadID=5202989&messageID=9811082

  • Strut Validation for Date

    I need some ideas on how to validate date in a form in the following two situations using Struts.
    a) Checking whether a particular date is a holiday.
    b) For a given pair of date (say start date and end date), to validate that the end date is later than the start date.
    Thanks!
    Joe

    In your case you can implement a service method in the VO to check if any other reservation overlaps with the new one (which is not inserted in the db).
    I would use a an other VO (e.g. VODateCheck) for this. This VO has it's query build to check if a given roomid and a given startdate(time?) overlaps any other record for the roomid
    select * from ReservationRoom where RoomId=:bindRoomId and ReservationEnd>=:bindReservationStartIf this query returns one or more rows you have an overlapping in the schedule and throw an error.
    You call this VODateCheck from your service method in the other module before inserting the record. Set the bind variables in the VODateCheck and execute the query.
    Timo

  • Display date in jsp. using struts, JSTL

    want to display today's date in format October 18, 2006
    how to get today's date and how to display it in jsp?
    I am using struts framwork and JSTL tags in my JSP.
    Thanks.

    rizza_99 wrote:
    The page underlines {<fmt:formatDate value="${now}" type="both" dateStyle="long" />} says
    attributte value doesn't accept any expressionsWait, you said "the page underlines"?? So you're using an IDE? Are you sure that it a JSTL problem and not an IDE problem? Ignore the IDE and just execute the code. Does it work without any compilation errors or runtime exceptions? If so, then there's a problem in the IDE.

  • Validate integer with a comma thousands seperator using struts Validator

    Using struts validator.
    have to validate the user entered value.
    The value entered should be a positive integer with a comma thousands seperator. the number need not be in thousands.
    I have as below to check for positive integer without comma seperator. but not sure how to validate if the user entered value with a comma seperator?
    i.e value like 25,349 // how to validate this?
    <field property="hrs" depends="integer,validwhen">
    <msg name="integer" key="errors.notvalid"/>
    <msg name="validwhen" key="errors.notvalid"/>
    <var>
    <var-name>test</var-name>
    <var-value>(*this* >= 0)</var-value>
    </var>
    </field>
    how to validate the user entered value with a comma seperator? Thanks.

    Found this in Struts' Building View Components section: Note: If your required form property is one of the Java object representations of primitive types (ie. java.lang.Integer), you must set the ActionServlet's convertNull init. parameter to true. Failing to do this will result in the required validation not being performed on that field because it will default to 0. This seems to be part of my problem. With it turned on, Validator picks up that the value is required. Now to figure out the issue with putting in a double value instead of an Integer.

  • How to load data into html:select using Struts ?

    How to load data into <html:select> using Struts ?
    I can not load an array or collection (static or dynamic data) into drop down list control by <html:select /> Struts.
    please use:
    <html:select >
    <html:options />
    </html:select >
    Please help me. please detail it. thanks a lot.
    Message was edited by:
    tranminhman

    In order to load a collection or array of data you can use <html:select> with <html: options collection="" name=""/>
    here collection attribute refers to the Arraylist or Array of data and name is the name of the Form bean.
    Hope this helps...
    Chaitanya V

  • Retrieve data and display using struts

    hello..
    pls help...
    i know how to insert data into the data base using struts. but i don't know how to retrieve it. i have been trying to retrieve it using resultset .. but not sure how to display it using struts properly..
    pls help...

    hi :-)
    1. put your resultset in a list.
    2. put that list in a request.
    3. show the contents of list using jstl.
    regards,

  • Receive POST data from another URL and process using Struts

    Hi there
    We have a website and as of now we are receiving some data from another URL which is received as an appended part of the URL. My application uses Struts and we process the received data and send back a response.
    Now my question is, I have been asked to change this behavior because there are more parameters now which cannot be passed through the URL. I am supposed to get the data from the other URL as POST data (as a form) and I have to create a new Struts action to receive this data, process it and send the response back to the requesting URL.
    Please explain me how to do this using some example code snippets.
    Thanks a lot

    Lookup in XI is used to call the target data storage system and get data from there to your mapping programme.
    In XI you can do Lookup in Message Mapping, Java Mapping and in XSLT Mapping. Previously Lookup in XI was system dependent. But now what ever the system are i.e. SAP system or non-sap system(Oracle,MS SQL etc) lookup API are same.
    Overview of Lookup
    - Lookups are used to identify/request the data from mapping program.
    - It interrupt the process and looking for data which was stored in target system.
    - It get that data and comeback to process and continue with that data.
    Types of Lookups in XI
    - JDBC Lookup: JDBC lookup is used for accessing data from database (non SAP).
    - RFC Lookup: RFC lookup is used for accessing the SAP Data.
    - SOAP Lookup: SOAP lookup is used for accessing data from Webservice
    Steps to perform Lookup in Mapping
    Import package com.sap.aii.mapping.lookup.*;
    Create connection to the target Database system.
    // Determine communication channel created in ID
    Channel channel = null;
    channel = LookupService.getChannel("DB-SYSTEM-NAME","DB-CHANNEL-NAME");
    // Get system accessor for the channel.
    DataBaseAccessor accessor = null;
    accessor = LookupService.getDataBaseAccessor(channel);
    Build the Query String.
    Getting Result
    // Execute Query and get the values.
    DataBaseResult resultSet = null;
    resultSet = accessor.execute(Query);

  • Help reqd on Changing the Valid from "date"  for both BOM & Routing

    Hi all...
    Pls advise me how to do the changing of Valid from "date"....
    Is there any process in CC01 or ECM???....
    pls reply me in detail step format (step by step analysis)....
    I wrongly created in CS01 and CA01 as 05.10.2007 as my valid from date instead of 01.10.2007.....
    How to change to my actual one......
    I dont know how to change it exactly.....as im beginner in SAP...pls take this into consideration...and post ur replies imm.
    Pls reply me in detail....will be rewarded at the end while closing this issue.
    thanks & regards
    sankar

    Dear Sankarbabu,
    IF there's no setting for Date Check in OS54 - Engineering Change Management
    Control Data,then you can create a change number with past dates,and also to
    use the same one for changing BOM.
    Tell me one thing you are saying you want to use ECM.Was the earlier one
    created without BOM was created without an ECN?
    See already if you have created your BOM with an ECN,then remove the date
    check setting which I have mentioned in OS54.
    Now goto T code CC02 ,enter the Change number and give the valid from date as
    01.10.2007.
    After that check in CS03 whether this date(01.10.2007)is getting reflected or not.
    I'm sure this will solve your problem.
    Regards
    Mangal

  • Error: No valid complaint data was found in this sales area

    Hi All,
    I am getting below error while delta or request download of customer.
    No valid complaint data was found in this sales area
    Message no. CRM_SPL_BUPA_FRG0010203
    Validation error occurred: Module CRM_BUPA_MAIN_VAL, BDoc type BUPA_MAIN.
    Message no. SMW3018
    Error case:
    ECC-->Customer(Sold to) extended to a sales area and saved.
         CRM-->Business partner gets updated in the CRM properly.
    ECC--> Deletion flag for same customer and same sales area is set. (Deletion flag - "Selected sales area").
         CRM-->Business partner gets updated in the CRM properly and is not shown as extended to the sales area via BP t code.
    ECC-->Deletion flag is removed for the customer.
         CRM--> BDOC fails to update the Partner and goes in error.
    Problem comes when deletion flag is removed in ECC.
    Any help would be highly appreciated.
    Thanks in advance.
    -Ram

    Hi Ram,
    Hope you have not make any field mandatory in the Complaint tab in the sales area section in the BP.
    When you are removing the deletion flag please check if any entry is mandatory in the Complaint tab.
    Hope this will be useful
    Thanks and Regards
    DJ

  • Table to find BOM valid-till-date

    Hi Friends,
      I have to check the vality of BOM components,  through transaction CS03 i could able to see the Valid-till-date and i need to check the same in my code.
    Looked into following tables, thre is a field valid-from-date(DATUV) but i'm not getting field Valied-to-date(DATUB).
    MAST Material to BOM Link
    EQST Equipment to BOM Link
    STAS BOMs header
    STKO BOM header
    STPN BOM follow-Up control
    STPO BOM item
    STPU BOM sub-item
    STST Standard BOM link
    STVB Bills of material - Serialisation of posting
    STZU Permanent BOM data
    Can any one please help me.
    Thanks in advance.
    /Kiran

    Hi kiran,
    I think the Valid-to-date is in table AEEF-DATE_HI which can be linked with the BOM Header table STKO by field AENNR. Try this.
    Otherwise you can also get the Date using the FM CS_BOM_EXPLOSION....
    Use it as follows;
    CALL FUNCTION 'CS_BOM_EXPLOSION'
    EXPORTING
    AUMNG = 0
    CAPID = ' '
    DATUV = DATVAL "valid-from date
    EHNDL = '1'
    MKTLS = 'X'
    MEHRS = 'X'
    MMORY = '1'
    MTNRV = MATNR
    STLAL = LAL "like mast-stlal default '1'
    STLAN = LAN "like mast-stlan default '2'
    SVWVO = 'X'
    VRSVO = 'X'
    WERKS = WERKS
    mmaps = 'X'
    IMPORTING
    TOPMAT = STARTMAT "includes structure CSTMAT
    TABLES
    STBD = TBD "includes structure CSXDOC
    STBE = TBE "includes structure CSXEQUI
    STBK = TBK "includes structure CSXKLA
    STBM = TBM "includes structure CSXMAT
    STBP = TBP "includes structure CSXGEN
    STBT = TBT "includes structure CSXTDL
    EXCEPTIONS
    ALT_NOT_FOUND = 1
    CALL_INVALID = 2
    MISSING_AUTHORIZATION = 3
    NO_BOM_FOUND = 4
    NO_PLANT_DATA = 5
    NO_SUITABLE_BOM_FOUND = 6
    OBJECT_NOT_FOUND = 7
    CONVERSION_ERROR = 8
    OTHERS = 9.
    After the function call you will get the Valid to Date(DATEUB) from table STBP.
    Hope this Helps you...
    Regards
    Karthik D

Maybe you are looking for