kenegozi.com

<form id='kenegozi' action='post'></form>

   
2007 Oct 29

AspView - New Syntax for Passing Parameters to SubViews (Breaking Change)

tagged as: castle | monorail | aspview

The old syntax for passing parameters to subviews was:

 

View sources files used to look like this:

<%Page Language= ... %>
... blah blah ...
<subview:whatever name="value"></subview:whatever>

 

The problem was that you could only have passed variables (by name), so if you needed to pass a string literal you had to declare a string object with the literal:

<%Page Language= ... %>
... blah blah ...
<%string value="literal"; %>
<subview:whatever name="value"></subview:whatever>

 

The new syntax follows the syntax for view components, and also the expected scripting syntax.

so now:

<%Page Language= ... %>
<%
%>
<subview:whatever name="mike" age="<%=30%>" currentItem="<%=item%>"></subview:whatever>

would pass the string literal "mike" to name, the int constant 30 to age, and the object item to currentItem.

 

You can download the new binaries, and a utility to migrate your existing views to the new syntax, from http://www.aspview.com

2007 Oct 29

AspView - New Syntax for Properties Section (Breaking Change)

tagged as: castle | monorail | aspview

So, what is Properties Section?

 

View sources files used to look like this:

<%Page Language= ... %>
<%
    int someProperty;
%>
... rest of view ...

 

The problem was that if you had no properties (or have used the DictionaryAdpater option described here) then you had to have an empty section, like:

<%Page Language= ... %>
<%
%>
... rest of view ...

 

Which is quite ugly.

 

So, following Lee Henson's suggestion, the properties section should now be wrapped in a special tag, and you can just omit that tag if you do not need to declare any properties.

The new syntax (new stuff in Bold Italic Font):

<%Page Language= ... %>
<aspView:properties>
<%
    int someProperty;
%>
</aspView:properties>
... rest of view ...

 

You can download the new binaries, and a utility to migrate your existing views to the new syntax, from http://www.aspview.com

2007 Oct 29

New Homepage for AspView

tagged as: castle | monorail | aspview

I've just setup a brand new site for AspView.

 

It's main purpose is to aggregate AspView related data to one central location. It would contain links to AspView related posts from this blog and others, links to online documentation and samples.

 

There'd be also a "download" page containing the latest builds to be used with Castle RC3 and Castle trunk.

 

The site's link is (surprise surprise): http://www.aspview.com

2007 Oct 26

Annoying Service (B4F97281-0DBD-4835-9ED8-7DFB966E87FF) in Visual Studio 2005 project files

Problem:

Your projects in Visual Studio 2005 are behaving strangely, sometimes not building with funny errors, and tend to marked as modified in your source control

 

When trying to isolate the problem:

you diff your *proj file against a previous version and find this entry:

<Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" />

 

Why is it happening?

You probably have installed VS 2005 SDK, with the DSL tools.

It has a bug in the Text Templating service.

Should have been fixed in VS SDK RTM 4.0, but it hadn't (apparently, as it happened on my machine after installing RTM 4.0)

I saw a promise that the on Orcas SDK it's fixed. I guess that mean that in VS 2005 SDK it won't get fixed.

 

How to solve (dirty - but working):

using your favorite registry editor, locate
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Packages\{a9696de6-e209-414d-bbec-a0506fb0e924} and
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0Exp\Packages\{a9696de6-e209-414d-bbec-a0506fb0e924}
remove (or rename) them, and the Text Templating service won't start, and your *proj files would stay intact.

 

However:

If you do need the Text Templating service, then I can't help ya.

 

Read also at:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=954064&SiteID=1

2007 Oct 26

Tackling Issues When Testing MonoRail Controllers

tagged as: monorail

Usually I'm not doing a strait linking to other's posts.

However, this time I am, as it explicitly answers a few newbie questions in MR and in UnitTesting.

So now I have a reference ...

2007 Oct 25

I've just been Knighted as a member of the Castle

tagged as: castle

In one word: Wow.

 

In a few more: It seam that the Castle Project PMC got tired of me nagging them about some patches, so they've decided to make me a commiter.

 

Ken in Castle

 

I find it very flattering, as this group is made of very talented people, who are maintaining a rather large, sophisticated, extremely useful and widespread set of frameworks and libraries.

 

I hope I will stand up to the faith they've given in me, by contributing Good Stuff into the repository, and help making existing Good Stuff into Great stuff, and Great Stuff into Amazing.

2007 Oct 23

Comments are temporarily off

tagged as: miscellanea | blog engine

Sorry.

I need to do that, at least for a few days.

 

If you want to leave a message, mail me:

 

blog at the-domain-name-of-this-blog (without the www part, of course ...)

2007 Oct 19

A new .NET blog in the sphere

tagged as: miscellanea

I think I'm going to like this one, since he showed some (simple but interesting) ILDASM output on his second post.

 

Found him through JoeyDotNet.

 

UPDATE:

The link to D. P. Bullington's blog is now fixed.

2007 Oct 17

Typed View Properties in MonoRail and AspView

tagged as: asp.net 2.0 | c# | castle | monorail | aspview

Following my last post on the DictionaryAdapter, I'll demonstrate here how you can get typed access to your views' properties.

 

What it requires from you:

1. Declare an interface for each of your views. That is a Good Thing anyway, as designing to a contract is a good best practice, and it allows for easy testing.

2. Have a base class for your controller that would define TypedFlash and TypedPropertyBag. Not mandatory, but very convenient.

3. Use the newest build of AspView. Again - not mandatory, but helpful.

 

Now for the showtime.

First we would create a base class for our controllers, with a TypedPropertyBag and TypedFlash properties:

public abstract class Controller<IView> : SmartDispatcherControllerController
where IView : class
{
IDictionaryAdapterFactory dictionaryAdapterFactory;
    IView typedPropertyBag;
    IView typedFlash;
    protected IView TypedPropertyBag
    {
        get
{
if (typedPropertyBag == null)
        typedPropertyBag = dictionaryAdapterFactory.GetAdapter<IView>(PropertyBag);
return typedPropertyBag;
}
    }
    protected IView TypedFlash
    {
        get
{
if (typedFlash == null)
        typedFlash = dictionaryAdapterFactory.GetAdapter<IView>(Flash);
return typedFlash;
}
    }
    protected override void Initialize()
    {
        base.Initialize();
IDictionaryAdapterFactory dictionaryAdapterFactory = new DictionaryAdapterFactory();
    }
}

 

tip:

You can look at a more complete version of that base-class, written by Lee Henson (who have made some improvements to the original DictionaryAdapter, and also have introduced me to Peroni Beer).
The base controller also declares a type parameter for a Session DictionaryAdapter, hooks into the Castle.Tools.CodeGenerator, and uses IoC for DI.
Talking about those issues is a separate subject, for other posts.

 

Now let's create the view contract. A rather stupid example would be:

public interface IStupidView
{
    Guid Id { get; set; }
string Name { get; set; }
}

 

controller:

public class StupidController : Controller<IStupidView>
{
public void Index()
{
}


public void DoStuff(string name, string password)
{
if (password != "AspView Rocks")
{
TypedFlash.Name = name;
TypedFlash.Message = "Wrong Password";
RedirectToAction("Index");
return;
}
TypedPropertyBag.Id = Guid.NewGuid();
TypedPropertyBag.Name = name;
}
}

 

view (Index.aspx):

<%@ Page Language="C#" Inherits="Castle.MonoRail.Views.AspView.ViewAtDesignTime<IStupidView>" %>
<%
%>
<p><%=view.Message %></p>
<form action="DoStuff.rails">
Name: <input type="text" name="name" value="<%= view.Name %>" /> <br />



password: <input type="password" name="password" /> <br />
<input type="submit" />
</form>

 

view (DoStuff.aspx):

<%@ Page Language="C#" Inherits="Castle.MonoRail.Views.AspView.ViewAtDesignTime<IStupidView>" %>
<%
%>
The data was: <br />
Id: <%= view.Id %>, Name: <%= view.Name %>

 

Look at the intellisense (and at my ultra-cool black color scheme):

TypedView intellisense

 

 

Things to notice:

1. Do not forget to reference the Assembly that has the view interface declaration. On the test site within aspview's source repository the interface is declared in the Web project (AspViewTestSite), so the web.config has this:

view (Index.aspx):

<aspview ... >
...

    <reference assembly="AspViewTestSite.dll"/>
...
</aspview>

 

2. you can use the DictionaryAdapter directly, on older versions of AspView (and on WebForms aspx/ascx files) by simply grabbing an adapter manually.  sample:

...
<% IMyViewContract view = new Castle.Components.DictionaryAdapter.DictionaryAdapterFactory()
.GetAdapter<IMyViewContract>(Properties); %>
...
blah blah <%=view.UsefulProperty %>
...

Ok, cut the crap. where can I get it?

here (release, debug, source)

 

UPDATE:

The DictionaryAdapter was initially written by the guys from Eleutian as part of Castle.Tools.CodeGenerator.

2007 Oct 16

Typed Session using Castle.Components.DictionaryAdapter

tagged as: asp.net 2.0 | castle

The castle project has a little gem hidden within.

Well, it has many of those, but I'll refer to one of them here.

Castle.Components.DictionaryAdapter

 

This is a tool that can generate typed wrapper around any IDictionary, using a POCI (Plain Old CLR Interface) as a contract. The generation occur on runtime, using Reflection.Emit magic.

 

Ok, assume you have an information system written in ASP.NET ( warning - WebForms code ahead).

You might keep the current username and a user preferences object in the session.

Somewhere along your application, you'd probably have a pieces of code like that:

public static class TypedSession
{
private static HttpSessionState session = HttpContext.Current.Session;

public static string Username
{
get { return (string)session["Username"]; }
}
public static Preferences Preferences
{
get { return (Preferences)session["Preferences"]; }
}

}

and in your code you'd be able to do:

...
if (TypedSession.Preferences.Color == Color.Red)
helloLabel.Text = "Hello " + TypedSession.Username;
...

 

Now, I won't get into those arguments, but generally speaking it would be great if you had an interface to encapsulate your session data (for example - it's good for testing as you can easily mock session data).

So:

public interface ISession
{
string Username { get; set; }
Preferences Preferences { get; set; }
}

 

And use it like that:

...
ISession TypedSession = new DictionaryAdapterFactory().GetAdapter<ISession>(Session);
...
if (TypedSession.Preferences.Color == Color.Red)
helloLabel.Text = "Hello " + TypedSession.Username;
... 

 

You probably want to put the creation of the TypedSession in a base class.

 

And you've probably noticed that the adapter itself is being acquired through an interfaced Factory, so you can easily use your IoC container of choice to plug in specialized implementations on rare edge cases, and also use your Mock framework of choice for easy testing.

 

On the next post I'll show you how well that fit into the world of MonoRail and AspView, as the use of dictionaries is wide (PropertyBag and Flash), and using that library + the newest addition to AspView can grant you with a simple, type safe and intellisense friendly view development experience.

2007 Oct 15

Hidden Networks Promotion - Find Developers Where They Hang Out

tagged as: miscellanea

The idea behind Hidden Networks is great.

They've added that simple job board (here, on the right. If you're on a feed reader, go the HTML version and look it up) that shows openings near the reader's (that's you) location.

 

That way, recruiters gets exposure on the places where developers who are interested in Learning New Stuff hang out.

If they read Ayende (or me), then you might want them for your team.

 

And now - there's a promotion code.

Quote that: 100OFF0710

And get a 100$ off your first ad.

This offer is good until the end of the month (31/10/2007).

2007 Oct 15

MonoRail Faq

tagged as: monorail

Following Adam Esterline's post, some Frequently Asked Questions regarding MR, and my answers:

 

Q: "What kinds of projects work best with MonoRail?":

A: all. I'd rather use SmartGridComponent (someone has added auto sorting lately) that GridView, anyday.
Especially because those "reporting only" projects tend to grow business rules.

 

Q: "Can we use 3rd party CustomControls?"

A: Maybe (using WebFormsViewEngine, and other 'bad' stuff). However, you can use 3rd party DHTML Controls, which usually are much better, cooler, (and cheaper)

 

Q: "How do I find new developers? I'd need to teach new devs a lot of new stuff to get them started"

A: I've never saw a new developer being productive on day 1. Since there's no convention in the .NET world, he'd need to learn a lot on arrival, and on every time you'd take him to a new project.
Learning to use MR is surprisingly simple, and from my experience, developers learn that very fast, can easily hook to existing Controllers and Views code. I've been involved in a WebForms->MR move on four companies, on all cases, all of the existing developers learned it fast, enjoyed it a lot and enough to use MR on future projects, and at least in one place, it allowed the team to recruit a former PHP dev and integrate him to the team in a breeze.

As for recruitment, the idea of HiddenNetworks is genius. People who read my blog (or even better, Ayende's blog) are probably familiar with MR, so try and grab them. Hey, don't forget to tell the HiddenNetworks guys that I've sent you!

 

Q: "Now that Microsoft MVC is out, should I use MonoRail?"

A: Microsoft MVC is great. It means that the Big Guns are actually listening to the community. However, it is definitely not Out. I believe it would take a considerable amount of time until it'd be RTM. While MonoRail is in production quality for a long time now, it's proven, many sites use that, and surly it's a better choice today, as Ms.MVC is not a choice yet. You should play with MS.MVC, you should learn about it, and when the day comes, you'd be able to move from MR to Ms.MVC if you'd like, cuz the concepts are similar enough.

2007 Oct 13

SQL Server 2005 - Cannot create Database Diagrams - Database does not have a valid owner

tagged as: SQL Server

Using SQL Server Management Studio (be it the 'full' version or the express one), you can sometime encounter the error:

Database has no valid owner

in words:

Database diagram support objects cannot be installed because this database does not have a valid owner.  To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support objects.

It usually happens when you've created that DB by a script (which was a bit incomplete) or by restoring a DB created on another machine, with some different settings.

 

Instead of going to the bottom of it, I'll just write down the simple solution, for future reference.

open a new Query, and run the next stored procedure:

EXEC sp_changedbowner 'sa'

If you have another default owner on your machine, use it's login instead of 'sa'.

That's it.

2007 Oct 12

On Potty Mouths, or Fuck Those Leaky Abstractions

tagged as: client-side | html

Reading David Heinemeier's post, it got me thinking.

In short (my words):

Since the meaning is what important, it doesn't matter whether you use Curse Words or their 'polite' euphemisms. The saying 'What the fuck is that' represents an honest question, while saying 'We should exile all those socially challenged foreigners'. Using Politically-Correct words in an outrageous sentence is much worse than a naive 'It's fucking great'.

 

Favorite quote from David's post:

...fake euphemisms that are actually much worse than the honest words they're trying to put a fig leave to.

Anyway, while thinking about that, a (bit far fetched) analogy came to my mind.

Many developers refer to 'HTML', 'DHTML' and 'Javascript' as curse words.

So they come up with euphemisms like Script#, RJS, WebForms and others, and by that, applying badly leaking abstractions on top of simple things. (HTML and Javascript are quite simple. you can see 13 year old kids that master those, but much less 13 years old master server OO languages).

 

Funny anecdote:

Writing this post on Windows Live Writer, the spell-checker is pointing out that 'fuck' is a misspelled word. One of the fix suggestions though is 'suck' ...  Ha Ha.

2007 Oct 8

The uncool wedding invitee, or, blogging on an old PDA

tagged as: miscellanea | personal

It's time to reveal one of my major handicaps, that didn't make it to my "five things you didn't know about me" list:

I can't dance.
I hate to dance.
I won't dance.

 

Therefore: I am getting bored at weddings.

 

Yesterday at a wedding party of a good friend of ours, I found myself sitting at the table by myself, with only my old PDA to accompany me.

So I wrote a post about the new release of AspView.

I would've written that one, too, however the PDA went low on battery, so I've had to find something else to do.

 

That was, drawing some domain design concepts for a portion of my new project at Music Glue, not on napkins, but rather on the back side of my checkbook ...

 

When we went home, the happy groom and bride hugged and thanked Sarit who was dancing all night like a party animal, and then gave me The Look. Yep, That one. That say "You'd better leave a fine present as no happiness came from your's tonight".

2007 Oct 8

AspView for Castle RC3 - new release

tagged as: tools | castle | monorail | aspview

Although about three weeks too late, I present thee:


AspView, built for Castle RC3 (release, debug, source)


I've also introduced a well due improvement to the engine. Now it supports the use of a 404 rescue view, that would get rendered in case of the url mapping to a non-existent controller.

 

the commit comment (for revision 314) says it all:

Handling view creation for EmptyController, specifically when a controller is not found and a 404 rescue exists

Next improvement will include an option for doing AutoRecompilation in memory, as sometimes the IIS process gets hold on the CompiledViews assembly files (dll and pdb) and failing the automatic recompilation process.

I certainly need that as it happens on my machine too much, and building the Web project takes a solid 10-15 seconds, while running vcompile is a milliseconds thing only.

 

Soon ...

2007 Oct 7

IE7 to the masses - the end of IE6 compatibility issues?

tagged as: client-side | css | tools

That's a great news for everyone who build websites and web applications.

IE7 would be installable even to XP users without the Genuine Check.

That means that in short time, the IE7 adoption rate would increase so much, that hopefully the annoying IE6 would become as obsolete as Netscape 4 and IE 5.5 ...

 

No more dirty CSS hacks (or at least, a lot less)

No more buggy box-model

Finally we can use input[type=text] and the likes

 

I've kept IE6 on my box for so long only to be able to test what I write. Even though I use Firefox for day-to-day browsing, I still need IE for some crappy israeli sites that would just not work on non IE (and by not work - I mean that you get an alert box saying:

This site is IE only

For people who knows not Hebrew:

"This site supports IE browsers, from version 5.5 and up. Support to other browsers is planned for next release"

Ha Ha.

This message is there for at least a year.

And it's not even dependant on ActiveX or other IE magic. It's only some laziness regarding JS and CSS compatibility.

2007 Oct 7

Some details on the new web MVC framework from Microsoft

tagged as: asp.net 2.0 | monorail | aspview

Now that the Big Boys do actually listening to the community, and gives a shot at a solid MVC web framework is a Good Think.

I would really like to see that in action, and would really like to see how they are coming up with stuff that are more than just url->action wiring, such as parameter bindings, view-components, etc.

 

It's going to be interesting, and MonoRail (and) might need some boost to keep being the (imho) no. 1 choice for Web MVC in .NET

It would be interesting also to see where would AspView fit in the new playground.

 

btw, would that be part of .NET 4.2?

 

Anyway, since it might take some time to get this new stuff on a production level, I do not believe that no one that works on production system (or those that are supposed to be at production during the coming year) should ditch MR. Even when it'd be out, I might consider MR as a better solution as it's Open Source, therefore more self twickable, and a lot more responsive in terms of bugfixes.

2007 Oct 3

Forget about Reflector-ing the BCL - the real deal is here

Another nice news from Scott Guthrie:

 

a small excerpt:

Today I'm excited to announce that we'll be providing this with the .NET 3.5 and VS 2008 release later this year.

2007 Oct 1

Horrible spam

tagged as: blog engine

I haven't monitored the blog's comments for only a week, and now I've had to delete 988 spam messages.

 

I guess I'm going to re-do the comment mechanism really soon.

2007 Oct 1

Must I install the new version?

tagged as: miscellanea

Needless to say that I did not like that message at all:

Must install new version

I liked the old UI better. Why can't I continue use it, and just skip the new stuff?

2007 Oct 1

It was a craic*

tagged as: miscellanea | personal

Just been back from a few days in Ireland, where I went with Sarit for a vacation, and for getting to a clearer state of mind. At least on that level it proved to be very productive, as I came back with more than a few solutions to problems I've been facing ,and even some new ideas for expanding the line of services that we, at Music Glue, can provide.

 

Just so you'd understand how muse-ful can Ireland be:

 

 Waterfall at Wicklow

 

and:

 

View from Valetia Island

 

(All pictures were taken on a Canon S3 IS Camera - a perfect thing for a photo-newbie like me)

 

I'll upload some more pictures in the next days. Actually, I guess it is high time I'll get me a proper image sharing service subscription.

Any recommendation of a free (or low cost) ones?

I guess my priorities would be:

High availability;

Fast;

Easy to use (allow multiple uploads, allow easy post-upload tagging);

 

More pictures to come ...

 

*Craic: Irish word for fun/enjoyment that has been brought into the English language. usu. when mixed with alcohol and/or music. source: http://www.urbandictionary.com/define.php?term=craic

Subscribe

Statistics

283
440

Related Books

Related Jobs

Related Ads

search page | Blog's home | About me