It is a good practice implements two or more views in the same page???

Topics: Web Client Software Factory, User Forum
Jun 1, 2007 at 10:31 AM
Edited Jun 1, 2007 at 10:36 AM
Hi!!!

I have one aspx page and I need implement two or more views in this page because I have many dropdownlist that I need to fill with information of the modules (Products, Coins, Customers) but I don't know if this option is a best practice or exists others ways to solve this design problem. For example:


using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using CLH.Facturacion.LineasDetalle.Views;
using CLH.Facturacion.LineasDetalle;
using CLH.Facturacion.Productos.Views;

using Microsoft.Practices.ObjectBuilder;


public partial class LineasDetalle_Default : System.Web.UI.Page, IDefaultView, IGetProductsView
{
private DefaultViewPresenter _presenter;
private GetProductsViewPresenter _presenterProducts;

#region Page Events

protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this._presenter.OnViewInitialized();
}
this._presenter.OnViewLoaded();
}

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}

#endregion

#region WCSF

CreateNew
public DefaultViewPresenter Presenter
{
set
{
this._presenter = value;
this._presenter.View = this;
}
}

CreateNew
public GetProductsViewPresenter PresenterProducts
{
set
{
this._presenterProducts = value;
this._presenterProducts.View = this;
}
}

#endregion

#region IDefaultView Members

public LineaDetalle LineaDetalle
{
set { ObjectContainerDataSourceDetail.DataSource = value; }
}

public IList<LineaDetalle> LineasDetalle
{
set { ObjectContainerDataSourceDetails.DataSource = value; }
}

#endregion

#region Miembros de IGetProductsView

public List<CLH.Facturacion.Productos.Producto> Productos
{
set
{
DropDownListProductos.DataSource = value;
DropDownListProductos.DataBind();
}
}

#endregion
}

I need help

Thnaks

Jun 1, 2007 at 1:11 PM
I find it untidy to have multiple views within a single web page, but do find it helps when using the SiteMap for menus and breadcrumbs.

It would be interesting to see what peoples opinions are on this for best practice.
Jun 1, 2007 at 2:30 PM
I have used multiple views on the same page for the exact same reason and it worked fine. Or you could put everything for that page in one BIG interface that encapsulates all the mini views...but that gets cumbersome...
Keep it seperate, since they are representing DISTINCT/seperate views to some data.

What you think?
Jun 4, 2007 at 8:16 AM
Edited Jun 4, 2007 at 8:36 AM

wanderer wrote:
I have used multiple views on the same page for the exact same reason and it worked fine. Or you could put everything for that page in one BIG interface that encapsulates all the mini views...but that gets cumbersome...
Keep it seperate, since they are representing DISTINCT/seperate views to some data.

What you think?


That does seem to me like the best method. I agree that different views/interfaces need to be kept seperate, but the page should implement the multiple interfaces.

For example, just say creating a user account was a two stage process. The first view would accept customer name, address etc, and the second view to select user preferences and confirm. In this case you would want "Create User" selected in the breadcrumb/menu for both views. So you could implement ICreateUserView and ICreateUserPreferencesView in a single page.
Jun 4, 2007 at 9:00 AM
Personally I would have user controls implementing each view, and then use the ASPX page as the controller which handles which view(s) to load/show etc.
Jun 4, 2007 at 9:21 AM
Edited Jun 4, 2007 at 9:25 AM

jonhilt wrote:
Personally I would have user controls implementing each view, and then use the ASPX page as the controller which handles which view(s) to load/show etc.


Yep, I 100% agree as this is exactly what I do. I don't know why I didn't say that earlier...

I create the controls to expose properties that allow the page to pump in data from the view/controller seeing as the user controls can not have object builder create the view for them. I believe there is an ammendment to WCSF to allow this functionality, so I guess I should really look into that...
Jun 4, 2007 at 12:48 PM
It depends on how complex your user controls get.. If they are complex and need to be reused and represent a functionality that encompasses more than just getting and setting data from the user then put the view in the user control.
If the user control is just a collection of labels and text boxes that you need to repeat a couple of times all over your page then it might be easier to put the view on the page.
Just depends on the complexity, either solution will work. So base your decision on how much redundant coding you have to do, code maintenance for you and the next coder who will take over your project, round trips...etc....(I;m sure there are others....)

Hope these replies help you.

Regards