Problem with PropertyStatus and the Business Rules in Csla 4 beta 2

Problem with PropertyStatus and the Business Rules in Csla 4 beta 2

Old forum URL: forums.lhotka.net/forums/t/9139.aspx


freaky posted on Monday, June 28, 2010

Hi,

I have a problem with the business rules and the “PropertyStatus” of csla 4.0 Beta 2 and a Silverlight application.

Perhaps someone has this problem too and has found a workaround.

I have build a rule and add this to a property at start of the application.

The rule looks like this here:

   public class LetstradeLoginUserIdRule : EntityRuleBase

    {

        IPropertyInfo _compareToProperty;

        private AccountSetupHolder _temp;

        public string FriendlyName { get; set; }

 

        public LetstradeLoginUserIdRule(IPropertyInfo property, IPropertyInfo compareToProperty, RuleSeverity severity = RuleSeverity.Error, string message = null, params IPropertyInfo[] otherProperties)

            : base(property, severity, message)

        {

            this._compareToProperty = compareToProperty;

            InputProperties = new List<IPropertyInfo> { property };

            foreach (IPropertyInfo propertyInfo in otherProperties)

            {

                                InputProperties.Add(propertyInfo);

            }

        }

 

 

        protected override void Execute(RuleContext context)

        {

       

//here I build erverytime on check this rule my errormessage

//then it will be through as an errorResult

                        context.AddErrorResult(PrimaryProperty, errorMessage.ToString());

 

                }

            }

        }

 

My Xaml code looks like this:

<TextBox Text="" Width="200" VerticalAlignment="Center" TextChanged="TextBox_TextChanged" />

     

        <csla:PropertyStatus         Name="_PropertyStatus"                                            

                                     Margin="3 0 0 0" 

                                    

                                     VerticalAlignment="Center"

                                     DataContext="{Binding Ndh}"

                                     Property="{Binding UserID}"           

                                     />

 

 Now if I type a character in a Textbox the rule will be checked and the “PropertyStatus” will be show as an icon with the right message in a tooltip.

If I type again a character in a Textbox, the rule will be checked, is broken again, but the “PropertyStatus” is gone.

The visibility of the “PropertyStatus” has no problem if the state is change from valid in invalid or from invalid to valid. But if the rule was broken and after the checking and calling  

context.AddErrorResult(PrimaryProperty, errorMessage.ToString());

 

and the rule is broken too, the “Propertystatus” is lost his visibility. But the Visualstate was “Error”.

My question is why? I have no idea why this happened. This behavior I have noticed first on csla 4.0 beta 2.

Regards and thx

Adrian

Copyright (c) Marimer LLC