Help with Portal Site

44 posts, 0 answers
  1. Jon Hobbs
    Jon Hobbs avatar
    48 posts
    Member since:
    May 2007

    Posted 28 Apr 2007 Link to this post

    Hi Guys,

    I am using Rad Dock Prometheus for the first time and I have an ambitious project.

    I want to build a home page which initially loads lots of "widgets"  into a certain layout, allow the user to move them around, save their layout to a database and add new widgets by clicking an add button.

    The problem is that I don't know where to start. I have got several Widgets containing user controls and managed to put them into three docking zones. I can move them around on the page but don't know how to do the following....

    * Save the layout to a SQL server database.
    * Reload the layout when the user logs back on if they have a layout saved.
    * Allow them to add new docks which are initially hidden

    I have looked at the myportal example in the documentation but haven't managed to get the "save layout to session" code working at all. Does anyone know of a good article on how to make a portal like this ?

    If you need any example of how it needs to work you can see what I mean on http://gamers.eurogamer.net/.

    Thanks, Jon
  2. Jon Hobbs
    Jon Hobbs avatar
    48 posts
    Member since:
    May 2007

    Posted 03 May 2007 Link to this post

    Anybody else tried to do this yet ?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Petya
    Admin
    Petya avatar
    869 posts

    Posted 10 May 2007 Link to this post

    Hello Jon Hobbs,

    Please, test the attached project with the updated version of the control which you can find here. This is a trial version - if you want the developer's version, please open a support ticket and we will send it to you.

    All the best,
    Petya
    the telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Jon Hobbs
    Jon Hobbs avatar
    48 posts
    Member since:
    May 2007

    Posted 18 May 2007 Link to this post

    Hi Petya,

    Thanks for that, I will give it a try and let you know how I get on :)

    Jon
  6. gil_yoktan
    gil_yoktan avatar
    9 posts
    Member since:
    Apr 2007

    Posted 22 May 2007 Link to this post

    Hello  As I'm interested to see this example, I downloaded the ZIP file and checked it out
    I didn't find the MyPortalDB specified in the web.config:
    <add name="MyPortalDBConnectionString1" connectionString="Data Source=TATEVA\SQLEXPRESS;Initial Catalog=MyPortalDB;Integrated Security=True"   providerName="System.Data.SqlClient" />

    Maybe there is something I didn't understand...
    Thanks in advance
    Gil Yoktan
  7. Petya
    Admin
    Petya avatar
    869 posts

    Posted 22 May 2007 Link to this post

    Hi,

    I truly apologize, I guess I missed adding the database to the .zip I sent you. Please, find attached the MyPortalDB database.

    All the best,
    Petya
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. mikejoseph
    mikejoseph avatar
    16 posts
    Member since:
    Jan 2007

    Posted 23 May 2007 Link to this post

    Here's my VB.NET translation if it saves anyone some time...

    Imports System.Collections  
    Imports System.Collections.Generic  
    Imports Telerik.Web.UI  
     
    Partial Class Portal  
        Inherits BasePage  
     
        Private _state As String 
     
        Private Property CurrentDockStates() As List(Of DockState)  
            Get 
                Dim _currentDockStates As New List(Of DockState)  
                Dim state As String = CustomerDataset.CustomerDataTable.GetPortalState(CustomerSession.CustomerId)  
                Dim dockState As DockState  
     
                If state = "" Then 
                    Return _currentDockStates  
                Else 
                    Dim dockStates As String() = state.Split("|")  
     
                    For i As Integer = 0 To dockStates.Length - 1  
                        If Not String.IsNullOrEmpty(dockStates(i)) Then 
                            dockState = dockState.Deserialize(dockStates(i))  
                            _currentDockStates.Add(dockState)  
                        End If 
                    Next 
     
                    Return _currentDockStates  
                End If 
            End Get 
            Set(ByVal value As List(Of DockState))  
                Dim sb As New StringBuilder  
                For i As Integer = 0 To value.Count - 1  
                    Dim serializedState As String = String.Concat(value(i).ToString, "|")  
                    sb.Append(serializedState).ToString()   ' I don't think the ToString is necessary, but the sample included it so....  
                Next 
     
                CustomerDataset.CustomerDataTable.SavePortalState(CustomerSession.CustomerId, sb.ToString)  
            End Set 
        End Property 
     
        Private Function CreateRadDockFromState(ByVal state As DockState, ByVal number As Integer)  
            Dim dock As New RadDock  
            dock.ID = String.Concat("RadDock", number)  
            dock.ApplyState(state)  
            dock.Visible = (Not state.Closed)  
            Return dock  
        End Function 
     
        Private Function CreateRadDock() As RadDock  
            Dim docksCount As Integer = Me.CurrentDockStates.Count  
            Dim dock As New RadDock  
            With dock  
                .ID = String.Concat("RadDock", docksCount)  
                .Title = String.Concat("Dock ", docksCount)  
                .Text = String.Concat("Added at "Date.Now)  
                .UniqueName = Guid.NewGuid.ToString  
                .Width = Unit.Pixel(300)  
            End With 
     
            Return dock  
        End Function 
     
        Private Sub CreateSaveStateTriggers(ByVal dock As RadDock)  
            'Ensure that the RadDock control will initiate postback  
            ' when its position changes on the client. Using the  
            ' trigger we will "ajaxify" that postback.  
            dock.AutoPostBack = True 
            dock.CommandsAutoPostBack = True 
     
            Dim saveStateTrigger As New AsyncPostBackTrigger  
            saveStateTrigger.ControlID = dock.ID  
            saveStateTrigger.EventName = "DockPositionChanged" 
            Me.UpdatePanel1.Triggers.Add(saveStateTrigger)  
     
            saveStateTrigger = New AsyncPostBackTrigger  
            saveStateTrigger.ControlID = dock.ID  
            saveStateTrigger.EventName = "Command" 
            Me.UpdatePanel1.Triggers.Add(saveStateTrigger)  
        End Sub 
     
        Private Sub LoadWidget(ByVal dock As RadDock)  
            If String.IsNullOrEmpty(dock.Tag) Then Exit Sub 
            Dim widget As Control = LoadControl(dock.Tag)  
            dock.ContentContainer.Controls.Add(widget)  
        End Sub 
     
        Protected Sub RadDockLayout1_LoadDockLayout(ByVal sender As ObjectByVal e As Telerik.Web.UI.DockLayoutEventArgs) Handles RadDockLayout1.LoadDockLayout  
            ' Populate the event args with the state information. The RadDockLayout control  
            ' will automatically move the docks according that information.  
            For Each state As DockState In Me.CurrentDockStates  
                e.Positions(state.UniqueName) = state.DockZoneID  
                e.Indices(state.UniqueName) = state.Index  
            Next 
        End Sub 
     
        Protected Sub RadDockLayout1_SaveDockLayout(ByVal sender As ObjectByVal e As Telerik.Web.UI.DockLayoutEventArgs) Handles RadDockLayout1.SaveDockLayout  
            'Save the dock state in the session. This will enable us  
            ' to recreate the dock in the next Page_Init.  
            Me.CurrentDockStates = RadDockLayout1.GetRegisteredDocksState()  
        End Sub 
     
        Protected Sub ButtonAddDock_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles ButtonAddDock.Click  
            Dim dock As RadDock = Me.CreateRadDock  
     
            'In order to optimize the execution speed we are adding the dock to a  
            ' hidden update panel and then register a script which will move it  
            ' to RadDockZone1 after the AJAX request completes. If you want to  
            ' dock the control in other zone, modify the script according your needs.  
            UpdatePanel1.ContentTemplateContainer.Controls.Add(Dock)  
     
            ScriptManager.RegisterStartupScript(Me.UpdatePanel1, dock.GetType"DockIntoZone", _  
                        Me.getStartupScript(dock.ClientID, Me.DropDownZone.SelectedValue), True)  
                  
            'Right now the RadDock control is not docked. When we try to save its state  
            ' later, the DockZoneID will be empty. To workaround this problem we will  
            ' set the AutoPostBack property of the RadDock control to true and will  
            ' attach an AsyncPostBackTrigger for the DockPositionChanged client-side  
            ' event. This will initiate second AJAX request in order to save the state  
            ' AFTER the dock was docked in RadDockZone1.  
            CreateSaveStateTriggers(Dock)  
     
            'Load the selected widget in the RadDock control  
            Dock.Tag = DroptDownWidget.SelectedValue  
            LoadWidget(Dock)  
        End Sub 
     
        Private Function getStartupScript(ByVal clientId As StringByVal drowpDownZone As StringAs String 
            Dim sb As New StringBuilder  
            sb.AppendLine("Sys.Application.add_load(function () {{")  
            sb.AppendFormat("   if (typeof(Telerik.Dock{0}) === 'undefined')", clientId).AppendLine()  
            sb.AppendLine("   {{")  
            sb.AppendFormat("      $find('{1}').dock($find('{0}'));", clientId, drowpDownZone).AppendLine()  
            sb.AppendFormat("      Telerik.Dock{0}Moved = true;").AppendLine()  
            sb.AppendLine("   }}")  
            Return sb.ToString  
        End Function 
     
        Protected Sub Page_Init(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Init  
            ' Recreate the docks in order to ensure their proper operation  
            For i As Integer = 0 To Me.CurrentDockStates.Count - 1  
                Dim dock As RadDock = Me.CreateRadDockFromState(Me.CurrentDockStates(i), i)  
                'We will just add the RadDock control to the RadDockLayout.  
                ' You could use any other control for that purpose, just ensure  
                ' that it is inside the RadDockLayout control.  
                ' The RadDockLayout control will automatically move the RadDock  
                ' controls to their corresponding zone in the LoadDockLayout  
                ' event (see below).  
                RadDockLayout1.Controls.Add(dock)  
                'We want to save the dock state every time a dock is moved.  
                CreateSaveStateTriggers(dock)  
                'Load the selected widget  
                LoadWidget(dock)  
            Next 
        End Sub 
    End Class 
     

    Thanks,

    Mike Joseph
    Interapp Development, Inc.
  9. Aron Calder
    Aron Calder avatar
    13 posts
    Member since:
    Jan 2006

    Posted 23 May 2007 Link to this post

    Hi Telerik,

    With this example, how can I clear the dockstate of docks that have been closed?

    Over time as a user adds and removes docks the state will fill up with docks that have their closed property=true.

    I tried to remove closed docks from the state collection (CurrentDockStates) in the SaveLayout and in the the LoadLayout, I even tried to do it during the CreateRadDockFromState. Although it is possible to remove the dock, it messes up the page calls and the page will no longer work and you can't add anymore docks again.

    Do you have any suggestions on how best to "tidy up" closed docks?

    Many thanks

    Aron

     

  10. Tim
    Tim avatar
    3 posts
    Member since:
    May 2007

    Posted 23 May 2007 Link to this post

    Thanks for the example but what it is missing is how to save the preferences for each control. I.e. if the custom control is an RSS reader how do i pass in the feed i want it to read or the id so the control can look up the preferences in the database?

    Thanks.

    Tim
  11. Aron Calder
    Aron Calder avatar
    13 posts
    Member since:
    Jan 2006

    Posted 23 May 2007 Link to this post

    Tim,

    I tackled this by creating a new "WidgetInstance" class for all my state storage. It held the state of the RadDock and the state of the usercontrol.

    This is pulled from the db as a collection of WidgetInstances and each one is then added to the dock layout during the CreateRadDockFromState method.

    When the usercontrol is loaded I just pass it's state stored in the WidgetInstance class and it recreates itself with all it's preferences.

    Hope this helps.

    Cheers

    Aron

  12. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 24 May 2007 Link to this post

    Hi Aron,

    The latest update of RadDock, version 2007.1.521.0, has certain modifications, affecting the Closed state of the RadDock controls. The first is that each RadDock control has Closed property, which is now persisted in the DockState objects and if you want to exclude the closed docks' state from saving, you could just remove it from the state list. On the other hand, RadDockLayout's method GetRegisteredDocksState() now has a new overload, which allows passing a boolean parameter, indicating which DockState objects to be included in the resulting list: when the parameter value is true, the closed states are not included, otherwise, they are included.

    Sincerely yours,
    Valeri Hristov (Senior Developer, MCSD)
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  13. Tim
    Tim avatar
    3 posts
    Member since:
    May 2007

    Posted 24 May 2007 Link to this post

    Thanks Aron. I think I get the idea but some example code would be great if you have some.

    Thanks again.

    Tim
  14. Aron Calder
    Aron Calder avatar
    13 posts
    Member since:
    Jan 2006

    Posted 24 May 2007 Link to this post

    Hi Valeri,

    That's what I have been trying, but it causes a javascript error on the page followed by an "Invalid JSON Primitive." error.

    Try changing the code in the example attached in this thread like this: Using the overload to exclude closed docks.

        protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)  
        {  
            //Save the dock state in the session. This will enable us  
            // to recreate the dock in the next Page_Init.  
            CurrentDockStates = RadDockLayout1.GetRegisteredDocksState(true);  
        } 

    Add some docks, then close one of the docs, then try and add another dock and you'll get the javascript error. Then click the "add" button again and you'll get the JSON error.

    Looks like the problem is caused by the dock having the same name, but I'm not sure why the page will still have that reference if it has been removed?

    Cheers

    Aron
  15. Jon Hobbs
    Jon Hobbs avatar
    48 posts
    Member since:
    May 2007

    Posted 24 May 2007 Link to this post

    Thanks for the example project Petya,

    Unfortunately I'm still a bit of a VB.net novice so I'm having trouble working out how it all works. When I put the project in a folder and try to run the myportal page i get the following error

    "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS."


    Anyway, I think i'm going to have to go back to basics and try to work out how to save the state of each dock in a database for each person. I assume i'll have to programatically add the docks to the page once I've worked out who's logged in and what layout they have ?

    I think it's great that Telerik provides example projects like this to forum users, very helpful and beyond most people expectations I'm sure. However, for idiots like me it would really help to have some kind of articles written on how to achieve common tasks like this and an explanation of how it all works. Is there any chance of anything being added to the knowledge base in the future about how to set up a portal site with a "save layout " and "add widgets" button, preferably saving customers settings to a SQL databse ?
  16. tbutcher
    tbutcher avatar
    4 posts
    Member since:
    Apr 2007

    Posted 24 May 2007 Link to this post

    I couldn't agree more the examples are excellent and make our life a whole lot easier. However I would really appreicate a little extension to this example to so how to set preferences of a custom user control such as an RSS reader because I am bit lost at the moment.

    Thanks again.

    Tim
  17. mikejoseph
    mikejoseph avatar
    16 posts
    Member since:
    Jan 2007

    Posted 24 May 2007 Link to this post

    Jon, I was getting that MachineToApplication Error too, but it was because I opened the wrong folder.  You have to open the websute WebPortal folder instead, which contains the Web.config for the app.
  18. mikejoseph
    mikejoseph avatar
    16 posts
    Member since:
    Jan 2007

    Posted 24 May 2007 Link to this post

    Hi again all,

    Did anyone actually get this sample working?  Unfortunately, I just assumed the sample would work when I went ahead and did my VB.NET translation.  I ran my project, which implements the conventions put forth in the example, but when I tried adding instances of particular modules to my portal page, the "Add Dock" button didn't work at all.  In an attempt to debug my problem, I went back to the original c# sample that I downloaded from this forum thread.

    When I ran the sample project, I was able to login as me/me ...  Upon logging in, I saw the RadDock instances in place like I would expect.  I closed all the radDock instances and tried selecting a module and adding that module to either RadDockZone.  However, unfortunately, the dock instances weren't being added back into the RadDockZones.

    Any ideas?  Thanks in advance.

    Mike Joseph
  19. Aron Calder
    Aron Calder avatar
    13 posts
    Member since:
    Jan 2006

    Posted 24 May 2007 Link to this post

    Hi All,

    I have the examples working fine, in VB.NET, other than the issue of closing a dock and physically removing it from the state management.

    I have successfully implemented the state management of the user controls as well, so that an entire "widget" instance (raddock + usercontrol) can be re-created for each user and on each page (tab).

    I still have a few issues to work through at the moment, but have got a RSS Widget working, very similar to the those on www.netvibes.com and www.pageflakes.com.

    Unfortunately the code isn't in a suitable format to make available at present.

    For those that want to know how to implement this kind of functionality have a read of this excellent article http://www.codeproject.com/Ajax/MakingGoogleIG.asp where all of the above are discussed and solutions provided. Just adapt for your own needs.

    Cheers

    Aron

  20. mikejoseph
    mikejoseph avatar
    16 posts
    Member since:
    Jan 2007

    Posted 24 May 2007 Link to this post

    Haha... that's funny Aron... I'm doing the EXACT same thing.  I created a Media RSS Reader in combination w/ many other widgets to mimick the functionality in netvibes as well.

    Any possibility you could cut and paste code snippets and replace sensitive info w/ psuedo comments? :)

    MJ
  21. mikejoseph
    mikejoseph avatar
    16 posts
    Member since:
    Jan 2007

    Posted 24 May 2007 Link to this post

    I also have a support request in... if I hear anything back positive, I'll post the results.  Thanks!        
  22. Jon Hobbs
    Jon Hobbs avatar
    48 posts
    Member since:
    May 2007

    Posted 29 May 2007 Link to this post

    Mave you heard anything back yet mike ?

    I still have no idea where to start with this.
  23. mikejoseph
    mikejoseph avatar
    16 posts
    Member since:
    Jan 2007

    Posted 29 May 2007 Link to this post

    Hi Jon -

    Yes, I have heard back from them.  They are in the midst of a holiday in their part of the world, so I guess they are catching up, but below is the reply I received from them.  These guys are awesome. :)  If they don't post the code sample they send before I do, I'll make sure it gets up here.

    Best,
    Mike Joseph

    -------------------------------------------------


    Hi Michael,

    I checked that forum thread, but it became quite long and now contains many problems of many different people. IMHO it is becoming complete mess, so I will try to create a new example in both C# and VB.NET, which demonstrates our "best practice" suggestion for implementing portal applications, including widget configuration, etc. I am not sure how much time it will take, but most probably I will be able to post it before wednesday. Let me know if you have specific requirements, which should be taken into account in the sample.

    Best wishes,
    Valeri Hristov (Senior Developer, MCSD)
    the Telerik team
  24. Petya
    Admin
    Petya avatar
    869 posts

    Posted 30 May 2007 Link to this post

    Hi,

    As I already wrote Michael, currently our team is quite understaffed and our work is seriously overwhelmed. Therefore, even though the example we work on is not complete, we decided to send it to you at the stage that it is now - state is preserved in database. What we have left is some work with configuring the widgets. While we continue our work, any feedback is appreciated. Please, find attached the current stage of the example.


    Best wishes,
    Petya
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  25. Jon Hobbs
    Jon Hobbs avatar
    48 posts
    Member since:
    May 2007

    Posted 30 May 2007 Link to this post

    Hi Petya,

    I just downlaoded that zip file and viewed default.aspx and got the following error..

    Compiler Error Message: CS0117: 'Telerik.Web.UI.DockState' does not contain a definition for 'Closed'

    Line 122:               return pageWidgetInfo.ID == stateWidgetID; 
    Line 123:           }); 
    Line 124:           if (pageWidget != null && !state.Closed) 
    Line 125:           { 
    Line 126:               pageWidget.State = state.ToString(); 

  26. Ubong
    Admin
    Ubong avatar
    328 posts

    Posted 01 Jun 2007 Link to this post


    Hello Jon,

    Could you try again with the last version of the Telerik.Web.UI dll again? I just ran this and did not have the errors you mention.

    Best regards,
    Ubong
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  27. tbutcher
    tbutcher avatar
    4 posts
    Member since:
    Apr 2007

    Posted 01 Jun 2007 Link to this post

    I don't get the above error but I do get:

    Object reference not set to an instance of an object.

    dock.ApplyState(DockState.Deserialize(pageWidgetInfo.State));

    Tim
  28. mikejoseph
    mikejoseph avatar
    16 posts
    Member since:
    Jan 2007

    Posted 01 Jun 2007 Link to this post

    I got the same thing.  I had to put an if statement around the trouble lines to check if null...  now I'm no c# guy, but I had to actually put in opposite of what I thought for it to actually work. 

    Here's what I tried first:
    if (pageWidgetInfo.State != null) {
      dock.ApplyState(DockState.Deserialize(pageWidgetInfo.State));
    }

    You'll have to do this somewhere else in the code as well.

    But here's what I had to type to get it to work oddly enough (I even stepped into the debugger and got odd results:
    if (pageWidgetInfo.State == null) {
      dock.ApplyState(DockState.Deserialize(pageWidgetInfo.State));
    }

    As Petya commented, the code sample isn't really ready for prime-time, but has some basic amount of function to at least 'get the idea'...  I'm working on my VB.NET translation (among other tasks) today...  I think when this code sample is tightened up and out of 'alpha' release, that it should go into the code samples.  I can't think of any portal application where saved wouldn't be saved to some sort of server-based database.

    Hope this helps,

    Mike
  29. tbutcher
    tbutcher avatar
    4 posts
    Member since:
    Apr 2007

    Posted 05 Jun 2007 Link to this post

    Has anybody managed to convert this code to vb.net yet? I am getting stuck on PageWidgetInfo pageWidget = PageWidgets.Find(delegate(PageWidgetInfo pageWidgetInfo), in the DockLayout_SaveDockLayout sub on the default page. What is it in vb.net?

    Thanks.

    Tim
  30. Theodore Kasten
    Theodore Kasten avatar
    1 posts
    Member since:
    May 2007

    Posted 05 Jun 2007 Link to this post

    Thanks for the sample but as others have noted, it doesn't quite work yet.  As you can see, there are a lot of people that are anxiously awaiting this type of functionality.   A full functional demo would be highly highly appreciated.

    Thanks a lot.
  31. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 06 Jun 2007 Link to this post

    Hello everybody,

    I created a new a new sticky thread and attached a VB.NET and a C# versions of the latest version of the sample. Please, check it out and send us your comments.
    http://www.telerik.com/community/forums/thread/b311D-mkttd.aspx

    Sincerely yours,
    Valeri Hristov (Senior Developer, MCSD)
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017