New Posts New Posts RSS Feed: Warnings vs. Errors
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Warnings vs. Errors

 Post Reply Post Reply
Author
rclarke View Drop Down
Groupie
Groupie


Joined: 14-Jun-2007
Location: United States
Posts: 69
Post Options Post Options   Quote rclarke Quote  Post ReplyReply Direct Link To This Post Topic: Warnings vs. Errors
    Posted: 07-Feb-2008 at 12:46pm
I override the base IDataErrorInfo and return nothing for the implementations functions. This essentually tells .Net that no errors exist and the behavior implemented for DevEx will be invoked. Or you could add a compile switch to the CommonEntity class to include the implementation you desire. The following code snippet in how I do the overrides in BaseEntity.

#Region "IDataErrorInfo"

' Entity inherits from IDataErrorInfo as of DF 3.5.3

' providing virtual GetDataErrorInfo overloads for the implementation

' of the two IDataErrorInfo methods.

' This region re-implements the overloads to use the VerifierResultsCache

''' <summary>

''' Get error message for a particular triggering property.

''' </summary>

''' <param name="pPropertyName">Name of the property we're looking for.</param>

''' <returns>The first message found; null if no message found.</returns>

''' <remarks>

''' This implementation looks among the VerifierResults

''' for the "first" errant VerifierResult that could have been triggered by this property.

''' There could be many such results.

''' <para>

''' One could override to provide alternative messaging

''' such as line wrapping all of the property's VerifierResult messages.

''' </para>

''' </remarks>

Protected Overrides Function GetDataErrorInfo(ByVal pPropertyName As String) As String

'Since we are implementing the DevX error provider

'return nothing to the base indicating no error

'Return VerifierResultsCache.ToString(pPropertyName)

Return Nothing

End Function

''' <summary>Get error message for the object as a whole.</summary>

''' <remarks>

''' This implementation returns a string representation

''' of all errant VerifierResults of this object.

''' Could override to provide alternative messaging.

''' </remarks>

Protected Overrides Function GetDataErrorInfo() As String

'Since we are implementing the DevX error provider

'return nothing to the base indicating no error

'Return CType(VerifierResultsCache, Object).ToString()

Return Nothing

End Function

Back to Top
eileenv View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Jun-2007
Location: United States
Posts: 68
Post Options Post Options   Quote eileenv Quote  Post ReplyReply Direct Link To This Post Posted: 01-Feb-2008 at 12:15pm

A customer asked:

I did all the changes that were suggested and it seems to show the DevEx error provider as required. But what happens is, I now see BOTH the DevEx error provider and the .NET error provider. How do I remove the .NET error provider? 

Answer:

The following snippet shows you how you can gain access to a control’s ErrorProvider to change its properties, replace it entirely, or in this case, set it to null:

    private void InitializeForm() {
      ConfigureErrorProvider(mCityTextEdit, "City");
    }

    private void ConfigureErrorProvider(Control pControl, String pPropertyPath) {
      // For some Control pControl, retrieve its data bindings
      foreach (Binding aBinding in pControl.DataBindings) {
        // Cast the binding to an IdeaBladeBinding
        IdeaBladeBinding binding = aBinding as IdeaBladeBinding;
        if (binding != null && binding.BindingDescriptor.ViewDescriptor.Name == pPropertyPath) {
          binding.ErrorProvider = null;
        }
      }
    } 

 



Edited by eileenv - 01-Feb-2008 at 12:17pm
Back to Top
eileenv View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Jun-2007
Location: United States
Posts: 68
Post Options Post Options   Quote eileenv Quote  Post ReplyReply Direct Link To This Post Posted: 31-Jan-2008 at 2:25pm
The following zip contains the sample code mentioned in this post. It was sent by a customer who was interested in integrating DevEx’s Error Provider mechanism with DevForce. It is written in VB and is provided as-is.
 
 
He also sent the following the comments about the code:

-----------------

I also attached my VB version of BaseEntity and supporting files as I use them (most of it, I converted from the C# tutotial) which works great.

Small mods include adjusting the VerifierCache to include Warnings.

One also needs to add references in the Model for DevExpress.XtraEditors, Data, Utils.

BaseEntity includes an implementation which simply converts the VerifierResultCode to a DevExpress.ErrorType which is crucial for correct Error Icons on the UI.

Private DXprovider As DXErrorProvider.DXErrorProvider

Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    DXprovider = New DXErrorProvider.DXErrorProvider()

    DXprovider.ContainerControl = Me

    DXprovider.DataSource = Me.MainBS

End Sub

-----------------



Edited by eileenv - 31-Jan-2008 at 3:27pm
Back to Top
naveed_kharadi View Drop Down
Newbie
Newbie


Joined: 31-Jan-2008
Posts: 1
Post Options Post Options   Quote naveed_kharadi Quote  Post ReplyReply Direct Link To This Post Posted: 31-Jan-2008 at 12:15pm
Hi,

Can I have that code please?

Thanks and regards.
Back to Top
Bernhard View Drop Down
Newbie
Newbie


Joined: 22-Nov-2007
Location: Austria
Posts: 1
Post Options Post Options   Quote Bernhard Quote  Post ReplyReply Direct Link To This Post Posted: 27-Nov-2007 at 5:41am
Hi!

is it possible to get the code as well?

Thank you!
Bernhard
Back to Top
Yaron View Drop Down
Newbie
Newbie


Joined: 19-Jun-2007
Posts: 16
Post Options Post Options   Quote Yaron Quote  Post ReplyReply Direct Link To This Post Posted: 19-Nov-2007 at 9:23pm

At last, someone else is coding in VB.

can I have it please?


Edited by Yaron - 19-Nov-2007 at 9:23pm
Back to Top
eileenv View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Jun-2007
Location: United States
Posts: 68
Post Options Post Options   Quote eileenv Quote  Post ReplyReply Direct Link To This Post Posted: 19-Nov-2007 at 3:54pm

We get asked this question a lot. One of our customers was kind enough to send us the files he modified in order to support the use of DevEx controls and the use of the DevEx error provider which includes support for displaying warning as well as error icons. We have not yet incorporated these changes into our current set of Instructional Units, but I would be happy to send you the files as-is if you are interested. The code is currently written in VB.

Back to Top
Yaron View Drop Down
Newbie
Newbie


Joined: 19-Jun-2007
Posts: 16
Post Options Post Options   Quote Yaron Quote  Post ReplyReply Direct Link To This Post Posted: 19-Nov-2007 at 12:07pm
You mention the DevEx implementation with regards to warnings, how can I adapt that approach with IB verification?
Back to Top
eileenv View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Jun-2007
Location: United States
Posts: 68
Post Options Post Options   Quote eileenv Quote  Post ReplyReply Direct Link To This Post Posted: 13-Jul-2007 at 10:32am

The warning will not show up in the UI unless you explicitly display it. It will not show up automatically like errors do. This means you would have to iterate through the VerifierResultsCollection, pick out the warnings, and display it somehow in the UI.

How do you provide the error information in your implementation of IDataErrorInfo? If you are using a VeriferResultsCache as in the Verification Tutorial application (associated with the videos on website), you should notice that only errors are added to this cache. You would have to modify the VerifierResultsCache class (in C# example) to include Warnings in addition to the Errors. I have an example showing this if you are interested. 
 
Again, if you are supplying warnings to the IDataErrorInfo mechanism, it may not make sense to some people that a warning appears like an error (with the Error icon). It all depends on whether you want to treat warnings as errors. It would be nice if the IDataErrorInfo allowed you to specify other icons such as a warning icon.
Back to Top
naveen.menon View Drop Down
Newbie
Newbie
Avatar

Joined: 09-Jul-2007
Location: United States
Posts: 5
Post Options Post Options   Quote naveen.menon Quote  Post ReplyReply Direct Link To This Post Posted: 13-Jul-2007 at 6:15am
Thanks for the reply.
 
I'm a little confused with regard to the showing of the error icon.
 
Are you saying that even a warning should show up on the UI?
 
All our classes inherit from BaseEntity which implements IDataErrorInfo. The errors show up fine but the warnings don't show the error icon. I can catch the warnings from the VerfierResult collection just fine but the warnings don't show the icon on the UI.
 
Is this correct behaviour?
 
Back to Top
eileenv View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Jun-2007
Location: United States
Posts: 68
Post Options Post Options   Quote eileenv Quote  Post ReplyReply Direct Link To This Post Posted: 10-Jul-2007 at 12:21pm
The VerifierResultCollection contains information about all the results of a call to VerifierEngine.Execute including Errors, Warnings, and Oks. The question now becomes how to display warnings in the UI. Unlike errors, warnings are not thrown as exceptions and are, therefore, not caught by the UI, nor displayed with an error icon.
 
You can implement IDataErrorInfo in your app to display warnings as well as errors. But the problem now becomes the all-or-nothing nature of the IDataErrorInfo interface. The interface does not provide a convenient way of specifying other types of icons such as warning icons. If you don't care about the icon, then implementing IDataErrorInfo will display the warning message.
 
DevExpress, on the other hand, implements its own IDxDataErrorInfo with support for a warning icon, and it can be easily adapted to display results in VerifierResultCollection.
 
Note about IDataErrorInfo: As of DevForce 3.5.2.3, IDataErrorInfo is now being implemented in the abstract Entity class. A forthcoming release will give users the ability to override the implementation. For now, you will have to explicitly implement IDataErrorInfo in your app in order to override the base implementation.
Back to Top
naveen.menon View Drop Down
Newbie
Newbie
Avatar

Joined: 09-Jul-2007
Location: United States
Posts: 5
Post Options Post Options   Quote naveen.menon Quote  Post ReplyReply Direct Link To This Post Posted: 09-Jul-2007 at 12:55pm
I read somewhere about the ability to use warnings, instead of errors, in the verification piece. The Developer's guide (3.5.1) doesn't seem to address this. Could someone point me to the right resources where I can get some more information ragrding this?
 
Thanks,
 
Naveen
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down