Date validation on action of button

Hi All,
I want to compare two dates and throw a java csript alert if date1 is less than date2.
This comparison should take place on click of a button which is having af:returnActionListener which closes the pop up on which the whole task was taking place. so no alert is displayed .
Please anyone can tell what the problem is??
Thanks
Pooja

Dear,
Call this function onClick
function date_compare1(field)
var DateField = field;
var field1=document.Formname.TextFieldname.value; //compare from this date
var date1 = new Date(field1);
var sec1 = date1.getTime();
var d=field.value;
var date = new Date(d);
var sec = date.getTime();
if(sec > 0)
if(sec < sec1)
DateField.select();
DateField.focus();
alert("Invalid Date");
Thanks,
Oajay

Similar Messages

  • Form Data Validations

    Imagine there is a field called "Username" ,"Password" and "Submit button".
    I want to implement following validations on click of "Submit" button.
    1 . Please enter Username.
    2.  Username should have a length of 10 characters.
    3.  Please enter Password.
    I want the validation procedure in 2 ways.
    1. The process of validation by indvidual criteria
    Example:
    displaying each validation message by validating all bussiness criteria one by one.
    That is in the above "Username" will be validated first.
    If user enters value it will check for number of characters less then 10.
    If this is passed then need to check for password entry.
    2.  Validating complete form at once
    Validating complete form for all bussiness conditions and displaying them at once.
    Please provide any links for data validations.

    Hey Raghu,
    you can implement a method like checkFields() in the "@@begin others" part of your view which returns a boolean value. When you press the "SUBMIT"-button it is checked whether every mandatory field is filled with the correct data. There you can implement the logic of your query.
    Here is an example for the method <b>checkFields()</b>:
    /** Checks whether the mandatory input fields are filled with regular data. */     
      private boolean checkFields()
         if ( wdContext.currentFreightrequestElement().getTitleInputField() == null ||
                   wdContext.currentFreightrequestElement().getTitleInputField().trim().length() == 0 )
              wdComponentAPI.getMessageManager().
                   reportContextAttributeMessage(wdContext.currentFreightrequestElement(),
                   wdContext.nodeFreightrequest().getNodeInfo().getAttribute(ATTRIBUTE_TITLE_INPUT_FIELD),
                   IMessageFreightRequestComponent.ERROR__01,
                   null,
                   false);
              return false;
    The important thing is the <b>reportContextAttributeMessage()</b> which highlightens a field you want to check.
    In the action-part you can use parts of the following code:
    boolean success = false;
         if ( checkFields()) {
              success = wdThis.wdGetRequestComponentController().executeSave();
         if (success == true)
              IWDControllerInfo controllerInfo = wdControllerAPI.getViewInfo().getViewController();
              String dialogText = wdComponentAPI.getTextAccessor().getText("TEXT_03");
              IWDConfirmationDialog dialog =
                   wdComponentAPI.getWindowManager().createConfirmationWindow(dialogText, controllerInfo.findInEventHandlers("createNewRequest"),wdComponentAPI.getTextAccessor().getText("TEXT_04"));
              dialog.addChoice(controllerInfo.findInEventHandlers("returnToWelcomeView"), wdComponentAPI.getTextAccessor().getText("TEXT_05"));          
              dialog.setTitle(wdComponentAPI.getTextAccessor().getText("TEXT_02"));
              dialog.show();          
    So far,
    Domingo

  • Viewset - active view and data validation problem

    Hey there,
    I've a problem while using a viewset (1 col, 2 rows) and the data-validation in the wdDoBeforeAction() method.
    My application works basically like this:
    The first view is displayed with 2 mandatory input fields. Upon the evaluation result of the entered data in these fields, a corresponding second view will be displayed. The input fields in the first view are set to read only and a button named "Change" appears. This button triggers an action which fires and outbound-plug to an empty view, so that the second view disappears and resets the "read only" properties of the input fields in the first view, so that the user can enter new data.
    The problem is, that the second view contains input fields itself, which are validated in the wdDoBeforeAction() method of this view. The navigation is cancelled if an error occurs. Well, this is fine if i want to submit (pressing the button "Approve" in the second view) this data and proceed, but if i want to go back to the first view (by hitting the "Change" button), i want to discard all information entered in the second view and i dont want this data to be validated. It's quite annoying if u just want to correct the first views data but have to enter correct values for the second view in order to get through the second views checks..
    I hope that's clear enough, otherwise i will upload a screenshot to clarify.
    Thx in advance
    Regards
    Pascal

    Hi Pascal,
    although I wont prefer to do so for reasons of readability, you could use wdDoProcessbeforeAction to control your view-flow.
    Take a look at the example, I have two Buttons with two actions, one is set on "Validate", the other is not (guess which on is the validating ).
    You can get the action triggered inside the doBefore ... method and determine whether or not the checkbox is set.
    So put your code to validate the input in the i(isValidting) branch and your problems are solved.
    Keep in Mind: I would delegate the Validation from the view to the controller, handle the validation myself with custom coding and then check in the view controller if any errors occured.
    hope that helped,
    Jan
      //@@end
      public void wdDoBeforeAction(com.sap.tc.webdynpro.progmodel.api.IWDBeforeAction validation)
        //@@begin wdDoBeforeAction
           IWDAction currentAction = validation.getCurrentAction();
           if (currentAction == null) return;
           String action = currentAction.getText();
           boolean isValidating = currentAction.isValidating();
           if (isValidating) {
                wdComponentAPI.getMessageManager().reportException(action);
           } else {
                wdComponentAPI.getMessageManager().reportSuccess(action);
        //@@end
    Edited by: Jan Galinski (Holisticon) on Sep 8, 2009 3:15 PM

  • Check data valid with Java Script

    Hi, every one,
    I made a jsp program and just to check if the data is valid before submit. My problem is even the data is invalid, it still go to next jsp page and display alert message at the same time. But I think if the data is invalid, we can't go to next jsp page. So, any one can tell me what's wrong with my program.
    Thanks in advance.
    The source code is as follows:
    <HTML><HEAD>
    <TITLE>TEST PROGRAM</TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    function validate(){
         if(document.form1.yourname.value.length < 1){
              alert("please enter your full name");
              return false;
         if(document.form1.address.value.length < 3){
              alert("please enter your address.");
              return false;
         if(document.form1.phone.value.length < 3){
              alert("please enter your phone number");
              return false;
         return true;
    </SCRIPT>
    </HEAD>
    <BODY>
    <H1>FORM EXAMPLE</H1>
    Enter the following information. When you press the Display button,
    the data you entered will be validated, then sent by e-mail.
    <form name="form1" action="a2.jsp" enctype="text/plain" onSubmit="validate();">
    <p>
    <b>Name:</b><input type="text" length="20" name="yourname">
    <p>
    <b>Address:</b>
    <input type="text" length="30" name="address">
    <p>
    <b>Phone:</b><input type="text" length="15" name="phone">
    <p>
    <input type="SUBMIT" value="Submit">
    </FORM>
    </BODY>
    </HTML>

    Hi,
    I have another question. If i have a menu as follows and I just want to check the data valid on the current page. I mean, only value=1, 2,3 is valid, value=0 is invalid. How can I do?
    <td valign="middle" width="63%"> <font face="Arial, Helvetica, sans-serif" size="2">
    <select name="type">
    <option value="0">Please Select One of The Following Reasons</option>
    <option value="1">Exchange</option>
    <option value="2">Refund</option>
    <option value="3">Wrong Product</option>
    </select>
    </font></td>
    </tr>
    Thanks.
    peter

  • Data Validation - a feature that Numbers really needs.

    Right now, the newly purchased Numbers app for iPad/iPhone is little more than a crippled document viewer for me because numbers doesn't support 'data validation' (as implemented in excel).
    Its not a hard concept and likely utilized in a LOT of spreadsheets on the planet.  Not supporting such a critical feature is a problem, as it makes numbers, at least for me, rather pointless as an authoring tool since I cannot change or update data in my worksheet without likely corrupting the document's data integrity.
    Hopefully, someone at Apple is working on fixing this.
    Given that one cannot use data validation - how do I lock down a spreadsheet so I don't accidentally change cell contents?
    The fact that there is no 'undo' button on the iPhone version that I do get on the iPad (same app) makes it worse.. I'm occasionally and unintentionally dragging selections of stuff around the page really hosing up the iPhone spreadsheet.
    So I need to just remember what needs to be updated, update the excel spreadsheet when I can, then delete the iWork-iCloud doc, upload the replacement, then refresh the iPhone/iPad version.. very cumbersome and not at all 'cloud-like' or usefull.
    Apple developers.. are you paying attention?

    Yeah I know that apple likely has the same system as Microsoft in sending general support to a forum such as this. And maybe thae same stupid moron that not paying attention to the forums if their users is a food idea.
    That doesn't change the point of the issue nor that apple directs ,e here to ask said question
    Written in the iPad split soft keypad that covers up the forum post I'm typing. Joy

  • WARNING: Actions on button

    Hi
    I do not understand why I am getting this warning below
    WARNING: Actions on button or MovieClip instances are not supported in ActionScript 3.0.
    All scripts on object instances will be ignored.
    Can someone help?
    mimi

    You can still use pretty much any objects that you have ever used before, though that's not saying they haven't changed in some way. In AS3 to manage things like buttons and other interactions the primary code approach involves creating event listeners and event handler functions.  Here is a description of how you would approach coding a button, though the same could apply to a movieclip....
    Let's say you create a button symbol.  Since it is a button, it is already a self animating object that will react to mouse interactions, but only visually at this stage.  The first thing you need to do to make it useful code-wise is to assign it a unique instance name.  So you drag a copy of it out to the stage from the library, and while it's still selected, you enter that unique instance name for it in the Properties panel... let's say you name it "btn1"
    In AS3, to make a button work with code, you need to add an event listener and event handler function for it.  You might need to add a few (for different events, like rollover, rollout, clicking it, but for now we'll just say you want to be able to click it to get a web page to open.  In the timeline that holds that button, in a separate actions layer that you create, in a frame numbered the same as where that button exists, you would add the event listener:
    btn1.addEventListener(MouseEvent.CLICK, btn1Click);
    The name of the unique function for processing the clicking of that button is specified at the end of the event listener assignment, so now you just have to write that function out:
    function btn1Click(evt:MouseEvent):void {
       gotoAndPlay("site_section");
    Here's some of what's involved there:
    evt:MouseEvent - the event listeners throws an argument automatically which the function must be set up to receive.  In this case I have given that argument a variable name of evt, though I could have chosen anything.
    :void - this defines the class of the value that the function will return.  In this case, the function does not return anything, so "void" is used.  If it did return a value, you would see a line containing "return xyz"; in the function (where xyz is not literal, it simply represents the variable or value being returned) and the :void would be rplaced with some other class such as :String, :int, Date, etc....
    In AS3, in strict mode, it is necessary to identify the types/classes of the variables being created, which is why you see :String, :MouseEvent, etc... showing up everywhere.
    Now, to create another button with a unique function for it, you could just drag another copy of it from the library, give it a unique name, say btn2, copy/paste the code from btn1 and replace "btn1" with "btn2" in that copied code.

  • List data validation failed when creating a new list item but does not fail when editing an existing item

    Dear SharePoint Experts,
    Please help.
    Why does my simple formula work in Excel but not-work in SharePoint?
    Why does this formula...
    =IF([Request Type]="Review",(IF(ISBLANK([Request Date]),FALSE,TRUE)),TRUE)
    ...work in Excel but fail when I try to use it in SharePoint?
    The intent of this formula is the following...
    If the field "Request Type" has the value "Review" and the field "Request Data" is blank then show FALSE, otherwise show TRUE.
    SharePoint saves the formula, but when a list item is saved where the formula is implemented, (under List Settings, List Validation), SharePoint does not, say anything other than that the formula failed.
    Note that the "list data validation failed" error only happens when I am creating a new item-- the formula above works just fine when one is trying to Save on the edit form. 
    Can you help?
    Thanks.
    -- Mark Kamoski

    Dear Jason,
    I appreciate your efforts.
    However, it seems to me that this statement of yours is not correct...
    "If it meet the validation formula, then you can new or edit the item, otherwise, it will throw the 'list data validation failed' error, it is by design".
    I believe this is NOT the answer for the following reasons.
    When I create a new item and click Save, the validation error is "list data validation failed".
    When I edit an existing item and click Save, the validation error is "my custom error message" and this is, I believe, the way it needs to work each time.
    I think, at the core, the error my formula does not handle some condition of null or blank or other default value.
    I tried a forumla that casts the date back to a string, and then checked the string for a default value, but that did not work.
    I tried looking up the Correlation ID in the ULS when "list data validation failed" occurs, but that gave no useful information because, even though logging was set to Verbose, the stack trace in the error log was truncated and did not given any
    good details.
    However, it seems to me that SharePoint 2013 is not well-suited for complex validation rules, because...
    SharePoint 2013 list-level validation (NOT column-level validation) allows only 1 input for all the multi-field validation formulas in a given list-- so, if I had more than 1 multi-field validation rule to implement on a given list, it would need to be packed
    into that single-line-of-code forumla style, like Excel does. That is not practice to write, debug, or maintain.
    SharePoint 2013 list-level validation only allows 1 block of text for all such multi-field validation rules. So that will not work because I would have something like "Validation failed for one or more of the following reasons-- withdrawal cannot exceed
    available balance, date-of-birth cannot be after date-of-death,... etc". That will not work for me.
    The real and awesome solution would simply be enhancing SP 2013 so that column-level validation forumlas are able to reference other columns.
    But, for now, my workaround solution is to use JavaScript and jQuery, hook the onclick handler on the Save button, and that works good. The only problem, is that the jQuery validation rules run before any of the column-level rules created  with OOTB
    SP 2013. So, in some cases, there is an extra click for the enduser.
    Thanks,
    Mark Kamoski
    -- Mark Kamoski

  • Date Validation - a Nightmare for ME!

    Hi, I searched the forum and came up with some code that works for me partially. I am still having problems with getting the end result that is needed.
    I need to do a date validation where the begin date is less than end date. Below is the syntax..It works but when I put in the correct end date i still get the error message athough the date is correct. Also if I set the focus back to the field and correct the date it still set focus back... I'm sure it is something simple that I am missing
    ----- form1.subformpage1.empnsubform.DateTimeField2::exit - (JavaScript, client) -------------------
    if (DateTimeField2.formattedValue>=DateTimeField1.formattedValue);
    xfa.host.messageBox("Incorrect Date range");
    What am I missing? Yes I still struggle with writing scripts!!!!
    thanks

    I have a similar thing on one of my forms, the fields are "Date Submitted" and "Date Needed" and I need to validate that the Date Submitted date occurs before the Date Needed date.  If it does not, it prompts a response dialog box and asks for a new DateNeed to be entered.  Here is the code I used: (I'm by no means an expert at code)<br /><br />//This just sets the values of the date/time fields to variables, and then checks for a null value.  If null, it changes the rawValue to an empty string for inserting into database.  If not null, it leaves the existing rawValue unchanged. Unless you're writing info to a database, you probably wouldn't need this.<br /> <br />var DateSubmit = form1.MainForm.Info.DateSubmitted.rawValue == null ? "" : form1.MainForm.Info.DateSubmitted.rawValue;<br />var DateNeed = form1.MainForm.Info.DateNeeded.rawValue == null ? "" : form1.MainForm.Info.DateNeeded.rawValue;<br /><br />if (DateNeed<DateSubmit)<br /><br />{<br /><br />     var dateResponse = xfa.host.response("The Date Needed date must be later than the Date Submitted date.\nPlease enter new date below: (MM/DD/YYYY format)", "Date Needed Error");<br /><br />     var myDate = new Date(dateResponse);<br /><br />     var myFormattedDate = util.printd("dd mmm yyyy", myDate);<br /><br />     form1.MainForm.Info.DateNeeded.formattedValue = myFormattedDate;<br /><br />}<br /><br />BTW, I have this as code on a submit button that does all of my validations and then writes a new record to a database.  But I think you could also do this on the exit event of the second date/time field if needed. The variable declarations at the top would be slightly different.<br /><br />Lynne

  • Data Validation in web dynpro

    Hi,
    Can anyone explain how to do data validation for the i/p fields in the WD View???Pleasegive an example with coding.
    Thanks!

    Hi,
    As Thomas pointed out in his reply that do the validation at WDDOBEFOREACTION method
    say you have a date to validate:
    DATA lo_nd_importing TYPE REF TO if_wd_context_node.
      DATA lo_el_importing TYPE REF TO if_wd_context_element.
      DATA ls_importing TYPE wd_this->element_importing.
      DATA lv_startdate LIKE ls_importing-startdate.
    navigate from <CONTEXT> to <IMPORTING> via lead selection
      lo_nd_importing = wd_context->get_child_node( name = wd_this->wdctx_importing ).
    get element via lead selection
      lo_el_importing = lo_nd_importing->get_element(  ).
    get single attribute
      lo_el_importing->get_attribute(
        EXPORTING
          name =  `STARTDATE`
        IMPORTING
          value = lv_startdate ).
    if lv_startdate is initial.
    get message manager
    DATA lo_api_controller     TYPE REF TO if_wd_controller.
    DATA lo_message_manager    TYPE REF TO if_wd_message_manager.
    lo_api_controller ?= wd_this->wd_get_api( ).
    CALL METHOD lo_api_controller->get_message_manager
      RECEIVING
        message_manager = lo_message_manager
    report message
    CALL METHOD lo_message_manager->report_error_message
      EXPORTING
        message_text             = 'Please input start date'
       params                   =
       msg_user_data            =
       is_permanent             = ABAP_FALSE
       scope_permanent_msg      = CO_MSG_SCOPE_CONTROLLER
       view                     =
       show_as_popup            =
       controller_permanent_msg =
       msg_index                =
        cancel_navigation        =  'X'    "this parameter will stop the program at the same view
    endif.
    this will stop the user at the same view and will give the error message out.....
    you can also check the code wizard and try different type of methods to give out the error messages....the code wizard is right beside the external break point button...
    Thanks...
    AS.

  • Data Validation in IP before saving

    Dear All,
                  I need to do data validation in IP layout, before data gets saved into cube. For example, i have percentage key figures to plan, which should sum up to 100. if it is not, on clicking on save button, user should get proper error message.
                   Is there any ready made planning function available which does this simple data validation? else, please suggest any other approach to achieve this.
    Thanks,
    Harpal

    Hi Harpal,
    Create a Custom Planning function to check the Percentage and return the expected message.
    for reference : look at class : CL_RSPLFC_CREATE_CR
    it should use syntax :
          if sy-subrc <> 0.
            message enum(messageclass ) with x.
          endif.
    Please let me know if you need further help.

  • Submit data using Jquery/Javascript during button click

    submit data using Jquery/Javascript during button click

    Hi,
    From your description, my understanding is that you want to restrict edit form with jQuery/JS.
    If you want to restrict the default edit form with jQuery/JS, you could refer to these steps below:
    Enter your editform.aspx.
    Add below code under <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">.
    Save this file.
    <script src="https://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    function PreSaveAction(){
    if($("select[id$='DropDownChoice']").val()==""){
    alert("please choose a value!");
    return false;
    return true;
    </script>
    The screenshot below is my result(it will not save data after clicking OK in the message alert):
    If you customize your list with InfoPath, you could check the checkbox “Cannot be blank” under Validation section or add a rule for your validation as the screenshot below:
    In addition, you could check your code with pressing F12 to debug your code.
    Best Regards,
    Vincent Han
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How to maintain dynamic rows with data when click on Previous button?

    Hi,
    I have 1 aspx page and divided into 3 pages using panels.Each panel has "Next" and Previous buttons
    I have created and deleted dynamic table rows when click on Add button using javascript. whenever i click on Next button it will navigate to same page of next panel.
    when i click on previous button then it goes to previous panel but whatever i have added dynamic table rows in 1st panel that got removed.
    Can u please help me for how to maintain state of dynamic table rows with entered data when click on Previous button?
    How to get dynamic table rows with entered data in previous panel when click on Previous button?
    Please find the below javascript code:
    function insertRow() {
    if (index >= 2) {
    document.getElementById('deleteRow').style.display = "inline";
    else { document.getElementById('DeleteRow').style.display = "none"; }
    var table = document.getElementById("myTable");
    var row = table.insertRow(table.rows.length);
    cell1 = row.insertCell(0);
    t1 = document.createElement("select");
    t1.options[t1.options.length] = new Option('--Select--', '0');
    t1.id = "ddlYear" + index;
    cell1.appendChild(t1);
    for (var i = 1975; i <= 2015; i++) {
    opt = document.createElement("option");
    opt.value = i;
    opt.text = i;
    t1.add(opt);
    t1.style.width = "155px";
    var cell2 = row.insertCell(1);
    t2 = document.createElement("Select");
    t2.options[t2.options.length]=new Option('--Select--','0');
    t2.options[t2.options.length]=new Option('State Board','1');
    t2.options[t2.options.length]=new Option('CBSE','2');
    t2.options[t2.options.length]=new Option('ICSE','3');
    t2.options[t2.options.length] = new Option('Others', '4');
    t2.style.width = "155px";
    t2.id = "ddlCourse" + index;
    cell2.appendChild(t2);
    var cell3 = row.insertCell(2);
    t3 = document.createElement("input");
    t3.id = "txtCity" + index;
    cell3.appendChild(t3);
    var cell4 = row.insertCell(3);
    t4 = document.createElement("input");
    t4.id = "txtInstitute" + index;
    cell4.appendChild(t4);
    var cell5 = row.insertCell(4);
    t5 = document.createElement("Select");
    t5.options[t5.options.length] = new Option('--Select--', '0');
    t5.options[t5.options.length] = new Option('English', '1');
    t5.options[t5.options.length] = new Option('Hindi', '2');
    t5.options[t5.options.length] = new Option('Telugu', '3');
    t5.options[t5.options.length] = new Option('Others', '4');
    t5.style.width = "155px";
    t5.id = "ddlMedium" + index;
    cell5.appendChild(t5);
    var cell6 = row.insertCell(5);
    t6 = document.createElement("input");
    t6.id = "txtSpecialization" + index;
    cell6.appendChild(t6);
    var cell7 = row.insertCell(6);
    t7 = document.createElement("input");
    t7.id = "txtFnl" + index;
    cell7.appendChild(t7);
    index++;
    function DeleteRow(index) {
    var table = document.getElementById("myTable");
    table.deleteRow(index);
    // if (index = 2) { alert("There is no rows added.Please add the new row"); }
    Design:
    <tr style="font-size: 12pt" id="trSecond" runat="server">
    <td colspan="3">
    <table id="myTable" width="100%" border="0">
    </table>
    <tr>
    <td colspan="3" align="right">
    <input type="button" title="Add" value="Add" onclick="insertRow();" />
    <input type="button" id="deleteRow" title="Delete" value="Delete Row" onclick="DeleteRow(this);" style="display:none" />
    </td>
    </tr>
    Thank you.

    Put the button click into an action listener and build the new frame there. The code I have below isn't exactly what you're doing (it's amazingly oversimplified), but it's probably similar enough to get your wheels turning in the right direction.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class sample
         public static void main(String[] args)
              JFrame frame = new JFrame("Sample");
              frame.setSize(400,400);
              Container content = frame.getContentPane();
              content.setLayout(new FlowLayout());
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              final JTextField text = new JTextField(10);
              content.add(text);
              JButton button = new JButton("Send");
              content.add(button);
              frame.setVisible(true);
              button.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        JFrame myframe = new JFrame("Results");
                        myframe.setSize(200,200);
                        Container mycontent = myframe.getContentPane();
                        mycontent.setLayout(new FlowLayout());
                        String mytext = text.getText();
                        JLabel label = new JLabel();
                        label.setText(String.valueOf(mytext));
                        mycontent.add(label);
                        myframe.setVisible(true);
    }

  • REUSE_ALV_GRID_DISPLAY standard data validation routine

    I am using REUSE_ALV_GRID_DISPLAY to display data from a custom table and allowing users to edit some fields. When the save button is clicked SAP automatically validates some data fields (for example MATNR) and alerts the user if there is an error. This is great!! But I need to execute some custom code when the user clicks the SAVE button. If SAP has detected an error and is going to pop up the Error Log screen for the user, I do not want to execute my custom code.
    Does anyone know how to determine if SAP has detected problems with the data so I can skip my code and let the normal process flow continue?
    I thought about trying to check if the all field values were valid using my own coding, but when I use the method CHECK_CHANGED_DATA  only valid field values are transfered to my internal table. So invalid fields AND fields that the user did not enter values into are all coming back as blank.
    Here is a small portion of my code.
    FORM user_command  USING    r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
      DATA ref1 TYPE REF TO cl_gui_alv_grid.
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = ref1.
      CALL METHOD ref1->check_changed_data .
      CASE r_ucomm.
         WHEN 'SAVE'.
              "Do some custom coding here if SAP did not detect any errors with data validation
      ENDCASE.
    Thanks for your help,
    David

    Hi,
    In your user_command form
        call function 'REUSE_ALV_GRID_DISPLAY'
          exporting
            it_fieldcat                 = i_fieldcat[]
            is_layout                   = pt_grplayout2
            i_callback_program          = 'YATTU0007'
            i_callback_html_top_of_page = p_header
            i_callback_user_command     = 'USER_COMMAND'
            it_events                   = i_events[]
          tables
            t_outtab                    = i_yatthdr.
    In user_command form
    * Form  user_command                                                   *
    * This form will handle the user command from fm REUSE                 *
    form user_command using p_ucomm type sy-ucomm
                         rs_selfield type  slis_selfield.
      data p_ref1 type ref to cl_gui_alv_grid.
      call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        importing
          e_grid = p_ref1.
      call method p_ref1->check_changed_data.
      case p_ucomm.
        when '&DATA_SAVE'.
       " WRITE YOUR CODE FOR SAVE
      endcase.
      rs_selfield-refresh = c_x.             " Grid refresh
    endform.                                 " User_command

  • Cut and Paste - Data Validation - JEditorPane

    I have an editor in development that uses JEditorPane which is supposed to accept only certain characters as its input.
    Now if I use keystroke I am able to handle the input data entered using keyboard and it seems this is not a good idea :(.
    But, for cut and paste this method does not work. So my questions are,
    1) What is a good way to do data validation for Paste operations
    2) I know that I might need to have a custom document but where do I do the validation in the custom document. I have checked using print statements and for my paste operation, it seems that the insert method in document does not get called.
    3) Is using system clipboard and checking the text before insertion a better option.
    4)What exactly happens when paste ie control C is pressed or paste from menu is clicked. I mean sequence of method calls.
    I know I have asked many questions but answers to any of them will be highly appreciated !!
    Thanks a lot for your help in advance :)

    In my application, I subclass JTextField but you should be able to change it to JEditorPane. Here is a snippet of code that you need:
    public class myTextField extends JTextField implements ClipboardOwner {
       public boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
          if (ks==KeyStroke.getKeyStroke(KeyEvent.VK_V,2)) {     // CTRL-V (paste text from clipboard)
             pasteText();
             return true;
          }   // there is more to my code but this will do
          return super.processKeyBinding(ks,e,condition,pressed);
       private void pasteText() {
          try {
             Transferable contents=clipboard.getContents(this);
             if (contents==null) return;
             int i=getCaretPosition();
             String line=(String)contents.getTransferData(DataFlavor.stringFlavor);
             String tmp=getText();
             int sStart=getSelectionStart();
             int sEnd=getSelectionEnd();
             if (sStart>=0) {
                setText(tmp.substring(0,sStart)+line+tmp.substring(sEnd));
                i=sStart;
             } else {
                if (i<tmp.length()) line+=tmp.substring(i);
                setText(tmp.substring(0,i)+line);
             sEnd=Math.min(i+line.length(),getText().length());
             setCaretPosition(sEnd);
             select(i,sEnd);
          } catch (Throwable t) {
             if (ExtDB!=null) ExtDB.setError("",t);
       public void lostOwnership(Clipboard cb, Transferable transferable) {
    }The above has been formatted to look pretty, the following is more suitable for cut-n-paste:
    public class myTextField extends JTextField implements ClipboardOwner {
       public boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
          if (ks==KeyStroke.getKeyStroke(KeyEvent.VK_V,2)) {     // CTRL-V (paste text from clipboard)
             pasteText();
             return true;
          }   // there is more to my code but this will do
          return super.processKeyBinding(ks,e,condition,pressed);
       private void pasteText() {
          try {
             Transferable contents=clipboard.getContents(this);
             if (contents==null) return;
             int i=getCaretPosition();
             String line=(String)contents.getTransferData(DataFlavor.stringFlavor);
             String tmp=getText();
             int sStart=getSelectionStart();
             int sEnd=getSelectionEnd();
             if (sStart>=0) {
                setText(tmp.substring(0,sStart)+line+tmp.substring(sEnd));
                i=sStart;
             } else {
                if (i<tmp.length()) line+=tmp.substring(i);
                setText(tmp.substring(0,i)+line);
             sEnd=Math.min(i+line.length(),getText().length());
             setCaretPosition(sEnd);
             select(i,sEnd);
          } catch (Throwable t) {
             if (ExtDB!=null) ExtDB.setError("",t);
       public void lostOwnership(Clipboard cb, Transferable transferable) {
    }This will force the paste action to trigger a call to insertString.
    ;o)
    V.V.
    PS: my preference for the use of processKeyBinding has been labled inappropriate, the proper method according to the experts in this forum is to use a combination of InputMap/ActionMap.... so, you decide what you want to do.

  • How to make custom data validation on standard form.

    Hi,
    I have some little OAF experience. I have extended VO so far but I am still newbie.
    I need to make custom data validation on standard form.
    I Oracle Credit Management module on "Create Credit Application: Applicant" form I need
    to validate chosen currency against customer setup (whether there is customer profile amount for the currency).
    The page is /oracle/apps/ar/creditmgt/application/webui/ARCMCREDITAPPPAGE
    There are controllers on the page:
    oracle.apps.ar.creditmgt.application.webui.creditAppContentFooterCO 115.14.15104.2
    oracle.apps.ar.creditmgt.application.webui.creditApplicationPageCO 115.6
    oracle.apps.ar.creditmgt.application.webui.creditAppRegion2CO 115.13.15104.2
    oracle.apps.ar.creditmgt.application.webui.creditApplicationCO 115.8.15104.3
    oracle.apps.ar.creditmgt.application.webui.creditAppRegion1CO 115.28.15104.4
    oracle.apps.ar.creditmgt.application.webui.creditAppBusBackCO 115.6
    oracle.apps.ar.creditmgt.application.webui.OCMApplicantInfoRNCO 115.4
    creditApplicationPageCO is pageLayout controller.
    Please direct me how to achieve it.
    Which controller should I extend (if any)?
    How to get values from the page (customer site id, currency) and how to run custom sql in my CO class ?
    Regards,
    Marcin

    Hi Marcin,
    You have to find your GO button is handled in which standard controller, (if you click on the about this page, you should be able to identify the controller,
    or you can download all the controller .class files and decompile and check the logic).
    Then extend that controller(which has the Go button logic, you can see how it has been handled.),
    The usual way to check is
    if(pageContext.getParameter('<Go button name>') !=null)
    Since you want to validate first your custom validation, in the extended controller ProcessFormRequest
    dont call the super.processFormRequest unless your validation is success.
    Call the super at the end.
    Inside your extended controller you have to find your AM and then your required ViewObject to get the user entered values.
    Thanks,
    With regards,
    Kali.
    OSSi.

Maybe you are looking for