cancel
Showing results for 
Search instead for 
Did you mean: 

Context element validation problem

Former Member
0 Kudos

I have two components in my application... a main component and a details component. In the main component window, I have a tree on the left side, and the embedded interface views of the details component on the right side. I have mapped the context nodes (these are all model nodes) from the main component controller to the main component view controllers, from the main component controller to the details component interface controller (isInputElement = true), and from the details component interface controller to the details component view controllers.

I am using all non-validating actions because I always want the user to be able to cancel their changes (even entry of invalid data) by just navigating away and choosing "don't save" to a "save changes?" prompt (I am manually cleaning up any invalid data).

I have a central method on the details component interface controller to save records. I call this from the individual details views (on the details component) and from the tree view (on the main component). In the central save method, I use IWDValidationCheck.isValidAttribute(IWDNodeElement, IWDAttributeInfo) on each context attribute before attempting to save to determine whether or not there is any invalid data. There are also cases where I need to check the validity of a context element from the tree view of the main component, so I am using IWDValidationCheck there as well (on the same nodes that are mapped all around).

I've got two scenarios where I see weird behavior:

1) With no invalid data entered, when the save method (on the details component interface controller) is called from the details views (on the details component), it passes the validation and works fine - but in the same situation, when I call the save method from the tree view (on the main component), my validation checking says that every single context attribute is invalid.

2) With invalid data entered (say a string in a date field), when I use IWDValidationCheck on the tree view (on the main component) to check the node element with invalid data, it doesn't recognize that there is invalid data, whereas the validation check on the same node element mapped to the details component recognizes the invalid data.

Any ideas?

Thanks,

-Dave

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

David,

1. Where your "centralized save" with IWDValidationCheck.isValidAttribute(..) resides?

2. Do you drop pending user input?

Also, probably it is simpler to create snapshot of data before user sees it for first time and then either revert to snapshot or save data? In this scenario you will let WD handle all the difficulties itself...

VS

Former Member
0 Kudos

The save method resides on the interface controller of the embedded component. I am calling it from within the embedded component (where it seems to work fine) as well as from the main component (where I see the problems I described). I am not dropping pending user input.

Can you elaborate a bit on the snapshot approach you mentioned?

Thanks,

-Dave

Former Member
0 Kudos

David,

It's hard to guess what is the reason for error, but, anyway -- try to do your validation in top-level component, probably it helps.

Also snapshot approach is just as simple as gathering current values of node attribute to some map and re-applying them afterwards if user cancels operation.

VS

Former Member
0 Kudos

So I've narrowed my problem down to as simple a situation as possible (one that I think should work), and I still see the problem.

I have two views interacting with the component controller (all on the same component). I have a model node mapped from the component controller to each of the views. The component controller has a save method the makes calls to IWDValidationCheck, checking the validity of a particular context element on the component controller. View A is the details form with a save button (non-validating action that calls the save method on the component controller). When I enter valid data on View A and press save, the manual validation calls on the component controller work fine. View B is a tree view. When I call the save method on the component controller from View B, the manual validation check fails for every attribute on the context element, even though the data is valid. I just don't understand...

-Dave

Former Member
0 Kudos

David,

Could you post 3 code extracts:

-- code of 2 action handlers (both actions are non validating, right?)

-- save method (along with validation code)

VS

Former Member
0 Kudos

Sweet... found the problem.

Both my action handlers are non-validating, but the non-validating action handler on the tree fires a confirmation dialog, and the validating event handler for the button on the confirmation dialog calls the save method.

I created an even simpler test project with the same validation structure, and the validation worked in all cases... until I added in the save prompt functionality, at which time it started producing the same error.

I don't see any way to control whether the event handlers are validating or non-validating, but I am assuming this is intended.

What I still don't understand is why the validation checks work when called from a non-validating action handler, but fail when called from a validating event handler. Also, will the validating event handler still fire for the button on the confirmation dialog if there is invalid data in the context?

Thanks,

-Dave

Former Member
0 Kudos

David,

From my understanding after validation check is complete (in case of validating action handler), the IWDValidationCheck has no association with pending user input (i.e. input not yet applied to context) while input itself already applied and discarded. And using IWDValidationCheck is forbidden at this phase. Therefore you are observing such behavior.

Also why not to implement your functionality as following steps:

1. Non-validating action handler verifies input when user click "Save".

2. If it is ok, then confirmation dialog is displayed, otherwise user forced to enter valid values or invoke "Cancel"

3. When you are returning from confirmation dialog you do not need validation check at all, while input already verified.

Thoughts?

VS

Former Member
0 Kudos

Valery, thanks for the help. I was able to get it to work by doing the following:

1. Non-validating action handler for "Save" checks validation and saves the data (if valid).

2. Non-validating action handler for "Select" checks validation, stores the results of the validation checks, and shows the save confirmation dialog (for "Select", I need to check to see if the user needs to save the current item before selecting the new item).

3. Validating event handler for "Yes" on save confirmation dialog checks only the stored results of the validation check made in step 2, and saves the data (if valid).

My problem was that previously, in step 3, I was trying to do the validation checks (now done in step 2) from a validating event handler, which does not work.

Thanks again,

-Dave

Answers (0)