1. I'll have a patch ready to go. 2. I understand and agree with that; however I could also see that if a user is binding to a Nullable type it is probably because they want to treat null as a first class citizen, otherwise they would bind to a value type...this is one of those issues though where both could be valid. Either way monorail is friendly and lets me do what I want.
Ken I have included this as a patch on donjon: http://support.castleproject.org/projects/COMP/issues/view/COMP-ISSUE-81 Please review. All tests for castle pass after this is applied and I think the tests included state more clearly what DataBinder will do with params. Thanks so much Mike On Jan 29, 9:18 am, Ken Egozi <[email protected]> wrote: > two issues here: > 1. non-nullable list break if empty values exists. > 2. nulluable list ignores null values. > > my take is: > 1. should be fixed. the List<double> should contain 2 values in the demo > I'll be happy to get a patch > 2. in the web lingua, a parameter without value is considered missing. I > think that lists of ref types should also ignore missing values. > > On Thu, Jan 29, 2009 at 6:09 PM, Mike Nichols <[email protected]>wrote: > > > > > > > I have found why this behaviour exists but am not sure whether this is > > by design or is a bug. When DefaultConverter tries to convert a > > Nullable type, it doesn't treat 'null' as a valid value and so simply > > returns 'null'. However a generic list requires the NULL to be cast to > > teh Nullable type . The fix is simple, simple have ACtivator create an > > instance of the nullable type passing NULL as the value. > > > But I am not sure whether this patch would be accepted or not. To me > > it seems logical that a nullable list would have null values, but I > > could see the other side too. > > > Now if we are just talking about a List<double> then it seems like it > > should add as many items as it can ... in the example below add 2 > > items. However right now it simply doesn't add any items because of > > the exception thrown on the list...again, I am not sure whether to > > roll my own or submit a patch. > > > Any monorail devs have a take on this? > > > On Jan 29, 12:19 am, Mike Nichols <[email protected]> wrote: > > > I hate to post about databinder stuff, but this seems odd. > > > What is the expected behaviour binding to a params dictionary like: > > > params["obj.SomeList[0]"]="123" > > > params["obj.SomeList[1]"]="456" > > > params["obj.SomeList[2]"]="" > > > params["obj.SomeList[3]"]="" > > > > I swear DataBinder used to add 2 items to obj.SomeList (List<double?>) > > > but I just moved to IIS7/server 2008 and now it doesn't add any values > > > at all. However if 'null' is the value instead of empty strings then > > > it works just fine. > > > > I am using today's trunk. > > > > Here are tests demonstrating... > > > The first test here PASSES, but the other two FAIL...note that NULL > > > values allow DataBinder to create and hydrate the list as expected. > > > Has anyone else come against this?: > > > > public class when_binding_indexed_properties_with_null_list_itemas : > > > context_spec > > > { > > > private ControllerBindingLIst sut; > > > private StubMonoRailServices services; > > > private IControllerContext controllerContext; > > > private StubEngineContext engineContext; > > > > public override void establish_context() > > > { > > > services = new StubMonoRailServices(); > > > sut = new ControllerBindingLIst(); > > > controllerContext = services.ControllerContextFactory > > > .Create("", "home", "MyAction", > > > services.ControllerDescriptorProvider.BuildDescriptor(sut)); > > > > engineContext = new StubEngineContext(); > > > engineContext.Request.Params.Add("entity.List[0]", > > "123"); > > > engineContext.Request.Params.Add("entity.List[1]", > > "456"); > > > engineContext.Request.Params.Add("entity.List[2]", null); > > // > > > databinder recognizes this > > > engineContext.Request.Params.Add("entity.List[3]", > > null);// > > > databinder recognizes this > > > > } > > > > public override void because() > > > { > > > //given > > > sut.Process(engineContext, controllerContext); > > > } > > > [Observation] > > > public void should_not_be_null() > > > { > > > Assert.NotNull(sut.list); > > > } > > > [Observation] > > > public void should_have_two_list_items() > > > { > > > Assert.Equal(2, sut.list.Count); //passes > > > } > > > > } > > > > public class when_binding_indexed_properties_with_empty_list_items : > > > context_spec > > > { > > > private ControllerBindingLIst sut; > > > private StubMonoRailServices services; > > > private IControllerContext controllerContext; > > > private StubEngineContext engineContext; > > > > public override void establish_context() > > > { > > > services = new StubMonoRailServices(); > > > sut = new ControllerBindingLIst(); > > > controllerContext = services.ControllerContextFactory > > > .Create("", "home", "MyAction", > > > services.ControllerDescriptorProvider.BuildDescriptor(sut)); > > > > engineContext = new StubEngineContext(); > > > engineContext.Request.Params.Add("entity.List[0]", > > "123"); > > > engineContext.Request.Params.Add("entity.List[1]", > > "456"); > > > engineContext.Request.Params.Add("entity.List[2]", > > "");//databinder > > > consequently disregards all values > > > engineContext.Request.Params.Add("entity.List[3]", ""); > > > > } > > > > public override void because() > > > { > > > //given > > > sut.Process(engineContext,controllerContext); > > > > } > > > [Observation] > > > public void should_not_be_null() > > > { > > > Assert.NotNull(sut.list); > > > } > > > [Observation] > > > public void should_have_two_list_items() > > > { > > > Assert.Equal(2,sut.list.Count); //FAILS, saying zero > > items are in > > > the list > > > } > > > > } > > > > public class when_binding_repeated_properties_on_sdc : context_spec > > > { > > > private ControllerBindingLIst sut; > > > private StubMonoRailServices services; > > > private IControllerContext controllerContext; > > > private StubEngineContext engineContext; > > > > public override void establish_context() > > > { > > > services = new StubMonoRailServices(); > > > sut = new ControllerBindingLIst(); > > > controllerContext = services.ControllerContextFactory > > > .Create("", "home", "MyAction", > > > services.ControllerDescriptorProvider.BuildDescriptor(sut)); > > > > engineContext = new StubEngineContext(); > > > engineContext.Request.Params.Add("entity.List", "123"); > > > engineContext.Request.Params.Add("entity.List", "456"); > > > engineContext.Request.Params.Add("entity.List", ""); > > > engineContext.Request.Params.Add("entity.List", ""); > > > > } > > > > public override void because() > > > { > > > //given > > > sut.Process(engineContext, controllerContext); > > > > } > > > [Observation] > > > public void should_not_be_null() > > > { > > > Assert.NotNull(sut.list); > > > } > > > [Observation] > > > public void should_have_two_list_items() > > > { > > > Assert.Equal(2, sut.list.Count); //same thing...fails > > saying zero > > > items are in list > > > } > > > > } > > > > //ENTITIES USED > > > public class ObjWithList > > > { > > > List<double?> list=new List<double?>(); > > > > public List<double?> List > > > { > > > get { return list; } > > > set { list = value; } > > > } > > > > } > > > > public class ControllerBindingLIst:SmartDispatcherController > > > { > > > public List<double?> list; > > > > public void MyAction([DataBind("entity")] ObjWithList entity) > > > { > > > this.list = entity.List; > > > } > > > > } > > -- > Ken > Egozi.http://www.kenegozi.com/bloghttp://www.delver.comhttp://www.musicglue.comhttp://www.castleproject.orghttp://www.gotfriends.co.il --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
