cancel
Showing results for 
Search instead for 
Did you mean: 

Field Validation

Former Member
0 Kudos

Hello everybody.

I wrote a validation function that validates the input fields in my View. It works fine, but there is a problem:

I need to call it on every "save" action, for example. To automate the process, I intend to use AOP.

Does anybody has a better solution?

IS There any problem in my solution?

Thanks.

Accepted Solutions (0)

Answers (3)

Answers (3)

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Alexandre,

exactly for this purpose the Web Dynpro for Java programming model provides a special hook method called wdDoBeforeNavigation() (inside the component controller).

Here an excerpt from the corresponding Web Dynpro help text:

<i><b>Navigation Preparation – wdDoBeforeNavigation()</b>

When executing large Web Dynpro applications, it might not be sufficient to ensure the consistency of the user entries by checking the individual contexts or all controller contexts within a single Web Dynpro component. SAP recommends that before you trigger a navigation change, you should check whether controller contexts of several Web Dynpro components contain valid data.

The Hook method wdDoBeforeNavigation() in the component controller allows you to execute such extensive and cross-component checks and display error messages, if necessary. This method is called by the Web Dynpro runtime before each processing of the navigation targets that have been accumulated till then. Only when the check is terminated, the Web Dynpro runtime assembles all views visible on the user interface (the new view assembly), initializes the view controller instances that have not been created yet and processes there the inbound plug event handlers defined by the navigation targets.</i>

Although you cannot introduce AOP approach in Web Dynpro, Web Dynpro provides it's own controller hook methods for implementing a 'crosscutting concerns' like 'validate context data across controller or even component borders'.

Regards, Bertram

Former Member
0 Kudos

Hello,

For other purposes than Alexandre's, I need to use AOP for a Web Dynpro project. After a lot of search by my side, I couldn't find any relevant method for this purpose.

Does anybody know of a possibility to use AOP with Web Dynpro ?

Thanks,

Laurent

Former Member
0 Kudos

Hi, Alexandre

Instead of diving in into cool unknown water of AOP, you may try more WD-like approach.

So, instead of using plain value nodes consider model nodes bound to your JavaBeans or XMI-imported models. Next, in your model object you can perform actual validation in field setters and report any errors with IWDMessageManager. You can pass it via constructor directly, or hide behind some custom error reporting interface to be more WD-agnostic.

As far as I know, before validating action handling WD runtime first assign any changed values and validate user input. So, your error reporting code will be a part of such standard validation. Next, if any errors are reported action handler will not be executed. (Even in opposite case you have an option to place IWDMessageManager.raisePendingException as first line of your code)

Hope this helps,

VS