cancel
Showing results for 
Search instead for 
Did you mean: 

Validation of inputs in Web Dynpro

Former Member
0 Kudos

Hi,

I have created an application in which i have 3 input fields. For each input field i need to keep some validation. Say i need to have validations like limit of 8 chars for a particular field, no special characters, should not be blank. How do i go about achieving this in Dynpro. Could you please let me know the details of the same.

thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sunil,

I hope the below link will be helpful to you.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/edf6ea90-0201...

Regards,

Sirisha.

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Sunil,

Have you created the plugs?

Try this link...It'll guide you in creating your application https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/webdynpro/tu... on creating your first web dynpro application - 1.htm

If you have already created the plugs write these lines of code in your event handler method of the button.


if(wdContext.currentContextElement().get<your_att_name>().equals("first page or something")
wdThis.wdFire<Plug1_name>()
else
wdThis.wdFire<Plug2_name>()

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Hi Sunil,

If your requirement is to navigate to different views from a view depending on some user input, you needn't use the controller mapping.

1) Create the source views & embedd them into the same window.

2) Open up the window Diagram view & define plugs from the source view to the target views.

3) In the event handler for the submit button, read the user input from the context attribute and depending on the user input fire the corresponding plug.

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Hi Nibu,

As you said i have associated the context with the UI element. Now how do i write the code in the 'Submit' Action .Please tel me. I have 2 attributes under a node in the context.

thanks

Former Member
0 Kudos

Hi Sunil,

1) you have to create an attribute of your simple type. In case you are not familiar with creating attributes, this is the way to proceed :

In your view, go to your context tab, right click on 'Context' create a new Value attribute. Right click on the created attribute, select 'properties'. Click on the 'type' property of the attribute, click on the small button displayed at the right most end, from 'Local Dictionary' naviage to your simple type and select that.

2) create the UI element, go to it's properties. For the 'text' property , select the attribute you created.

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Hi Nibu,

Creation of type and linking with an attribute is done.

But i am facing a problem in step 2)

i am validating an 'input field' and i am unable to find a property called 'text' in which i can select the attribute i created. There is only the 'value' property where i bind it with the context of the view controller.Please help...

thanks

Former Member
0 Kudos

Yes that is where you have to bind it.

Former Member
0 Kudos

We intentionally called this property "value" instead of "text" because an InputField can not only edit string values but also dates, integers, strings with value sets etc.

Armin

Former Member
0 Kudos

Hi all,

This is how far i have reached.

1. I have created the context for the 2 input fields and kept the attributes for these as the 2 simple types i have created.

2. I have mapped these contexts to my comp controller and bound the view context to the UI elements(input fields).

3. I have created an action 'Submit' which takes me to a new view.

Now what condition should I give in the 'Submit' event as the validation is not takin place right at this moment. When i click the button it takes me to the 2nd view no matter what input i give

thanks

former_member182372
Active Contributor
0 Kudos

Is "Without Validation" flag for action "Submit" unchecked?

Former Member
0 Kudos

Yes it is unchecked.

Former Member
0 Kudos

Hi Sunil,

To create the simple type :

1)In your project go to Dictionary->Local Dictionary -> Data types -> simple types. Right click and create a new type. The new type will open up with the default 'Definition' tab view. There you can find the options for defining the data type, length etc...

Hi Maksim,

You are absolutely right. We cannot restrict special characters through this method.

Best Regards,

Nibu.

Former Member
0 Kudos

Hi Nibu,

I have created a simple type and set the max. length to 4. Now please tell me how i can associate this created type with my input field?

thanks

Former Member
0 Kudos

Just set type of the Context attribute mapped to the InputField to the SimpleType as I have explained in my earlier post.

Former Member
0 Kudos

Hi Sunil,

The best way to do this is to create a simple type say 'mytype' in the local dictionary with all the restrictions you want to. Then make attributes of this type and map the 'text' property of the input fields to them.

Hope this helps,

Best Regards,

Nibu.

former_member182372
Active Contributor
0 Kudos

Hello,

to Nibu Wilson:

but how to exclude special characters using this approach?

to SUNIL HS:

Try nice Valery`s blog /people/valery.silaev/blog/2005/06/29/apojo--almostplain-old-java-objects-as-model

It seems complicated for first time but it can help you definitely.

Best regards, Maksim R.

Former Member
0 Kudos

Hi Nibu,

Could you please ellaborate on the steps you just told me.

1.How do i place th erestrictions in 'mytype'?

2.What do you mean by make attributes to the type?

Sorry if they are silly Qs but im new to Web Dyn and never used the local dictionary before. So a liitle extra help is needed to get me through this

thanks

Former Member
0 Kudos

When you open the simple type you will get the tabs to set the restrictions.

In the properties of the attribute select the browse button and in the local dictionary go to the folder in which you have created the simpletype and set the attribute to that particular type