cancel
Showing results for 
Search instead for 
Did you mean: 

Validations - client side

sridhar_k2
Active Contributor
0 Kudos

Hi,

I want a string to validate. I declared a simple type in dictionary for that string with fixed length as '4' and it is working fine.

But the problem I'm facing is that when I want to clear(Clicking Clear Button) by entering less than 4 characters in that field, it is validating and giving message as ' Length of String " " has not expected fixed length 4'.

I want this validation happen only when I click actions like save and but should not work for actions like clear.

Is there any ways that i can bypass this validation some times?? or how can i clear that field??

regards,

Sridhar

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member181879
Active Contributor
0 Kudos

In summary: Web Dynpro does <b>NOT</b> support any form of custom JavaScript during rendering. It is a closed rendering model. This has positive and negative sides. Let us accept the status-quo as it will definitely not be changed in any (near) future, and further debate about why it is a "good thing" will not change our opinion on this topic. See also email extract below.

As such, we consider this topics now as closed.

regards, brian

EXTRACT FROM AN EMAIL WRITTEN:

Yes, we are aware, and have been for a long time that if you should load JavaScript into an <iframe> you can hack parts of the rendered Web Dynpro pages. However, this is not kindergarten. If you shoot yourself in the foot, it is going to hurt, and we can not help. Our basic recommendation at this stage will always be: never do it, you will regret it!

Here some basic aspects for you to keep in mind:

(1) Already the one example you have made available for testing failed with JavaScript errors in my browser. So any hack you attempt will have to be tested for scenarios: different browsers (and versions thereof), right-to-left rendering, different rendering when accessibility mode is active.

(2) The HTML that is rendered changes effectively per service pack, expect at least dramactic change after about three service packs.

(3) Also the rendering framework(s) we use change with service packs, for example suddenly a different technique is used to DOM inject rendered code, etc.

(4) In later service packs, depending on rendering, we start to use very short (cryptic) ids, that are generated on the fly. These have no relationship to the IDs you use/see in the workbench. So you have no way in the browser to now decide what controls you wish to influence.

(5) iframe control is already flagged as deprecated. There are also techniques we can use to prevent you from using JavaScript from your iframe to ours (still under consideration.)

In principle, using such an approach in a customer solution is gauranteed to blowup sooner than later. It is not industrial strength, and will just not fly.

We can understand that when Web Dynpro "works as designed" it is not always "works as expected". And it is true that new features you require are far in the future. But nevertheless, it is recommended to take the time to write us the problems you face. Maybe if you describe specific problems on the forum, people have other alternative ideas. Or update Armin's thread on things you would like to place on the wish list. We can not promise, but we do read the list!

former_member182372
Active Contributor
0 Kudos

Hello Sridhar,

You have 2 options for this:

1) Use non-validating action handler(search doesn`t work on SDN, so I can`t find appropriate article) and do all validation there.

2) Create context attribute(needExplicitClear). In action handler set to true. In wdDoModifyView check whethre variable is true and put something like:

final IWDInputField inputField = (IWDInputField)view.getElement("inputField");
inputField.setValue("");
//set needExplicitClear to false

And you have to set needExplicitClear to false in wdDoInit.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Sridhar,

If u r using WebDynpros we use Message pools to sort out these issues.Check the URL Below which will be of great use.

http://help.sap.com/saphelp_nw04s/helpdata/en/d1/1937e802d4ef4597fa14c48e66ca5d/frameset.htm

If u r using JSPDynpages we need to write the java script in Scripts Tag.Call the function into the controller of the Action Button Click and then ur issue can be easily solved.

sridhar_k2
Active Contributor
0 Kudos

I am doing it in web dynpro. So i cant use java script.

I can get the same functionality by using context attributes but, i can't restrict entering the text to 4 chars only.

How can i get two functionalities ..

roberto_tagliento
Active Contributor
0 Kudos

Really you can

I am writing a document, tomorrow or next tomorrow, i will post a document on how insert custom javascript into a Web Dynpro.

And i hope that it will become a Web blog.

Bye

Former Member
0 Kudos

Forget it. In older versions maybe you could do this by (ab-)using certain properties of UI elements, in newer versions this will be checked at runtime and an exception will be thrown.

Armin

roberto_tagliento
Active Contributor
0 Kudos

No no

I use SP13 and don't (ab-)use certain properties.

It's fantastic on how is easy 😛

And it's will function always, also for future realese.

Because is completely indipendent from j2ee engine.

Message was edited by: Roberto Tagliento

Former Member
0 Kudos

Ok, go for it. By the way, the IFrame element will be deprecated after NW04.

Armin

roberto_tagliento
Active Contributor
0 Kudos

Noooooooooooo

ouch!! Damn!!! 😛

You kill me

Hope that from NW04 javascript will be supported better

Message was edited by: Roberto Tagliento

Former Member
0 Kudos

Gotcha

Javascript is not part of the Web Dynpro programming model (for good reasons IMHO). There are Web Dynpro clients that do not support Javascript at all (e.g. smart clients, some Mobile clients) so using Javascript inside an application would restrict it to the browser based clients.

Armin

former_member182372
Active Contributor
0 Kudos

Hello Sridhar,

Did you try my suggested solution with direct access to UI element?

Best regards, Maksim Rashchynski.

roberto_tagliento
Active Contributor
0 Kudos

I don't understood very well this choice, it's true that smart clients and some Mobile clients don't support very well javascript; but a developer knows for what client the Web Dynpro will be realized, better surely he knows if he is developing a Web Dynpro for smart clients and some Mobile clients.

As we have in java, there is "J2SE" and there is "J2ME".

By the way, i don't think that IFRAME could be deprecated so soon, this is not funny.

SAP tend to maintain the versioning for at least 3 release, i know (see BAPI).

There is some official announcement about deprecation of IFRAME, i understand that you are a SAP AG employee, but i need more confimation on what you say to me ?

EPCF will be improved?

Thanks and bye

roberto_tagliento
Active Contributor
0 Kudos

Someone could answer me?

Bye