Skip to Content
author's profile photo Former Member
Former Member

Validations in Web Dynpro Java

Hello,

I'm trying to create a lot of validations in a web dynpro App.

Examples:

- An inputfield must not pass 6 characters of length. (I can set the inputfield length of 6 characters but I can't force the inputfield to accept only 6 characters).

- Some fields (inputfield, textEdit, dropdownByKey) are mandatory. (I can see the property state = "required" but I don't know how it works)

- Some field are mandatory depending in a previous selection.

I'm finding that adding this validation logic to the form is very heavy and implies a lot of work. I want to ask if someone knows an easy and automatically way to add this validation logic to the app, or I can't escape of programing everything.

Please help.

Regards

SU

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on Dec 07, 2011 at 04:55 AM

    you have to do it manually.

    for the input field length, i think you can limit it in dictionary.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 07, 2011 at 06:53 AM

    Hi,

    You have to do manually. Itu2019s not comes automatically.

    Examples:

    - An inputfield must not pass 6 characters of length. --- By using Dictionary. Go to dictionary you can create one Simple Data type. You can put that length having 6 characters. That data type you can bind to the your value attribute.

    - Some fields (inputfield, textEdit, dropdownByKey) are mandatory. -


    Here you can put Condition.

    If()

    {

    If input filed length is equals to null(Please Enter Value) not null condition True.

    }

    Else

    {

    }

    Best Regards

    Vijay K

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 07, 2011 at 07:14 AM

    Hi,

    - An inputfield must not pass 6 characters of length. (I can set the inputfield length of 6 characters but I can't force the inputfield to accept only 6 characters).

    Yes, you can force the input field to accept only 6 characters with the help of simple types. Create a simple type in your DC and in the defination tab, set the maximum length as 6. Create an attribute of type this simple type. bind this attribute with the input field and you'll get the desired result.

    Regards,

    Arjun

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 07, 2011 at 07:19 AM

    Hi,

    Some fields (inputfield, textEdit, dropdownByKey) are mandatory. (I can see the property state = "required" but I don't know how it works)

    You can try to use the checkAndReportRequiredFields() method to check mandatory fields. Check the [javadoc|http://help.sap.com/javadocs/NW73/SPS02/CE/wdr/com.sap.wdr/com/sap/tc/webdynpro/progmodel/api/IWDViewController.html] for the method.

    I hope it helps.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi SU,

      I wrote the following code just to check if this method works or not. Well, this method does work.

      Ceate a message in the message pool and use the following code

      IWDNode node = null;
      wdControllerAPI.checkAndReportRequiredFields(node ,IMessageNew1Comp.VALIDATION__MESSAGE, new Object[]{"test"});
      " in my case the attribute bound to the input - whose state is required - is in root container. 
      "That's why I am passing null as first parameter.
       

      Validation_Message is the message key

      "test" is the message which you could pass to the passholder

      I hope it helps.

      Edited by: Arjun Singh Thakur on Dec 9, 2011 11:32 AM

  • author's profile photo Former Member
    Former Member
    Posted on Dec 07, 2011 at 07:22 AM

    Hi,

    For inputfileds you can restirct the length by taking a dictionary simple type object. Specify the max length in length constraints and bind this to the context attribute.

    For input fields, text edit you can keep the property state as required and for labels set the property label for with the corresponding ui element id.

    If some fields has to be made mandatory basing on the previous selection, you can have a context attribute with type state in uielementdefinitions(com.sap.ide.webdynpro.uielementdefinitions.State) and in the action specify those fields state as required.

    Hope this helps you..let me know if you need more help on this.

    Regards,

    Saleem Mohammad.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.