Re: About URL Routing
you need to name the params in your route to the same thing as what you pass on to the UrlHelper, like this: rules.Add(new PatternRoute(/controller/name/productId/ action.ashx) I guess you need to skip the action aswell, since you define a default, that's not needed: rules.Add(new PatternRoute(/controller/name/productId/) .DefaultForAction().Is(searchresult) .Restrict(productId).ValidInteger); eyal wrote: Now I'm closer to a real solution see changes: public static void Register(IRoutingRuleContainer rules) { rules.Add(new PatternRoute(/controller/name/id/ action.ashx) .DefaultForArea().IsEmpty .DefaultForAction().Is(searchresult) .Restrict(id).ValidInteger); } in view #foreach($Product in $Products) li$Url.Link($Product.Name, %{controller='products', action='searchresult', querystring='productId=$Product.Id,params={id=$Product.Id, name=$Product.Name}})/ li #end The resulted url: .../specials/myproduct/11/searchresult.ashx?productId=11 However I want the url to appear as such .../specials/myproduct/11/ How can I do this? thanks eyal On Feb 10, 4:43 pm, eyal ebarda...@gmail.com wrote: I looked into your suggestions and that is what I decided to do: #foreach($Product in $Products) li$Url.Link($Product.Name, %{controller='products', action='searchresult', params={id=$Product.Id, name=$Product.Name}})/ li #end public static void Register(IRoutingRuleContainer rules) { rules.Add(new PatternRoute(/products/productId/ searchresult.ashx) .DefaultForArea().IsEmpty .DefaultForAction().Is(searchresult)); } When I click on the generated link I get the following error within the BaseHttpHandler.cs in func. Process(HttpContext context): ex = {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.} Any idea why? thanks Eyal On Feb 10, 3:06 pm, Jimmy Shimizu jimmy.shim...@gmail.com wrote: the UrlHelper will be able to generate urls if you have a matching rule for it. $Url.For(%{controller='product', action='view', params={name='ProductName'}}) would generate a URL if you have a valid route, I guess like this: RoutingModuleEx.Engine.Add( new PatternRoute(/controller/name) .DefaultForAction().Is(view)); You can add restrictions for it if you like. This would make: /product/ProductName call ProductController, on action View(string name) where name = 'ProductName'. You would need to internally map 'ProductName' to the approriate id in your action aswell as use the correct ProductName in your UrlHelper in the view. I would however combine productname with the id instead, like this: /product/15/product-name so that I would get 15 in my view, without the need for any mapping. This however needs another route than the one I supplied. Hope this helps. On 10 feb 2009, at 22:22, eyal wrote: Hi All, I am interested in re-writing some of my urls to make them url friendly. I found this bloghttp://using.castleproject.org/display/MR/Routing+Overview My agenda is to convert the following: .../controllerName/searchresult.ashx?categoryId=23 into .../controllerName/categoryName where each categoryId is associated with a Category Name Also I am not sure how to associate the two following code snippets found on blog: Code: RoutingModuleEx.Engine.Add( new PatternRoute(/controller/name/id/view.aspx) .DefaultForAction().Is(view) .Restrict(id).ValidInteger ); I found that just by using the $UrlLink(... on my view I can re-write a url. But the url is not initially generated into the browser's url address. Instead it appears as a hyper link on the page. Once clicked only then it will re-write the url address in the browser - that is useless to me. What am I missing here? Code: $Url.Link('Product Name', %{controller='product', action='view', params={id=15, name='ProductName'}}) Thanks Eyal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Field not found: 'NVelocity.Runtime.Directive.Directive.runtimeServices' exception after moving from RC3 to trunk build 1040
The problem was resolved! :) The update of NVelocity.dll to the latest one from the build really helps. The reason of our error was that we did not notice, that we also use NVelocity in a dependent project for mail message generation, and after move to trunk we did not change NVelocity.dll there. So during the solution build the old NVelocity.dll from the dependency always overwrote the new NVelocity.dll in our web project. On 10 фев, 20:06, Alexandra Tikhonova shuren...@gmail.com wrote: Hi We have moved our project from RC3 to the trunk build 1040. After fixing some breaking changes like objects renaming and removing monorail http module, we managed to build our project. But when we run it we got the following exception: Exception Details: System.MissingFieldException: Field not found: 'NVelocity.Runtime.Directive.Directive.runtimeServices'. [MissingFieldException: Field not found: 'NVelocity.Runtime.Directive.Directive.runtimeServices'.] Castle.MonoRail.Framework.Views.NVelocity.CustomDirectives.AbstractComponentDirective.Render (IInternalContextAdapter context, TextWriter writer, INode node) +0 NVelocity.Runtime.Parser.Node.ASTDirective.Render (IInternalContextAdapter context, TextWriter writer) +23 NVelocity.Runtime.Parser.Node.SimpleNode.Render (IInternalContextAdapter context, TextWriter writer) +52 NVelocity.Template.Merge(IContext context, TextWriter writer) +146 Castle.MonoRail.Framework.Views.NVelocity.NVelocityViewEngine.RenderLayout (String layoutName, String contents, IContext ctx, TextWriter output) +121 Castle.MonoRail.Framework.Views.NVelocity.NVelocityViewEngine.ProcessLayoutRecursively (StringWriter writer, IEngineContext context, IController controller, IControllerContext controllerContext, IContext ctx, TextWriter finalOutput) +361 Castle.MonoRail.Framework.Views.NVelocity.NVelocityViewEngine.Process (String viewName, TextWriter output, IEngineContext context, IController controller, IControllerContext controllerContext) +564 Castle.MonoRail.Framework.Services.DefaultViewEngineManager.Process (String templateName, TextWriter output, IEngineContext context, IController controller, IControllerContext controllerContext) +238 Castle.MonoRail.Framework.Controller.ProcessView() +146 Castle.MonoRail.Framework.Controller.RunActionAndRenderView() +2841 Castle.MonoRail.Framework.Controller.Process(IEngineContext engineContext, IControllerContext context) +63 Castle.MonoRail.Framework.BaseHttpHandler.Process(HttpContext context) +161 [MonoRailException: Error processing MonoRail request. Action Index on controller Overview] Castle.MonoRail.Framework.BaseHttpHandler.Process(HttpContext context) +477 Castle.MonoRail.Framework.BaseHttpHandler.ProcessRequest (HttpContext context) +37 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute () +181 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean completedSynchronously) +75 After we replaced current action view with a simple view with no components on it everything worked fine. When we tried to add a component on the test view we got the exception above again. We found a suggestion to replace NVelocity.dll with the latest one from the build. We did so but the exception repeated. Please advise. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Natural key
off the top of my head: 1. you can set it as a readonly property, and have the DB initiate the value (in SQL server use IDENTITY(1000, 1) ). I think you'd need to set the field as int? so it won't try to save 0 to the DB 2. call the DB when inserting to get the highest OrderNumber and plus 1 it 3. If you know for sure that only the application can access the DB, you might consider setting a variable with the last OrderNumber, increasing it when needed with an appropriate logging mechanism. On Wed, Feb 11, 2009 at 4:15 PM, Martin Nilsson mffmar...@gmail.com wrote: How do I best setup my active record class to have a natural key. Instead of guid as order number I want a sequence that starts with 1 for example. [ActiveRecord] public class Order { [PrimaryKey(PrimaryKeyType.GuidComb)] public Guid Id {get; set;} [??] public int OrderNumber {get; set;} } Note that I will still have guid as id to keep track of if it is saved or not but I want to show the customer a more friendly order number. -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://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 castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Convert String to Url Format
Hi All, I need to convert a string into url compatible format. For example, Product cost $24.00 higher/lower.- original string product-cost-24-00-higher-lower - url format I know that I can use string.Replace() but there are alot of characters that I may have to replace to accommodate a proper url. Is there a function that is already written that I can use? thanks eyal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Convert String to Url Format
you can use a regex say (notepad code): var cleanedUrl = new Regex([^-a-z0-9], RegexOptions.IgnoreCase).Replace(url, -); maybe then I'd add a new regex(-+).Replace(cleanedUrl, -) to avoid double '-' characters On Wed, Feb 11, 2009 at 6:38 PM, eyal ebarda...@gmail.com wrote: Hi All, I need to convert a string into url compatible format. For example, Product cost $24.00 higher/lower.- original string product-cost-24-00-higher-lower - url format I know that I can use string.Replace() but there are alot of characters that I may have to replace to accommodate a proper url. Is there a function that is already written that I can use? thanks eyal -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://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 castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
How to inject WCF WebOperationContex into an ErrorHandler
Does anyone know if it is possible to inject the current WCF WebOperationContext into a class that implements IErrorHandler? My ErrorHandler is instantiated via a WebHttpBehavior that is instantiated via new DefaultServiceModel().AddExtensions(new MyWebHttpBehavior()). Therefore my ErrorHandler is created once, but I need it to be injected with the current WCF WebOperationContext. Any ideas how to do this? Here's what MyWebHttpBehavior looks like and how it is configured in the container Container.AddFacilityWcfFacility() .Register( ... Component.For... .ActAs( new DefaultServiceModel() ... .AddExtensions(new MyWebHttpBehavior()) ) ); public class MyWebHttpBehavior: WebHttpBehavior { protected override void AddServerErrorHandlers(ServiceEndpoint endpoint, EndpointDispatcher ed) { // TODO MyErrorHandler should be injected by the Ioc container ed.DispatchRuntime.ChannelDispatcher.ErrorHandlers.Add(new MyErrorHandler()); } } And here's MyErrorHandler class MyErrorHandler: IErrorHandler { ... public void ProvideFault(...) { // TODO WebOperationContextWrapper should be injected by the Ioc container var currentWebOperationContext = new WebOperationContextWrapper(WebOperationContext.Current); ... } } Cheers, Craig --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: How to integrate Castle ActiveRecord and WCF using Windsor?
It needs to be an IContractBehavior to ensure that it is propertly applied to the operations at the right time during channel or service host initialization On Wed, Feb 11, 2009 at 4:28 AM, Tavo gustavo.rin...@gmail.com wrote: Craig talking about this, i have seen that you set the UnitOfWork Behavior as an IEndpointBehavior. I have seen others doing it as an IContractBehavior or IServiceBehavior. Can you tell what was your consideration to decide going for this instead of the others? Thanks. Gustavo. On Feb 10, 3:57 pm, Craig Neuwirt cneuw...@gmail.com wrote: They are independent. You should be able to configure them independently. I suspect what you are looking for is how to manage session/transaction scope per request. If you look at the WcfFacility tests you will find a UnitOfWorkBehavior which shows you how to create the plumbing you need. For AR, you will just need to create a new SessionScope/TransactionScope in the BeforeInvoke and Dispose it in the AfterInvoke. On Tue, Feb 10, 2009 at 4:41 AM, crios...@gmail.com crios...@gmail.com wrote: Hey guys, Can anyone provide working snippet for integration AR and WCF services using windsor container (facility perhaps?) for PerCall (per request) model?.. Thank you in advance! :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Convert String to Url Format
HttpUtility.UrlEncode() On Wed, Feb 11, 2009 at 11:38 AM, eyal ebarda...@gmail.com wrote: Hi All, I need to convert a string into url compatible format. For example, Product cost $24.00 higher/lower.- original string product-cost-24-00-higher-lower - url format I know that I can use string.Replace() but there are alot of characters that I may have to replace to accommodate a proper url. Is there a function that is already written that I can use? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
[Windsor] Passing a custom argument to a sub-dependency
Hello, I am currently facing a interesting problem with my Windsor object creation. I have a service that calculates something and then calls a Writer service to save this calculation. So I have Calculator depend on IWriter through it's ctor. This all works. But now I have a special case where I need get a Calculator that is hooked up to a decorated IWriter that has one of it's dependencies supplied at runtime. In more concrete terms I try to apply a filter through the decorator, so I need to resolve a Calculator object that depends on a Filtered IWriter (with a runtime-supplied filter argument) and the Filter-Decorator then passes the call on to the real IWriter that then goes into the DB. Now, container.ResolveCalculator(arguments) would work if I need to pass an argument to the calculator. But how do I supply the arguments to the subsequent IWriter lookup? Is there some way to pass arguments to subsequent resolves? The obvious fallback would be to simply construct that object by hand. But that's not really ideal imo. Any help would be greatly appreciated. greetings Daniel Hoelbling (PS: Sorry if this went to the list twice, I may have forgotten to change my from field to the one registered at google) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
hyperlink Wrap around
Hi All, I am using $Url.For( )and $Url.Link(). How can I use them to wrap around images and divs. In pure html I can do this very easily using the closing /a tag: a href=... img name=... src=... / /a thanks eyal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: hyperlink Wrap around
a href=Url.For( ) img name=... src=... / /a --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: [Windsor] Passing a custom argument to a sub-dependency
Acording to this post: http://groups.google.com/group/castle-project-devel/browse_thread/thread/296dd82d5decd226/e5106c9ef7671710?hl=enlnk=gstq=MicroKernel+additionalArgs+behavior+definition#e5106c9ef7671710 This should work: var sender = container.ResolveCalculator(new {parameterNameOfIWriter = value} ); On Wed, Feb 11, 2009 at 2:26 PM, Daniel Hölbling hoelblin...@gmail.comwrote: Hello, I am currently facing a interesting problem with my Windsor object creation. I have a service that calculates something and then calls a Writer service to save this calculation. So I have Calculator depend on IWriter through it's ctor. This all works. But now I have a special case where I need get a Calculator that is hooked up to a decorated IWriter that has one of it's dependencies supplied at runtime. In more concrete terms I try to apply a filter through the decorator, so I need to resolve a Calculator object that depends on a Filtered IWriter (with a runtime-supplied filter argument) and the Filter-Decorator then passes the call on to the real IWriter that then goes into the DB. Now, container.ResolveCalculator(arguments) would work if I need to pass an argument to the calculator. But how do I supply the arguments to the subsequent IWriter lookup? Is there some way to pass arguments to subsequent resolves? The obvious fallback would be to simply construct that object by hand. But that's not really ideal imo. Any help would be greatly appreciated. greetings Daniel Hoelbling (PS: Sorry if this went to the list twice, I may have forgotten to change my from field to the one registered at google) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Convert String to Url Format
Thank you all for the quick reply. Ken your suggestion works like a charm. On Feb 11, 8:53 am, Ken Egozi egoz...@gmail.com wrote: you can use a regex say (notepad code): var cleanedUrl = new Regex([^-a-z0-9], RegexOptions.IgnoreCase).Replace(url, -); maybe then I'd add a new regex(-+).Replace(cleanedUrl, -) to avoid double '-' characters On Wed, Feb 11, 2009 at 6:38 PM, eyal ebarda...@gmail.com wrote: Hi All, I need to convert a string into url compatible format. For example, Product cost $24.00 higher/lower. - original string product-cost-24-00-higher-lower - url format I know that I can use string.Replace() but there are alot of characters that I may have to replace to accommodate a proper url. Is there a function that is already written that I can use? thanks eyal -- 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 castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
WizardStepPage Issue with Reset and IsPreConditionSatisfied funcs
Hi All, I recently upgraded my app. trunk to the latest framework ver 2.0. I found that the overridable functions Reset and IsPreConditionSatisfied are no longer supported or available for use. I'm getting the following error in the Controller.cs under RunActionAndRenderView() Object reference not set to an instance of an object. Does anyone know what can I use to replace them? I tried the following but it didnt work: changed protected override void Reset() {} into public override void Reset() {} thanks eyal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: [Windsor] Passing a custom argument to a sub-dependency
you wouldn't pass the iwriter's dependency through the calculator, the calculator doesn't know the type of the iwriter. if you want to create writer at runtime, you could pass the kernel to calculator and have the calculator pull the iwriter from the kernel based on a parameter var writer = kernel.ResolveIWriter(key of writer to select); or you could create a factory object to create the calculator public class CalculatorFactory { public ctor(IWriterRegistery registry) {...} public Calculator Create(criteria for writer) { foreach(var writer in registry) { if(!writer.meets(critiera) continue; return new Calculator(writer.implementation); } } } or you could resolve the writer and then resolve the calculator var writer = container.ResolveIWriter(key to writer); var calculator = container.ResolveICalculator (writer); you could register an IWriter which is just a composite of the actual resolvers and place the logic there class AllWriters : IWriter { ctor(IWriter first, IWriter second){...} void dosomething() { if(should use first) first.dosomething(); else second.dosomething(); } } or you could implement your own subdependencyresolver to resolve the type of writer needed. Daniel Hölbling wrote: Hello, I am currently facing a interesting problem with my Windsor object creation. I have a service that calculates something and then calls a Writer service to save this calculation. So I have Calculator depend on IWriter through it's ctor. This all works. But now I have a special case where I need get a Calculator that is hooked up to a decorated IWriter that has one of it's dependencies supplied at runtime. In more concrete terms I try to apply a filter through the decorator, so I need to resolve a Calculator object that depends on a Filtered IWriter (with a runtime-supplied filter argument) and the Filter-Decorator then passes the call on to the real IWriter that then goes into the DB. Now, container.ResolveCalculator(arguments) would work if I need to pass an argument to the calculator. But how do I supply the arguments to the subsequent IWriter lookup? Is there some way to pass arguments to subsequent resolves? The obvious fallback would be to simply construct that object by hand. But that's not really ideal imo. Any help would be greatly appreciated. greetings Daniel Hoelbling (PS: Sorry if this went to the list twice, I may have forgotten to change my from field to the one registered at google) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: ARDataBinder and Version fields
After further investigation I think I might have found a possible bug when in Evict method of the ActiveRecordMediator when used within a transaction scope. The mediator calls directly to the curren scope to evict an entity. And the scope Evict method is: /// summary /// Evicts the specified instance from the session cache. /// /summary /// param name=instanceThe instance./param public void Evict(object instance) { if (instance == null) throw new ArgumentNullException(instance); foreach (ISession session in GetSessions()) { if (session.Contains(instance)) { session.Evict(instance); } } } However, GetSessions returns no session within a transaction scope in this case: [TestFixture] public class EvictFixture { [Test] public void Evict_Fails_when_nested_scopes() { var evictedEntity = new EvictedEntity() {Name = N1}; using(new SessionScope()) { ActiveRecordMediator.Save(evictedEntity); } using(new SessionScope(FlushAction.Never)) { //Entity loaded within this scope EvictedEntity entity = ActiveRecordMediatorEvictedEntity.FindByPrimaryKey(evictedEntity.Id); using (new TransactionScope(TransactionMode.New, OnDispose.Commit)) { entity.Name = N2; ActiveRecordMediator.Evict(entity); //this evict does nothing } } using (new SessionScope()) { EvictedEntity entity = ActiveRecordMediatorEvictedEntity.FindByPrimaryKey(evictedEntity.Id); Assert.That(entity.Version, Is.EqualTo(1)); Assert.That(entity.Name, Is.EqualTo(N1)); } } } [ActiveRecord] public class EvictedEntity { [PrimaryKey] public int Id { get; private set; } [Version] public int Version { get; private set; } [Castle.ActiveRecord.Property] public string Name { get; set; } } So, is there a special reason for Evict to be implemented differently then Save, Update or Delete? Could the evict methods be implemented within ActiveRecordBase in the same way as Save, Update and Delete? Thanks, Simon On Tue, Feb 10, 2009 at 10:58 AM, Simon Laroche laroche.si...@gmail.com wrote: This is my scenario: 1. Version field is a hidden field in the form. 2. When I bind using ARDataBinder, the binder correctly sets the version field to whatever is in the form. 3. I would like to get an StaleObjectStateException when I flush the session if the version has changed. If I use the binder as is, I can never get a stale object exception. I must evict then update the object for the session to throw a StaleObjectStateException on flush. //Simon On Tue, Feb 10, 2009 at 8:03 AM, Markus Zywitza markus.zywi...@gmail.com wrote: Sorry for the delay. Can you please elaborate on what you need to do? Any checks that are done by NH (not-null, uniqueness, version etc.) are only performed while flushing. Calling Save() won't do anything within a SessionScope when the object is already persistent (this is the case when you use ARDataBind). My preferred option to handle this is calling Flush() manually, catching errors and evicting the offending objects in the exception handler. -Markus 2009/2/6 Simon laroche.si...@gmail.com: I have trying to use the ActiveRecord DataBinder in conjunction with a Version field and I could not get a stale object object exception when the session got flushed. The only way I could get a stale object exception was by evicting and then updating the entity. For example: public void Update([ARDataBind(fournisseur, AutoLoadBehavior.Always)] Fournisseur fournisseur) { ActiveRecordMediator.Evict(fournisseur); //Required to get a stale object exception ActiveRecordMediator.Update(fournisseur); // if(!Validator.IsValid(fournisseur)) { PropertyBag.Add(errorSummary, Validator.GetErrorSummary (fournisseur)); PropertyBag.Add(fournisseurType, typeof(Fournisseur)); PropertyBag.Add(fournisseur, fournisseur); MyViews.edit.Render(); return; } MyActions.Index().Redirect(); } I think that it is how NHibernate works since the entity already belongs to the session when the binder
Re: Convert String to Url Format
Hi Alex, RegexReplace is not recognized to be a valid method. Am I missing a lib ref? (Regex is recognized) thanks eyal On Feb 11, 10:55 am, Alex Henderson bitterco...@gmail.com wrote: I have an extension method I use for this, basically the same as Kens... public static string Slugify(this string text) { return text.ToLowerInvariant().RegexReplace([^a-z0-9]+, -).RegexReplace(-+$, ).RegexReplace(^-+$, ); } On Thu, Feb 12, 2009 at 5:38 AM, eyal ebarda...@gmail.com wrote: Hi All, I need to convert a string into url compatible format. For example, Product cost $24.00 higher/lower. - original string product-cost-24-00-higher-lower - url format I know that I can use string.Replace() but there are alot of characters that I may have to replace to accommodate a proper url. Is there a function that is already written that I can use? thanks eyal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Convert String to Url Format
Also please explain if there is an advantage over Ken's method On Feb 11, 10:55 am, Alex Henderson bitterco...@gmail.com wrote: I have an extension method I use for this, basically the same as Kens... public static string Slugify(this string text) { return text.ToLowerInvariant().RegexReplace([^a-z0-9]+, -).RegexReplace(-+$, ).RegexReplace(^-+$, ); } On Thu, Feb 12, 2009 at 5:38 AM, eyal ebarda...@gmail.com wrote: Hi All, I need to convert a string into url compatible format. For example, Product cost $24.00 higher/lower. - original string product-cost-24-00-higher-lower - url format I know that I can use string.Replace() but there are alot of characters that I may have to replace to accommodate a proper url. Is there a function that is already written that I can use? thanks eyal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: [Windsor] Passing a custom argument to a sub-dependency
You could look at the Castle.Facilities.Logging.LoggerResolver for an example of an implementation of the ISubDependencyResolver approach. This uses a combination of Factory and Resolver. - rb On Wed, Feb 11, 2009 at 10:29 AM, Jason Meckley jasonmeck...@gmail.comwrote: you wouldn't pass the iwriter's dependency through the calculator, the calculator doesn't know the type of the iwriter. if you want to create writer at runtime, you could pass the kernel to calculator and have the calculator pull the iwriter from the kernel based on a parameter var writer = kernel.ResolveIWriter(key of writer to select); or you could create a factory object to create the calculator public class CalculatorFactory { public ctor(IWriterRegistery registry) {...} public Calculator Create(criteria for writer) { foreach(var writer in registry) { if(!writer.meets(critiera) continue; return new Calculator(writer.implementation); } } } or you could resolve the writer and then resolve the calculator var writer = container.ResolveIWriter(key to writer); var calculator = container.ResolveICalculator (writer); you could register an IWriter which is just a composite of the actual resolvers and place the logic there class AllWriters : IWriter { ctor(IWriter first, IWriter second){...} void dosomething() { if(should use first) first.dosomething(); else second.dosomething(); } } or you could implement your own subdependencyresolver to resolve the type of writer needed. Daniel Hölbling wrote: Hello, I am currently facing a interesting problem with my Windsor object creation. I have a service that calculates something and then calls a Writer service to save this calculation. So I have Calculator depend on IWriter through it's ctor. This all works. But now I have a special case where I need get a Calculator that is hooked up to a decorated IWriter that has one of it's dependencies supplied at runtime. In more concrete terms I try to apply a filter through the decorator, so I need to resolve a Calculator object that depends on a Filtered IWriter (with a runtime-supplied filter argument) and the Filter-Decorator then passes the call on to the real IWriter that then goes into the DB. Now, container.ResolveCalculator(arguments) would work if I need to pass an argument to the calculator. But how do I supply the arguments to the subsequent IWriter lookup? Is there some way to pass arguments to subsequent resolves? The obvious fallback would be to simply construct that object by hand. But that's not really ideal imo. Any help would be greatly appreciated. greetings Daniel Hoelbling (PS: Sorry if this went to the list twice, I may have forgotten to change my from field to the one registered at google) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Convert String to Url Format
I have an extension method I use for this, basically the same as Kens... public static string Slugify(this string text) { return text.ToLowerInvariant().RegexReplace([^a-z0-9]+, -).RegexReplace(-+$, ).RegexReplace(^-+$, ); } On Thu, Feb 12, 2009 at 5:38 AM, eyal ebarda...@gmail.com wrote: Hi All, I need to convert a string into url compatible format. For example, Product cost $24.00 higher/lower.- original string product-cost-24-00-higher-lower - url format I know that I can use string.Replace() but there are alot of characters that I may have to replace to accommodate a proper url. Is there a function that is already written that I can use? thanks eyal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: How to integrate Castle ActiveRecord and WCF using Windsor?
Thx! On Feb 11, 7:07 pm, Craig Neuwirt cneuw...@gmail.com wrote: It needs to be an IContractBehavior to ensure that it is propertly applied to the operations at the right time during channel or service host initialization On Wed, Feb 11, 2009 at 4:28 AM, Tavo gustavo.rin...@gmail.com wrote: Craig talking about this, i have seen that you set the UnitOfWork Behavior as an IEndpointBehavior. I have seen others doing it as an IContractBehavior or IServiceBehavior. Can you tell what was your consideration to decide going for this instead of the others? Thanks. Gustavo. On Feb 10, 3:57 pm, Craig Neuwirt cneuw...@gmail.com wrote: They are independent. You should be able to configure them independently. I suspect what you are looking for is how to manage session/transaction scope per request. If you look at the WcfFacility tests you will find a UnitOfWorkBehavior which shows you how to create the plumbing you need. For AR, you will just need to create a new SessionScope/TransactionScope in the BeforeInvoke and Dispose it in the AfterInvoke. On Tue, Feb 10, 2009 at 4:41 AM, crios...@gmail.com crios...@gmail.com wrote: Hey guys, Can anyone provide working snippet for integration AR and WCF services using windsor container (facility perhaps?) for PerCall (per request) model?.. Thank you in advance! :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Convert String to Url Format
Sorry, regex replace is another extension method.. public static string RegexReplace(this string input, string pattern, string replace) { return Regex.Replace(input, pattern, replace); } No advantage over kens implementation I could see, just adding some weight to the fact that his approach works in the wild :) On Thu, Feb 12, 2009 at 8:12 AM, eyal ebarda...@gmail.com wrote: Also please explain if there is an advantage over Ken's method On Feb 11, 10:55 am, Alex Henderson bitterco...@gmail.com wrote: I have an extension method I use for this, basically the same as Kens... public static string Slugify(this string text) { return text.ToLowerInvariant().RegexReplace([^a-z0-9]+, -).RegexReplace(-+$, ).RegexReplace(^-+$, ); } On Thu, Feb 12, 2009 at 5:38 AM, eyal ebarda...@gmail.com wrote: Hi All, I need to convert a string into url compatible format. For example, Product cost $24.00 higher/lower.- original string product-cost-24-00-higher-lower - url format I know that I can use string.Replace() but there are alot of characters that I may have to replace to accommodate a proper url. Is there a function that is already written that I can use? thanks eyal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Lost images after Routing
Hi All, I recently applied url routing. However my view lost all its images. All I see on page is the image placement with marked with red X. Any idea of how to fix this? this is how I pull the image to display on page: img name=Image_$cnt alt=$Html.HtmlEncode($row.Title) src=../container/images/product_images/thumb$image.FileId border=0/ Thanks Eyal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Convert String to Url Format
I bet that RegexReplace is a simple extension method On Wed, Feb 11, 2009 at 9:12 PM, eyal ebarda...@gmail.com wrote: Also please explain if there is an advantage over Ken's method On Feb 11, 10:55 am, Alex Henderson bitterco...@gmail.com wrote: I have an extension method I use for this, basically the same as Kens... public static string Slugify(this string text) { return text.ToLowerInvariant().RegexReplace([^a-z0-9]+, -).RegexReplace(-+$, ).RegexReplace(^-+$, ); } On Thu, Feb 12, 2009 at 5:38 AM, eyal ebarda...@gmail.com wrote: Hi All, I need to convert a string into url compatible format. For example, Product cost $24.00 higher/lower.- original string product-cost-24-00-higher-lower - url format I know that I can use string.Replace() but there are alot of characters that I may have to replace to accommodate a proper url. Is there a function that is already written that I can use? thanks eyal -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://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 castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: hyperlink Wrap around
Hi Victor, this example is not working. the html generated is: a href=$Url.For(%{controller='product', action='pageName', params= {prodId=199 On Feb 11, 10:23 am, Victor Kornov wee...@gmail.com wrote: a href=Url.For( ) img name=... src=... / /a --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Partial Initialization
Hi folks, I'd like your help. I'm looking to do something simple, but I have no idea how. I usually create an XML config file that contains all the settings to run the application with AR and that works fine. What I'd like to do now is a bit different. I want the XML to have ALL settings EXCEPT the connection string, which will be obtained from a source other than the Xml config file.. Is that possible? I couldn't figure out how I'd manage to do that. I just need to use the ActiveRecordStarter class to read all the parameters and then find a way to add the connection string that will come from a different source. Any help will be greatly appreciated. Thanks in advance --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: hyperlink Wrap around
You are using NVelocity viewengine, right? I've not used it can't give you exact syntax. That was just an example of where you should be looking at. On Wed, Feb 11, 2009 at 10:22 PM, eyal ebarda...@gmail.com wrote: Hi Victor, this example is not working. the html generated is: a href=$Url.For(%{controller='product', action='pageName', params= {prodId=199 On Feb 11, 10:23 am, Victor Kornov wee...@gmail.com wrote: a href=Url.For( ) img name=... src=... / /a --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: AR Native Query - type not initialized
Tyler Burd wrote: I ran into this issue not long ago. The generic type parameter on SimpleQuery MUST be an Active Record persistent class. You can't use SimpleQuery to get DTOs or integer results. If you go to a lower level and use the good ol' session.CreateQuery or session.CreateSqlQuery things should work just fine. Does that help? -tyler Thx for answer. I also tried session.createSQLQuery() with following code: Code: ISQLQuery sqlQuery = this.m_database.GetSessionFactoryHolder ().CreateSession (typeof (DrawingAR)).CreateSQLQuery ( MAX_BOUNDING_BOX_QUERY); IList list = sqlQuery.List (); long[] result = (long[]) list[0]; but then i get Quote: Return types of SQL query were not specified [SELECT min(xmin(box2d (shape))) as a, min(ymin(box2d(shape))) as b, max(xmax(box2d(shape))) as c, max(ymax(box2d(shape))) as d FROM drawings;] And acctualy don't now where to specify them. Can you help? Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Form isn't loading on grid selection
Clearing this up, since it seems nobody can help with what I've got so far. I create a Dictionary object, like this: Dictionaryint, Dictionaryint, decimal Details = new Dictionaryint, Dictionaryint, decimal(); I fill it and then assign it to the Property Bag like this: PropertyBag[Details] = Details; In my .brail form, I have this: if IsDefined(Details): output Has Details if Details.ContainsKey(sectKey.ID) and Details[sectKey.ID].ContainsKey (cat.ID): output tdinput type=\text\ id=\ + strID + \ name=\ + strID + \ value=\ + Details[sectKey.ID][cat.ID] + \ //td\n else: output tdinput type=\text\ id=\ + strID + \ name=\ + strID + \ //td\n end else: output tdinput type=\text\ id=\ + strID + \ name=\ + strID + \ //td\n end But IsDefined never returns true. It does for other items in the PropertyBag. What gives? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: AR Native Query - type not initialized
Or better yet, use one of the Result Transformers and you'll get a nice list of DTOs On Wed, Feb 11, 2009 at 11:46 PM, Ken Egozi egoz...@gmail.com wrote: The exception is quite informative.You need to specify the return types for the query, as you are not returning any NH object so NH does not now how to read the IDataReader. use the AddScalar() method on IQuery to specify the returned columns On Wed, Feb 11, 2009 at 11:32 PM, Michał Staszewski mailing...@gmail.comwrote: Tyler Burd wrote: I ran into this issue not long ago. The generic type parameter on SimpleQuery MUST be an Active Record persistent class. You can't use SimpleQuery to get DTOs or integer results. If you go to a lower level and use the good ol' session.CreateQuery or session.CreateSqlQuery things should work just fine. Does that help? -tyler Thx for answer. I also tried session.createSQLQuery() with following code: Code: ISQLQuery sqlQuery = this.m_database.GetSessionFactoryHolder ().CreateSession (typeof (DrawingAR)).CreateSQLQuery ( MAX_BOUNDING_BOX_QUERY); IList list = sqlQuery.List (); long[] result = (long[]) list[0]; but then i get Quote: Return types of SQL query were not specified [SELECT min(xmin(box2d (shape))) as a, min(ymin(box2d(shape))) as b, max(xmax(box2d(shape))) as c, max(ymax(box2d(shape))) as d FROM drawings;] And acctualy don't now where to specify them. Can you help? Mike -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://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 castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: hyperlink Wrap around
hi victor, thanks for the reply: this is what i came up with... and this works #set ($myUrl = $Url.For(%{controller='...})) a href='$myUrl' eyal On Feb 11, 12:42 pm, Victor Kornov wee...@gmail.com wrote: You are using NVelocity viewengine, right? I've not used it can't give you exact syntax. That was just an example of where you should be looking at. On Wed, Feb 11, 2009 at 10:22 PM, eyal ebarda...@gmail.com wrote: Hi Victor, this example is not working. the html generated is: a href=$Url.For(%{controller='product', action='pageName', params= {prodId=199 On Feb 11, 10:23 am, Victor Kornov wee...@gmail.com wrote: a href=Url.For( ) img name=... src=... / /a --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Is this possible with Routing
use this to extract image h and w HttpPostedFile image Bitmap sourceImage = new Bitmap(image.InputStream, false); int width = sourceImage.Width; int height = sourceImage.Height; On Feb 11, 6:20 pm, Daniel Pupek d...@agilejedi.com wrote: Ok, I have tested this and so far it doesn't seem to work but I wanted to see if anyone had a suggestion: new PatternRoute(/groupName/images/Banner(widthxheight).png) .DefaultForArea().IsEmpty .DefaultForAction().Is(Show) .DefaultForController().Is(Images) I am trying to extract the height and width for the image. thanks, Dan Checkout my blog @http://blog.agilejedi.com Checkout my homepage @http://www.agilejedi.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Routing Pattern Rules Issue
hi all, For some reason one routing rule replaces the other. Meaning whenever I try to evoke MyView(id) func SearchResult(categoryId) is executed instead. Any ideas of how to fix this? thanks eyal I have the following routing rules: rules.Add(new PatternRoute(/controller/productName/ categoryId/) .DefaultForArea().IsEmpty .DefaultForAction().Is(searchresult) .Restrict(categoryId).ValidInteger); rules.Add(new PatternRoute(/controller/title/id/) .DefaultForArea().IsEmpty .DefaultForAction().Is(myview) .Restrict(id).ValidInteger); Relating Url generated in view: Evokes SearchResult(categoryId) func $Url.Link($Product.Name, %{controller='products', action='searchresult', params={categoryId=$Product.Id, productName= $Product.Name}) Evokes MyView(id) func $Url.For(%{controller='products', action='myview', params={id= $row.Id, title=$row.title}) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Handle Errors with Url Routing
Hi there, when defining routing pattern rules you can specify type of parameter as such .Restrict(Id).ValidInteger But what if someone tempers with the url and changes the parameter value to a non integer. How can you handle this? For example: mysite.com/productName/12 - correct url mysite.com/productName/d- erroneous url mysite.com/productName/ - erroneous url Normally, I trap and handle such errors in a Controller. But now that I'm using routing, such errors for some reason dont even reach the controller. thanks eyal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: About URL Routing
In order to get routing to work, you map * to Monorail, meaning all static requests also tries to get served by monorail. Personally I have all static material in a /static/ folder, which I set to it's own application, with a static file handler (no monorail- handler). On 11 feb 2009, at 16:27, eyal wrote: Hi Jimmy, Works great. Also I noticed that images on searchresult page/s disappeared. I am assuming that it has to do with the re-writing of the url. Any idea of how to fix this? this is how I pull the image to display on page: img name=Image_$cnt alt=$Html.HtmlEncode($row.Title) src=../container/images/product_images/thumb$image.FileId border=0/ Thanks Eyal On Feb 11, 1:26 am, Jimmy Shimizu jimmy.shim...@gmail.com wrote: you need to name the params in your route to the same thing as what you pass on to the UrlHelper, like this: rules.Add(new PatternRoute(/controller/name/productId/ action.ashx) I guess you need to skip the action aswell, since you define a default, that's not needed: rules.Add(new PatternRoute(/controller/name/productId/) .DefaultForAction().Is(searchresult) .Restrict(productId).ValidInteger); eyal wrote: Now I'm closer to a real solution see changes: public static void Register(IRoutingRuleContainer rules) { rules.Add(new PatternRoute(/controller/name/id/ action.ashx) .DefaultForArea().IsEmpty .DefaultForAction().Is(searchresult) .Restrict(id).ValidInteger); } in view #foreach($Product in $Products) li$Url.Link($Product.Name, %{controller='products', action='searchresult', querystring='productId= $Product.Id,params={id=$Product.Id, name=$Product.Name}})/ li #end The resulted url: .../specials/myproduct/11/searchresult.ashx?productId=11 However I want the url to appear as such .../specials/myproduct/11/ How can I do this? thanks eyal On Feb 10, 4:43 pm, eyal ebarda...@gmail.com wrote: I looked into your suggestions and that is what I decided to do: #foreach($Product in $Products) li$Url.Link($Product.Name, %{controller='products', action='searchresult', params={id=$Product.Id, name= $Product.Name}})/ li #end public static void Register(IRoutingRuleContainer rules) { rules.Add(new PatternRoute(/products/productId/ searchresult.ashx) .DefaultForArea().IsEmpty .DefaultForAction().Is(searchresult)); } When I click on the generated link I get the following error within the BaseHttpHandler.cs in func. Process(HttpContext context): ex = {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.} Any idea why? thanks Eyal On Feb 10, 3:06 pm, Jimmy Shimizu jimmy.shim...@gmail.com wrote: the UrlHelper will be able to generate urls if you have a matching rule for it. $Url.For(%{controller='product', action='view', params={name='ProductName'}}) would generate a URL if you have a valid route, I guess like this: RoutingModuleEx.Engine.Add( new PatternRoute(/controller/name) .DefaultForAction().Is(view)); You can add restrictions for it if you like. This would make: /product/ProductName call ProductController, on action View(string name) where name = 'ProductName'. You would need to internally map 'ProductName' to the approriate id in your action aswell as use the correct ProductName in your UrlHelper in the view. I would however combine productname with the id instead, like this: /product/15/product-name so that I would get 15 in my view, without the need for any mapping. This however needs another route than the one I supplied. Hope this helps. On 10 feb 2009, at 22:22, eyal wrote: Hi All, I am interested in re-writing some of my urls to make them url friendly. I found this bloghttp://using.castleproject.org/display/MR/Routing+Overview My agenda is to convert the following: .../controllerName/searchresult.ashx?categoryId=23 into .../controllerName/categoryName where each categoryId is associated with a Category Name Also I am not sure how to associate the two following code snippets found on blog: Code: RoutingModuleEx.Engine.Add( new PatternRoute(/controller/name/id/view.aspx) .DefaultForAction().Is(view) .Restrict(id).ValidInteger ); I found that just by using the $UrlLink(... on my view I can re- write a url. But the url is not initially generated into the browser's url address. Instead it appears as a hyper link on the page. Once clicked only then it will re-write the url address in the browser - that is useless to me. What am I missing here? Code: $Url.Link('Product Name', %{controller='product', action='view', params={id=15, name='ProductName'}}) Thanks Eyal --~--~-~--~~~---~--~~ You received this
Re: Is this possible with Routing
why the parentheses? I assume your url is: /someGroupName/images/Banner800x600.png just skip the parentheses and it will work I believe. On 12 feb 2009, at 03:20, Daniel Pupek wrote: Ok, I have tested this and so far it doesn't seem to work but I wanted to see if anyone had a suggestion: new PatternRoute(/groupName/images/Banner(widthxheight).png) .DefaultForArea().IsEmpty .DefaultForAction().Is(Show) .DefaultForController().Is(Images) I am trying to extract the height and width for the image. thanks, Dan Checkout my blog @ http://blog.agilejedi.com Checkout my homepage @ http://www.agilejedi.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Add Multi Routing Rules
You can't add multiple routes that will match the same thing, it has no idea to understand if that integer is a categoryId or a regular id. You need to combine it with some static text for example, or hardcode it per controller. rules.Add(new PatternRoute(/category/name/ categoryId/) .DefaultForArea().IsEmpty .DefaultForController().Is(Category) .DefaultForAction().Is(searchresult) .Restrict(categoryId).ValidInteger); if you want it to work regardless of controller, you need to either prefix, suffix the integer, or add one more level to it: new PatternRoute(/controller/name/cat/categoryId/ ... which would give you /someController/SomeName/cat/12345/ On 11 feb 2009, at 23:53, eyal wrote: Hi All, I'm trying to add multiple routing rules and it seems that only the first rule is actually added What am I doing wrong here? here is my attempt: public static void Register(IRoutingRuleContainer rules) { rules.Add(new PatternRoute(/controller/name/ categoryId/) .DefaultForArea().IsEmpty .DefaultForAction().Is(searchresult) .Restrict(categoryId).ValidInteger); rules.Add(new PatternRoute(/controller/name/Id/) .DefaultForArea().IsEmpty .DefaultForAction().Is(view) .Restrict(Id).ValidInteger); // you can add as many rules as you want } Cheers eyal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Natural key
Number 1, is that possible with AR? I can't have it as a primary key but as a normal property. Tried a little bit with the Formula parameter for PropertyAttribute but didn't had any progress there either. [ActiveRecord] public class Order { [PrimaryKey(PrimaryKeyType.GuidComb)] public Guid Id {get; set;} [Property(??)] public int OrderNumber {get; set;} } On Wed, Feb 11, 2009 at 3:29 PM, Ken Egozi egoz...@gmail.com wrote: off the top of my head: 1. you can set it as a readonly property, and have the DB initiate the value (in SQL server use IDENTITY(1000, 1) ). I think you'd need to set the field as int? so it won't try to save 0 to the DB 2. call the DB when inserting to get the highest OrderNumber and plus 1 it 3. If you know for sure that only the application can access the DB, you might consider setting a variable with the last OrderNumber, increasing it when needed with an appropriate logging mechanism. On Wed, Feb 11, 2009 at 4:15 PM, Martin Nilsson mffmar...@gmail.comwrote: How do I best setup my active record class to have a natural key. Instead of guid as order number I want a sequence that starts with 1 for example. [ActiveRecord] public class Order { [PrimaryKey(PrimaryKeyType.GuidComb)] public Guid Id {get; set;} [??] public int OrderNumber {get; set;} } Note that I will still have guid as id to keep track of if it is saved or not but I want to show the customer a more friendly order number. -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://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 castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Natural key
you'd have to set the IDENTITY field in the DB yourself. On Thu, Feb 12, 2009 at 9:00 AM, Martin Nilsson mffmar...@gmail.com wrote: Number 1, is that possible with AR? I can't have it as a primary key but as a normal property. Tried a little bit with the Formula parameter for PropertyAttribute but didn't had any progress there either. [ActiveRecord] public class Order { [PrimaryKey(PrimaryKeyType.GuidComb)] public Guid Id {get; set;} [Property(??)] public int OrderNumber {get; set;} } On Wed, Feb 11, 2009 at 3:29 PM, Ken Egozi egoz...@gmail.com wrote: off the top of my head: 1. you can set it as a readonly property, and have the DB initiate the value (in SQL server use IDENTITY(1000, 1) ). I think you'd need to set the field as int? so it won't try to save 0 to the DB 2. call the DB when inserting to get the highest OrderNumber and plus 1 it 3. If you know for sure that only the application can access the DB, you might consider setting a variable with the last OrderNumber, increasing it when needed with an appropriate logging mechanism. On Wed, Feb 11, 2009 at 4:15 PM, Martin Nilsson mffmar...@gmail.comwrote: How do I best setup my active record class to have a natural key. Instead of guid as order number I want a sequence that starts with 1 for example. [ActiveRecord] public class Order { [PrimaryKey(PrimaryKeyType.GuidComb)] public Guid Id {get; set;} [??] public int OrderNumber {get; set;} } Note that I will still have guid as id to keep track of if it is saved or not but I want to show the customer a more friendly order number. -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://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 castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Routing Pattern Rules Issue
both rules are using the same pattern: SOME-STRING / SOME- STRING / SOME- INTEGER so the engine will match the first rule. you need to differentiate the two. say: /search/productName/categoryId/ and /product/title/id/ this way, URLs with /search/STRING/INT will match the first, and product/STRING/INT will match the latter On Thu, Feb 12, 2009 at 4:57 AM, eyal ebarda...@gmail.com wrote: hi all, For some reason one routing rule replaces the other. Meaning whenever I try to evoke MyView(id) func SearchResult(categoryId) is executed instead. Any ideas of how to fix this? thanks eyal I have the following routing rules: rules.Add(new PatternRoute(/controller/productName/ categoryId/) .DefaultForArea().IsEmpty .DefaultForAction().Is(searchresult) .Restrict(categoryId).ValidInteger); rules.Add(new PatternRoute(/controller/title/id/) .DefaultForArea().IsEmpty .DefaultForAction().Is(myview) .Restrict(id).ValidInteger); Relating Url generated in view: Evokes SearchResult(categoryId) func $Url.Link($Product.Name, %{controller='products', action='searchresult', params={categoryId=$Product.Id, productName= $Product.Name}) Evokes MyView(id) func $Url.For(%{controller='products', action='myview', params={id= $row.Id, title=$row.title}) -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://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 castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---
Re: Handle Errors with Url Routing
it won't reach the controller since the route won't match. this should be dealt like any other 404 error On Thu, Feb 12, 2009 at 6:52 AM, eyal ebarda...@gmail.com wrote: Hi there, when defining routing pattern rules you can specify type of parameter as such .Restrict(Id).ValidInteger But what if someone tempers with the url and changes the parameter value to a non integer. How can you handle this? For example: mysite.com/productName/12 - correct url mysite.com/productName/d- erroneous url mysite.com/productName/ - erroneous url Normally, I trap and handle such errors in a Controller. But now that I'm using routing, such errors for some reason dont even reach the controller. thanks eyal -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://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 castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~--~~~~--~~--~--~---