Archives

Archives / 2004 / August
  • Selecting the tools before you know what your needs are

    (blowing off some steam here)

    Someone blogged earlier about selecting tools and platforms before you're sure about what your needs are. Looks like I'm going to be affected by that now. I'm one of the responsible architects for implementing a java based portal that must integrate with a document management system and a search system that knows nothing about each other, has no standard ways of plugging into each other and no one seems to have done this before. Yay! Besides, one of the requirements are to have automatic and seamless login for the windows users into the portal, which, as I said, is based on Java...

    We fixed the automatic login requirement by using JCIFS open source stuff from samba, which implements the CIFS/SMB protocol, but IMHO it's sort of a hacky way of doing it. I'm looking at replacing that part with some 3rd party access management system though... For large enterprise sized portals I prefer using a supported way of doing access, which *is* a pretty important part. No access - no portal, right?

    Well, only thing to do is just smile and dig into each product and make them talk to each other somehow. It will take much longer to implement and it won't be a standard way of integrating portals with content and search, that's for sure.

    Some people complains about the risk of "getting stuck into proprietary Microsoft products", but personally I prefer that to getting stuck into a much smaller product that once sprung up from some open source portal framework initiative and now has evolved into a monster that needs a gazillion of bytes just to wake up and start chewing request! During the time it grew from baby monster to a huge monster the owner of the pet changed a number of times and the price went from zero buckazoids to a price relative to the amount of memory needed to get it running...

    At least I got the power (in my dreams) to select the platform for building the Web Service layer we will need to integrate with other systems. I'll certainly raise my hand for .NET Web Services and use WSE 2.0 (or what there will be in ASP.NET 2.0) for security. I'll see how far AXIS and WSS4J has come...

    I need to say though, that I don't mind being involved in this project because even though that it could have been easier with other products, it's pretty fun to try to solve problems with integration, security, where to store content and how to search for it :)

    (I feel much better now, thanks)

  • Spent a day of WSE 2.0 coding at Microsoft Sweden

    Johan Lindfors, who is a Developer Evangelist at the Swedish Microsoft office, came up with the good idea of inviting interested people to a full day of WSE 2.0 coding. Some of us brought our own laptops and Johan had prepared DVD discs with VPC images of Windows XP, VS.NET and WSE 2.0 and some WSE labs from Teched 2004. Really smooth! In 20 minutes I had everything I needed to get going and a bunch of really good people to talk to and discuss stuff.

    We looked at Messaging with SoapReceiver and SoapSender and also using SoapService and SoapClient and running SOAP over TCP. Then we had a look at Security and Policy, digging into security tokens, roles, signing and stuff like that.

    I had a nice day indeed :)

  • [.NET 2.0] Adding Web Parts programmatically (part 2)

    I got a tip from Mike Harder on the ASP.NET Team to derive from CatalogPart and do my own catalog. So I tried that and it works pretty nice. I'd like to share my experience like this. Note that I'm a complete newbie when it comes to WebParts and the 2.0 documentation in this area is sort of under construction it seems :)

    Anyway, first create a simple ASPX page with the basic stuff needed (I won't go into details of the manager and such):

    <%@ Page Language="C#" CompileWith="MyCatalog.aspx.cs" ClassName="MyCatalog" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">

        <title>Untitled Page</title>

    </head>

    <body>

        <form id="form1" runat="server">

            <asp:WebPartManager ID="WebPartManager1" Runat="server" OnDisplayModeChanged="WebPartManager1_DisplayModeChanged">

            </asp:WebPartManager>

            <asp:WebPartPageMenu ID="WebPartPageMenu1" Runat="server" Text="Display Mode" Mode="Menu">

                <HoverStyle BorderWidth="1" />

                <MenuStyle BorderWidth="1" />

                <BrowseModeVerb Text="Browse" />

                <DesignModeVerb Text="Design" />

                <EditModeVerb Text="Edit" />

                <CatalogModeVerb Text="Catalog" />

            </asp:WebPartPageMenu>

            <br />

            <h1>

                Web Parts Testing Page</h1>

            <br />

            <table cellspacing="0" cellpadding="0" border="0">

                <tr>

                    <td valign="top">

                        <asp:WebPartZone ID="WebPartZone1" Runat="server" DragHighlightColor="244, 198, 96"

                            HeaderText="My Zone" HeaderStyle-Font-Bold="true">

                            <PartTitleStyle ForeColor="#666644"></PartTitleStyle>

                            <ZoneTemplate>

                            </ZoneTemplate>

                            <PartStyle BorderWidth="0px" BackColor="Yellow"></PartStyle>

                        </asp:WebPartZone>

                    </td>

                    <td valign="top">

                        <asp:EditorZone ID="EditorZone1" Runat="server">

                            <ZoneTemplate>

                                <asp:AppearanceEditorPart Runat="server" ID="AppearanceEditorPart1" />

                                <asp:LayoutEditorPart Runat="server" ID="LayoutEditorPart1" />

                            </ZoneTemplate>

                        </asp:EditorZone>

                        <asp:CatalogZone ID="CatalogZone1" Runat="server" HeaderText="Add Web Parts">

                        </asp:CatalogZone>

                    </td>

                </tr>

            </table>

        </form>

    </body>

    </html>

     

    It's very simple, and has only one WebPartZone in it. The code behind for the ASPX page looks like this:

    using System;

    using System.Web.UI.WebControls.WebParts;

     

    public partial class MyCatalog

    {

               void Page_Load(object sender, EventArgs e)

               {

                          //if we're in catalog mode, show our special catalog

                          if (WebPartManager1.DisplayMode.Name == "Catalog")

                          {

                                     AddMyCatalog();

                          }

               }

     

               /// <summary>

               /// Code to add our own catalog to the catalog zone

               /// </summary>

               private void AddMyCatalog()

               {

                          MyCatalogPart catalogPart = new MyCatalogPart();

                          catalogPart.ID = "mycatalog";

                          catalogPart.Title = "My Catalog";

     

                          CatalogZone1.CatalogParts.Add(catalogPart);

               }

     

               void WebPartManager1_DisplayModeChanged(object sender, WebPartDisplayModeEventArgs e)

               {

                          //if the user has changed display mode to catalog, add it to the catalog zone

                          if (WebPartManager1.DisplayMode.Name == "Catalog")

                          {

                                     AddMyCatalog();

                          }

     

               }

    }

    And finally, the implementation of MyCatalogPart. It is derived from CatalogPart and must implement GetAvailableWebPartDescriptions() and GetWebPart()

    using System;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Collections;

     

    /// <summary>

    /// Test implementation of my own catalog part, which displays a dynamic list

    /// of web part that I can get from a database, xml or by perhaps looking for

    /// web parts assemblies on disk.

    /// </summary>

    public class MyCatalogPart : CatalogPart

    {

     

               /// <summary>

               /// Returns a collection of available web parts in my catalog

               /// </summary>

               /// <returns></returns>

               public override WebPartDescriptionCollection GetAvailableWebPartDescriptions()

               {

                          //normally get a list of web parts dynamically from XML or database or something

                          WebPartDescription wpDescription = new WebPartDescription("MyWebPartID", "My Web Part", null);

                          ArrayList arrWpDescriptions = new ArrayList();

                          arrWpDescriptions.Add(wpDescription);

                          return new WebPartDescriptionCollection(arrWpDescriptions);

               }

     

               /// <summary>

               /// User has selected a web part in my catalog, return the correct instance of that web part

               /// </summary>

               /// <param name="description">The selected web part from the catalog</param>

               /// <returns></returns>

               public override WebPart GetWebPart(WebPartDescription description)

               {

                          if (description.ID == "MyWebPartID")

                          {

                                     //returning an instance of the selected web part

                                     return new MyWebPart();

                          }

     

                          return null;

               }

    }

    The very simple Web Part called MyWebPart is described in my previous blog post, but you can replace it with whatever web part you wish. Let me know if you try this one out and anything seems to crash. As I said, I'm new to this portal framework - haven't even looked at how things are done in SharePoint.

  • [.NET 2.0] Adding Web Parts programmatically

    I'm playing around with the portal frameworks and web parts in .NET 2.0 and it looks powerful. The thing that bugs me most right now is the built in personalization stuff that remember everything I do on my web page (like closing a web part by mistake and not being able to get it back :)

    At the moment I'm looking at the best way to programmatically add web parts from say another assembly and allow the user to add it to a zone. The way I'm doing it now is by implementing the abstract WebPart class and adding it to the zone.

    A very simple Web Part class looks like this:

    using System;

    using System.Security.Permissions;

    using System.Web;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

     

    public class MyWebPart : WebPart

    {

               public MyWebPart()

               {

                          //comment to allow close

                          this.AllowClose = false;

               }

     

               public MyWebPart(String Title) : base()

               {

                          this.Title = Title;

               }

     

               protected override void CreateChildControls()

               {

                          Controls.Clear();

                          Label DisplayContent = new Label();

                          DisplayContent.Text = "Hello web part";

                          this.Controls.Add(DisplayContent);

                          ChildControlsCreated = true;

               }

     

    }

    And I'm adding it to the zone like this:

    private void AddPart()

    {

        MyWebPart myPart = new MyWebPart("MyPart");

        WebPartManager1.AddWebPart(myPart, LeftZone, 0);

    }

    Problems I have now is that the Web Part disappeares sometimes and I don't know how add this Web Part to a CatalogZone. Not much info on the Net about stuff like this. Pity I didn't attend the TechEd, I'm sure there was lots of Web Parts coding samples there. If anyone knows the best way to do it, please let me know.

    EDIT 1: It seems that you're not supposed to be using a CatalogZone when you want to add Web Parts at run time. Just implement you own kind of catalog and use the AddWebPart() to add it to the zone you want to have it in. The Web Part will saved in the personalization data.

    EDIT 2: I've implemented my own catalog now by deriving from CatalogPart. See my other blog post for a sample.

    Anyone working on doing a portal framework on top of this? Something like IBuySpy Portal but based on Web Parts instead of User Controls?

  • Installing SQL 2005 Express on top of SQL 2000

    I'm going to install the VS 2005 beta on one of my lab boxes here, and this machine already has SQL 2000 on it. What happens if I check to install SQL 2005 Express during the VS 2005 installation? Will it upgrade 2000 to 2005 or what?

    I'm sure people has tried this out there, but if I don't get any response I'll just go ahead and try and see what happens :)

    EDIT 1: Brilliant... Ok, first I installed VS 2005 and all the MSDN stuff, then I rebooted the machine and tried to add SQL 2005 Express. Problem is that it hung in the end (progress meter near 100%) and refused to finish. So I killed the setup process and had a look at the box. It looks like SQL 2005 was installed properly and everything. Just one thing I wonder now... and this sounds stupid maybe, but how do I know which database service I'm running against?? *confused*

    EDIT 2: Ok, I'm almost there! I downloaded the SQL Server Express Books Online and I'm following the walkthrough to create a database app. To be cont.

    EDIT 3: Right, I'm in! It was very easy once I got into it (as usual). 1) Install SQLExpress 2) Make sure SQLExpress service is started and you may also want to start the SQL Browser service and enable some of the other network protocols if you're not running locally only 3) Use your favourite SQL manager (like the server browser in VS 2005) and access the database instance by calling it .\SQLExpress or <computername>\SQLExpress.

    *running off to try some of the new features*

  • No PDC this year?

    I'm trying to find information about a PDC 2004 from Microsoft, but I can't find anything about it. Aren't there going to be one this year?
  • Got a cat

    After 5 weeks of vacation it's time to get back to work again. It's not that funny considering the really, really hot weather we got here in Stockholm at the moment. Not much to do about it though...

    We've got ourselves a kitten. A black male, just 10 weeks old. He's half Maine Coon, half Norwegian Forest so I guess he's going to be a really big and good hunter.