Reuse of View in the WCSF

Topics: Web Client Software Factory, UIP Application Block discussion, User Forum
Mar 21, 2007 at 7:31 PM
Edited Mar 21, 2007 at 7:32 PM
In one major solution of ours we got like 5 views that looks exactly the same. At this time we dont use any Presenter, but uses resourcefiles to find out which procedures to use to retrieve or store to the database.

so we have a we that incorporate the following code to get the right text/procedure:

        Private ReadOnly Property PageResourceType() As String
            Get
                Dim result As String = String.Empty
 
                If Not String.IsNullOrEmpty(Request.Item("PageType")) Then
                    result = Request.Item("PageType")
                Else
                    result = String.Empty
                End If
 
                Return result
            End Get
        End Property
 
        Protected ReadOnly Property ResourceString(ByVal resource As String) As String
            Get
                Return DirectCast(HttpContext.GetGlobalResourceObject(PageResourceType, resource), String)
            End Get
        End Property

This lets us use Resourcefiles to give us the information to use the korrekt settings for a view.

Like this:

        Protected Sub DoSaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
            Dim db As Database = CDBHandler.GetDatabase()
            Dim cmd As DbCommand = db.GetStoredProcCommand(ResourceString("InsertUpdateProcedure"))
 
            Dim message As String = String.Empty
 
            Try
                message = GetChangeMessage()
 
                If Not String.IsNullOrEmpty(message) Then
                    db.AddInParameter(cmd, "name", DbType.Int32, TFDBLib.GODBValue(NAME))
                    db.AddInParameter(cmd, "desc", DbType.Int32, TFDBLib.GODBValue(DESC))
                    db.AddInParameter(cmd, "target", DbType.Int32, TFDBLib.GODBValue(TARGET))
                    db.AddInParameter(cmd, "url", DbType.Int32, TFDBLib.GODBValue(URL))
                    db.AddInParameter(cmd, "param", DbType.Int32, TFDBLib.GODBValue(PARAM))
 
                    db.AddParameter(cmd, "id", DbType.Int32, ParameterDirection.InputOutput, String.Empty, DataRowVersion.Default, TFDBLib.GODBValue(ItemID()))
 
                    db.ExecuteNonQuery(cmd)
 
                    Log(ResourceString("LogTable"), db.GetParameterValue(cmd, "id").ToString(), "", message)
                End If
                Panel0.Visible = True
                FillGrid()
                ModalPopupExtender1.Hide()
            Catch ex As Exception
                L_ERRMessage.Text = GetWindowError(Resources.Constants.SaveErrorTitle, ex.Message, ex, cmd.CommandText)
            End Try
        End Sub

This is a poor example but i hope u get the drift of wait we are trying to get done her.

My question is a follows:

Is their a good way to incorperate this with use of MVP in the WCSF?

Objectbuilder should give us the tool to get this done.

Do we need to make a factory that gives ut the presenter we need?

Or should the Presenter ask the view what responsibilities it has and then create the controller needed for the task?

Any ideas to make this work and the best solution to incorperate for this task?

Benny