Struts validator for two fields(conditional required)

Have a Drop down and an input field.
When user selects "Type 1" from drop down only then the input field is required. otherwise it's not a required field.
Looking at the validator guide in struts maybe I have to create a new validator rule which should check if drop down value "Type 1". But not sure how to code to say that the input field is required here.
How to do this?
Thanks.

Yes you have to check for drop down value "Type 1".
when you hit on submit it goes to the validation function right ...
there add a condition. Check if tpe 1 is selected , if so proceed validation the text box , else skip that validation and come out.

Similar Messages

  • How to use same Data Type and Length for two fields

    How to use same data type and length for two fields when using 'FOR ALL ENTRIES IN' in a select statement? For instance the select queries are :
    SELECT bukrs gjahr belnr lifnr budat bldat zlspr dmbtr waers shkzg
    FROM bsik
    INTO TABLE it_bsik
    WHERE bukrs = p_bukrs
    AND lifnr IN s_lifnr.
    IF it_bsik IS NOT INITIAL.
    SELECT belnr gjahr awkey awtyp
    FROM bkpf
    INTO TABLE it_bkpf
    FOR ALL ENTRIES IN it_bsik
    WHERE belnr = it_bsik-belnr
    AND gjahr = it_bsik-gjahr.
    IF it_bkpf IS NOT INITIAL.
    SELECT belnr gjahr lifnr xblnr
    FROM rbkp
    INTO TABLE it_rbkp
    FOR ALL ENTRIES IN it_bkpf
    WHERE belnr = it_bkpf-awkey+0(10)
    AND gjahr = it_bkpf-awkey+10(4).
    ENDIF.
    ENDIF.
    Here it gives an error in the 3rd select query that 'When you use the addition "FOR ALL ENTRIES IN itab", the fields "GJAHR" and "IT_BKPF2-AWKEY+10(4)" must have the same type and the same length.'
    Kindly clarify.

    Hi Saurabh,
    Please see the example code that I have developed for you. It will help you solve the problem.
    REPORT ZTEST_3 .
    tables : BKPF.
    data : begin of it_bkpf occurs 1,
             belnr type RE_BELNR,
             awkey type awkey,
             awtyp type awtyp,
             gjahr type GJAHR,
           end of it_bkpf.
    data : begin of it_bkpf1 occurs 1,
             belnr type RE_BELNR,
             awkey type gjahr,              " change the data type
             awtyp type awtyp,
             gjahr type GJAHR,
           end of it_bkpf1.
    data : begin of it_rbkp occurs 1,
             belnr type BELNR_D,
             gjahr type gjahr,
             lifnr type LIFRE,
             xblnr type XBLNR,
           end of it_rbkp.
    select belnr
           awkey
           awtyp
           gjahr
           from bkpf
           into table it_bkpf
           where BUKRS = 'TELH'.
    loop at it_bkpf.
    it_bkpf1-belnr = it_bkpf-belnr.
    it_bkpf1-awkey = it_bkpf-awkey+10(4).           "Here only append the required length.
    it_bkpf1-awtyp = it_bkpf-awtyp.
    it_bkpf1-gjahr = it_bkpf-gjahr.
    append it_bkpf1.
    clear it_bkpf1.
    endloop.
    select  belnr
            gjahr
            lifnr
            xblnr
            from RBKP
            into table it_rbkp
            for all entries in it_bkpf1
            where belnr = it_bkpf1-belnr
    This is just an example. Change the fields according to your requirement.
    Regards
    Abhii
    Edited by: Abhii on Mar 9, 2011 9:08 AM

  • AT NEW command for two fields

    Dear All,
    How to use AT NEW command in internal table for two fields.
    Warm Regards,
    N.Jain

    Hi
      See the following code. It is useful for u.
    DATA: BEGIN OF ty_batest,
            designation TYPE zba_test-designation,
            salary TYPE zba_test-salary,
            empno TYPE zba_test-empno,
            empname TYPE zba_test-empname,
            address TYPE zba_test-address,
          END OF ty_batest,
          it_batest LIKE TABLE OF ty_batest,
          wa_batest LIKE ty_batest.
    SELECT * FROM zba_test INTO CORRESPONDING FIELDS OF TABLE it_batest.
    SORT it_batest BY designation salary.
    LOOP AT it_batest INTO wa_batest.
      AT NEW designation.
        WRITE: / 'Designation  :', wa_batest-designation,
               /(35) sy-uline.
      ENDAT.
      AT NEW salary.
        WRITE: / 'Salary : ', wa_batest-salary,
      ENDAT.
      WRITE: / 'Emp Name    : ', wa_batest-empname,
              / 'Emp Number  : ', wa_batest-empno,
              / 'Designation : ', wa_batest-designation,
              / 'Address     : ', wa_batest-address,
              / 'Salary      : ', wa_batest-salary NO-ZERO .
      SKIP.
    ENDLOOP.
    Regards
    Bhuvana.

  • How to make a validation for a field?

    Is any possible to make input value
    validation for a field?
    E.g. Force the user enter ItemCode in a
    correct format with proper prefix XX-BB-.... .
    If SDK is a only solution, how to do it?
    Regards,
    Kenneth

    You can't realy do it with out sdk. You could always try to right a query that will clear the code when it isn't in the correct format. then if they press add it will give an error cause there is no item code. But you'll struggle to get this right and it won't be full proof.
    In sdk in your item event you'll test if the specific edit box lost focus and before the action, if that is true then check the value. If it is not correct then bubble the event and give an error. when you bubble the event it won't do the action they wanted to do.
    Hope this helps.

  • Subtotal and grand total for two fields(iseg-buchm and iseg-erfmg)

    hi experts,
        how to do subtotal and grand total for two fields (iseg-buchm and iseg-erfmg).please help me on solving the problem.

    subtotal & grand total can be done in folowing way in ALV.
    1.Pass it_sort parametere to REUSE_ALV_GRID_DISPLAY
    2.Give the field name for sorting in it_sort-fieldname. it can be any field name  u want to sort ur data with.
    3.For iseg-buchm & iseg-erfmg mark do_sum = 'X'. in fieldcat
      gs_sort-spos = 1.
      gs_sort-fieldname = 'ANY FIELD NAME'.
      gs_sort-up = 'X'.
      gs_sort-subtot = 'X'.
      APPEND gs_sort TO et_sort.
      IF iv_fieldname = 'BUCHM'
      OR iv_fieldname = 'ERFMG'.
        gs_fieldcat-do_sum = 'X'.
      ENDIF.
      APPEND gs_fieldcat TO gt_fieldcat.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
           is_variant              = ev_variant
          it_fieldcat             = gt_fieldcat[]

  • How to exclude Required Validation for some fields?

    Hi,
    I have a page in a form with some fields that are set as required like this:
    Field 1   Field 2
    table
    Field 3   Field4 "Add" button
    Field 5    Field 6
    "Submit" button
    There are two buttons in this form. The "Add" button is PPR allows adding Field 3 and Field 4 to the table. The "Submit" button is for the actual submission and processing. When "Add" button is pressed, I only want the require validation to be done for Field 3 and Field 4, but not Field 1/Field 2/Field 5/Field 6.
    Currently, if I press "Add" button, the required field validations are triggered for all six fields. How can I only limit the require validation to some required fields only for this button?
    Thanks
    -Mina

    subform is a great idea and kinna what I needed in this situation, but there is another challenge.
    In my case, I tried to put table, Field 3 and Field 4 in subform:
    Field 1 Field 2
    <af:subform>
    table
    Field 3 Field4 "Add" button
    </af:subform>
    Field 5 Field 6
    "Submit" button
    When I press "Add" button, Required validation still triggered for all fields. Only if I put Field 1 and Field 2 in another subform, and Field 5 and Field 6 in a different subform. Then it works like this:
    <af:subform>
    Field 1 Field 2
    </af:subform>
    <af:subform>
    table
    Field 3 Field4 "Add" button
    </af:subform>
    <af:subform>
    Field 5 Field 6
    "Submit" button
    </af:subform>
    But in my case, I need Field 1, Field 2, Field 5, Field 6 and "Submit" button to be in the same subform, as the "Submit" button applies to these four fields. In the UI design, Field 3 and Field 4 are between Field 1/Field 2 and Field 5/Field 6 though.
    Any other ideas?

  • Data validation for Date Field in Web Dynpro ABAP

    Hi ,
    In my WDA i want to perform data validation for date filed. (i.e. While creating a new record i have to check the Start Date should be always lesser than End Date.)
    If u ll enter the wrong date it should validate the Date and throw an error message.
    Please Reply soon its urgent.
    Thanks,
    Deepika

    Hi,
    First read the two attributes start date and end date.
    Then write the following condition.
    IF item_start_date > item_end_date.
    Error message.
    Endif.
    For pop up error message you need to use Create_window method of the Interface if_wd_window.
    Thanks.

  • Can I make certain fields conditionally required?

    I am TOTALLY new to acrobat- just to put that out there first. I am wondering in acrobat (NOT formscentral or indesign) how to make certain fields required based off the answer of the previous required field.
    I.E  first required field- "is this a single application?" if so, do NOT make the next few fields required
    "is this a joint application?" if so, make the next rew fields required.
    Can I get some help with this?
    Thanks!

    What is commonly done is a button is used to initiate the email, using a "Submit a Form" action and specifying the email address of the recipient. The submit will fail if any fields that are marked as required are blank. In your case, you need to set the required property of certain fields conditionally, based on the sate of the form, and this will require a bit of scripting. It's not overly complicated though and you can get some help here.
    The Acrobat help document is a good place to start, though it won't help with JavaScript programming. A good resource is AcrobatUsers.com where there are a number of tutorials and other resources available about forms.
    Be aware that submitting form by email is often less reliable than expected, for many different reasons. A more reliable and secure approach is to set up the form to submit to a web server, but this involves even more expertise as it involves server-side programming and interacting with a PDF form. Emailing may seem sufficient for your needs, but be aware of the alternatives.

  • Validation for text field: Null and contains no spaces

    Currently on APEX 3.2
    I want to check 1 text field and 2 text areas to ensure they are not null and blank (hitting the space bar in the field) before submitting the page. How do I do both validations for on each field?

    I created a validation with a type of 'Function Returning Boolean' and using the following code in the expression:
    IF( TRIM( :P1_Text_Field) IS NULL
    Or LTRIM( :P1_Text_Field ) != :P1_Text_Field )
    THEN
    RETURN false;
    ELSE
    RETURN true;
    END IF;
    Edited by: Jeremy_F on Apr 12, 2012 8:15 AM

  • F4 help for two fields in screen

    hello,
    I have two fields in my table control which need F4 help in the screen.
    But one F4 search exit is implemented, but it populates only one field.
    but, on clicking f4 for one field, it should populate both the fields together.
    do help me with this issue...
    Can POH in the screen populate up two fields together???

    Hi Krithika ,
    In addition to checking up the export parameters for the Search healp you will have to define the Search Help attachment also. I'll paste the SAP Help Text below but in Simple terms
    You Define a structure with the fields to be returned and define the screen elements based on that structure . So on selection the structure is returned with all values and the screen elements are in referance to structure so all values get posted in screen.
    Here is the SAP HELP part
    "" From SAP HELP
    A search help attachment is an assignment of a search help to a table, structure or data element, causing the corresponding search help to be automatically used to describe the input help process at this field when an ABAP Dictionary field is used in a screen.
    You can attach a search help as follows:
    1. Attach a search help to a structure or table field: The attached search help is available for all screen fields that refer to the table or structure field. There must be an assignment between the interface parameters of the search help and the fields of the table or structure for this type of attachment. In the input help process, this assignment results in a value transport between the corresponding fields (if they are known at least to the module pool of the screen) and the search help parameters. As for the foreign key definition, you can assign nothing, a constant or any other field (which is then sought in the module pool) to indivdiual search help parameters.
    2. Attach a search help to a table: The assigned search help is available for all screen fields for which the table is a check table. There must also be an assignment between the search help parameters and the key fields of the table for this type of assignment.
    3. Attach a search help to a data element: The attached search help is available for all screen fields that refer to the data element. If the search help is attached to a data element, an export parameter of the search help must be assigned to the data element. If the user chooses a row of the hit list in the input help, the contents of this parameter are returned in the corresponding screen field. More than one value is not returned when a search help is attached to a data element.
    The described attachments only take effect if the field was not yet assigned an input help in the screen definition. Such an assignment can be made with the mechanism PROCESS ON VALUE-REQUEST in the flow logic or by attaching a search help to the screen field in the attribute maintenance screen. A F4 help can also be assigned to the field in the flow logic by using VALUES or SELECT. In the latter case, the input help here behaves as if the table specified under SELECT were assigned to the field as check table.
    If more than one of the described mechanisms compete in defining the input help method of a screen field, the first one named will take effect. If none of the described mechanisms is available, the domain fixed values of the field will be used for the input help if necessary. If the domain of the field has no fixed values but has data type DATS or TIMS, the input helps that are assigned to these types are used for the input help. Otherwise there will be no input help available for the field.
    A search help attachment always belongs to the definition of the object to which the attachment is made (structure, table or data element). It is also maintained in the maintenance transaction for this object and transported with this object.
    <b>REWARD IF USEFUL. It Works for me here..get back if any doubts.</b>

  • OVS for two fields in the same selct Option?

    Hi Experts,
    I am using select options in my view. I am using OVS for one field. I would like to use same OVS for another field in the same select option.
    I tried "case ovs_callback_object->context_attribute". Which return the field for which we press F4.
    But IT did not work here probably because this we can use only for context attributes fields.
    but But here I dont get the select option field.
    But in my case I have select options which are not mapped to any context attribute.
    How can I find , for which field in select options F4 help has been requested?
    Regards,
    Vishal.

    Hi,
    You can find which field in select options F4 help has been requested using I_OVS_DATA-M_SELECTION_FIELD_ID.
            CASE I_OVS_DATA-M_SELECTION_FIELD_ID .
                 WHEN 'PERNR'.
                 WHEN 'ENAME'.
                 WHEN OTHERS.
            ENDCASE.
    If you are using one OVS for more than one fileds, please remember that you need to provide different code for each fields at phase 0 (configuration) and phase 3 (apply result).
    Regards,

  • Struts Validator for Struts 1.2

    Dear all,
    I have migrated to Struts 1.2 and observed the problem with action form validation. What is strange is that every thing seems working. But if you look at the log file, you can realise that the validation did not work and there are the following exceptions. Moreover, the exception did not stop the program to continue (this gives the wrong impression that every thing working).
    Best regards,
    Pengyou
    11:31:53,463 ERROR [ValidatorForm] org.apache.struts.util.StrutsValidator
    org.apache.commons.validator.ValidatorException: org.apache.struts.util.StrutsValidator
         at org.apache.commons.validator.ValidatorAction.loadValidationClass(ValidatorAction.java:646)
         at org.apache.commons.validator.ValidatorAction.executeValidationMethod(ValidatorAction.java:555)

    well, the only way this can be happening is if you have your ActionMessages object in request with errors in it. This sounds like something strange is happening in your LoaderAction class for that JSP. Sounds like you are executing the validate method when you are loading this page. Check your loaderAction class to ensure you are not validating upon load. You should be validating upon post. Remember, when loading, unless your loaderAction class has prepopulated some attributes on your form bean, everything is null in request. Therefore, you validate to ensure that certain fields are not null, the errors will be caught and shown on the page.

  • Important : how to create a  validation for table field.

    Hi all,
    I have created a table in which i have date field of format MM/DD i.e char 5.
    i want validation that if user creates a entry in date field then if he enters first two digit more then 12 then validation must be their that please enter first 2 digits from 1-12.
    similarly for last two digitsi.e it must be from 1-31
    so how can i provide this validation.
    if u have any confusion in understanding the query please revert.

    Declare 3 variables
    DD(2) type char
    MM(2) type char
    Temp(2) type char
    Date(5) type char
    Get the DD and MM value from your date field
    if MM > 12.
        temp = MM.
        MM = DD.
        DD = temp.
    endif.
    Then concatenate MM & DD into date and save
    Hope it helps!
    Regards,
    Ashok

  • 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

  • Separating values for two fields which is have same search help

    Hi Folks,
    I have one requirement like this. i have 2 fields in MM02 t-code. if i see F4 for those 2 fields it is showing 7 values in that search help. both fields are having same search help so that it is showing same 7 values for these 2 fields. but i want to separate this. if i click on the first fields then it has to show first 3 fields and if i click 2 field it has to show rest 4 fields. can any one suggest what to do for this. these 2 fields are not having search help exit and this one im doing in ECC 6.0.
    Regards..
    kanna

    Hi Rajesh,
    Your are mention related to MM02 which is standard t-code. I am not sure it is possible for that. It can be restrict through code level only..
    Regards,
    Kumar

Maybe you are looking for

  • How to rename folder in Final Cut Pro X project library?

    How to rename folder in Final Cut Pro X project library? I can't double click on folder, when I right click it just gives options to erase. Can someone help?

  • Firefox is only displaying one of the two user profiles on my computer

    I just added my husband onto my computer by creating a user profile for him. It seemed fine at first, but then it disappeared.After researching the problem I think what probably happened was that I forgot to uncheck the "Don't ask at start up" box in

  • Maintain Customs vendor in condition type

    Dear all, We have seperate pricing procedure for imports,we manually capture required customs duties in condition types in purchase order,Subsequently we need to do customs miro,for that we need to maintain customs vendor for every condition type, Si

  • Importing recordings

    Can you import a voice recording from an olympus voice recorder and burn it to a cd?  Please advise how to do it if it can be done.

  • 2007 macbook that will not start

    I have a 2007 macbook that will not start.  I get the gray screen with the apple icon,  spinning circle and the process bar will move a little.  I have tried command and r keys while booting but nothing happens. can anyone help me get it started?