PDA

View Full Version : Spring .NET with PeterBlum validators



Billy
03-20-2006, 10:48 PM
If I declare an ASPX page within a web.config's spring/objects, then PeterBlum validators fail with the following error:

------------------
Request is not available in this context
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Request is not available in this context

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[HttpException (0x80004005): Request is not available in this context]
System.Web.UI.Page.get_Request() +2025389
PeterBlum.VAM.TrueBrowser.GetTrueBrowser(Page pPage) +73
PeterBlum.VAM.BaseValidationSummary.OnPreRender(Ev entArgs pArgs) +52
System.Web.UI.Control.PreRenderRecursiveInternal() +77
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360
------------------

Would have any insight as to why the Request object isn't available and what I might be able to do to fix it?

Thanks!
Billy

LaTtEX
03-21-2006, 08:25 AM
That's because Spring ASPX pages don't inherit from System.Web.UI; they inherit from Spring.Web, and based on the stack trace the PeterBlum objects obviously need to pass on a System.Web.UI.Page object.

Billy
03-21-2006, 07:33 PM
Not to sound too reactionary, but it seems to me this is a bad design decision on Spring .NET's part. The Request object should always be available to an ASPX page, regardless of whether or not it inherits from Spring's page, or from System.Web.UI page object. Even if Spring's page object doesn't make the Request object available, then the Request object should, at the very least, always be available to the ASPX page if it inherits from System.Web.UI.Page. (My page was inheriting from System.Web.UI.Page when it lost access to the Request object during IoC actions.) It seems that removing this assumption, i.e. the assumption that the Request object is always available within an ASPX page, breaks proper OOP design as an "unexpected side effect." Don't get me wrong, I love the Spring .NET framework and love the direction it's headed and will continue using it in my projects. But for this particular issue, it seems that the Request object should always be available to the page. Is there a way to remedy this?

Billy

Aleks Seovic
03-21-2006, 07:53 PM
You are not reactionary and you are perfectly right -- Request object should be, and as far as I know is, always available to the Spring Page.

Spring.Web.UI.Page inherits from Sustem.Web.UI.Page, and Request property is instantiated in the standard way using SetIntrinsics method by the ASP.NET, not Spring, so there is no reason why request shouldn't be available.

Of course, as systems become more complex and you have multiple frameworks in use, the chance of strange and unexplainable behavior goes up -- I have no way of knowing what Peter Bloom is doing and why the request cannot be used.

The funny thing is that I don't see a single method from Spring namespace in the stack trace, so I'm not sure that the problem is in Spring. The only thing I can think of is that there might be a problem with a handler wrapper created by Spring's PageHandlerFactory, but it is hard to pinpoint the issue without analyzing in depth what's going on in the code listed in the stack trace.

BTW, even though Peter's validators are a great improvement over standard ASP.NET validators, I still think that validation framework built into Spring is better than either solution and will allow you to do much more. I know that I'm not the most objective person on the subject, but is there any particular reason why you are not using it?

Regards,

Aleks

Billy
03-21-2006, 08:04 PM
Thanks for the reply Aleks. I can certainly understand that as different frameworks mesh, unexpected consequences are inevitable. I'm glad to hear that the Request should be available at all times. I can now retract my last post. ;)

I apologize for the newbie question, but where's the best place to go for an overview and samples of validation within ASP.NET? I've looked in http://www.springframework.net/documentation.html and in http://www.springframework.net/doc/reference/html but can't find what I'm looking for.

Honestly, I'd like to keep the number of frameworks to a minimum and would be happy to use the Spring .NET validation.

Thanks!

LaTtEX
03-22-2006, 01:41 AM
Billy,

There's no documentation for Spring validators yet (and for most other features changed/added after 11/16/2005) but I've learned using them by following the sample validations in SpringAir. You can get this from the nightly build downloads.

Billy
03-22-2006, 03:27 PM
Thanks! Downloading latest now.