Use MVP Pattern And Add A Presenter Layer In Web App?
May 12, 2010
I would like to use MVP pattern and add a presenter layer in my web app. EX;- for filling the data in page I am doing like this.
[Code]....
If I add a presenter class, Do I need to move this code in presenter layer?
View 2 Replies
Similar Messages:
Apr 5, 2010
I have a ASP.NET Web Forms application and I'm using some dynamic controls in the view which depend on stuff that the presenter exposes. Is it okay for the view in this case to pull on the presenter for that data? Is there anything I should be extra careful about when considering testability and a loosely coupled design.
The page in this case has it's own page-life cycle and the presenter doesn't know about this. However, the page-life cycle dictates that somethings must occur at specific moments in the page-life cycle. This smells like trouble... Any known pit falls?
EDIT
When my concrete view hits the Init event it will pull on the presenter for a collection that will result in a bunch of ASP.NET server controls to be created. I'm wondering if this is a particular bad thing to do... The presenter doesn't know how to respond to the page-life cycle init event but it has to if the view is to be populated with dynamic controls.
View 2 Replies
Apr 1, 2010
how the data pass from one layer to another layer in mvc design pattern...
View 2 Replies
Aug 16, 2010
I am using mvp pattern in small project. I have problems with view which contains html table with data(always 9 rows). How can i easily get data from html table and send it to the presenter? On the model side i want to keep data from html table as a generic List<some_type>
View 1 Replies
Jan 27, 2010
I recently read Phil Haack's post where he gives an example of implementing Model View Presenter for ASP.NET. One of the code snippets shows how the code for the view class.
public partial class _Default : System.Web.UI.Page, IPostEditView
{
PostEditController controller;
public _Default()
{
this.controller = new PostEditController(this, new BlogDataService());
}
}
However, here the view constructs the instance of the BlogDataService and passes it along to the presenter. Ideally the view should not know about BlogDataService or any of the presenter's lower layer dependencies. But i also prefer to keep the BlogDataService as a constructor injected dependency of the presenter as it makes the dependencies of the presenter explicit.
This same question has been asked on stackoverflow here.
One of the answers suggests using a service locator to get the instance of the BlogDataService and passing it along to the presenter's constructor.This solution however does not solve the problem of the view knowing about the BlogDataService and needing to explicitly get a reference to it.
Is there a way to automatically construct the presenter object using an IoC or DI container tool such that the view does not have to deal with explicitly creating the BlogDataService object and also injecting the view and service instances into the presenter's constructor. I prefer to use the constructor injection pattern as far as possible.
Or is there a better design available to solve the problem?. Can there be a better way to implement this If i am building a WinForms application instead of a ASP.NET WebForms application?
View 2 Replies
Mar 27, 2011
I'm reading through Architecting Microsoft .Net Solutions for the Enterprise and I try to figure a couple of things out concerning the Presenter and the Service Layer.
First off, my Presenter needs to call methods that reside in the Service Layer, like initialize(), save() etc. But where do I place a reference to the service layer? Should it be at class level in the Presenter, or should I define a new service in the presenter methods itself?
Second - this isn't really clear in the book either - is this how the processing from the Presenter to the Service Layer works?:
[code]....
View 1 Replies
Oct 13, 2010
We have an ASP.NET MVC site that uses Entity Framework abstractions with Repository and UnitOfWork patterns. What I'm wondering is how others have implemented navigation of complex object graphs with these patterns. Let me give an example from one of our controllers:
[code]....
It's a registration process and pretty much everything hangs off the POCO class Person. In this case we're caching the person through the registration process. I've now started implementing the latter part of the registration process which requires access to data deeper in the object graph. Specifically DPA data which hangs off Legal inside Country.
The code above is just mapping out the model information into a simpler format for the ViewModel. My question is do you consider this fairly deep navigation of the graph good practice or would you abstract out the retrieval of the objects further down the graph into repositories?
View 2 Replies
Feb 23, 2010
Does anyone have a working pattern for converting a GET-POST-GET pattern to asny?
I'm encountering the following issues:
1. You cannot mix Sync and Async action methods SubmitForm(), SubmitFormAsync(bool? confirm), SubmitFormCompleted() ... (because the resolver gets all confused ... it doesn't use the HTTP verb to decide who to target. BTW: I think that's poor design, or a bug)
2. Renaming the get method name to something else eg: SubmitFormConfirmation(), SubmitFormAsync(bool? confirm), SubmitFormCompleted() would be very awkward if it works ... because you have to doctor the <form markup to specify an action name.
3. You cannot give them all async names SubmitFormAsync(), SubmitFormAsync(bool? confirm), submitFormCompleted(), because the call just keeps malfunctioning. It sometime even behaves as if you are requesting a delete of something.
Can someone give an insight from an actually working sample.
View 5 Replies
Aug 21, 2010
Now that the next version of ASP.NET MVC is being prototyped and previewed (ASP.NET MVC 3 Preview 1 came out a couple of weeks ago), I wonder if we should call the attention of the Core Dev team (S Hanselman, Phil Haack and all) to this "feature."there a easy/non tacky way of associating subdomains → areas?Something like:
[URL]Also, whats the best accepted design pattern in implementing PRG pattern in ASP.NET MVC? I guess it should also get some official loving in MVC 3.
View 2 Replies
Oct 26, 2010
I am new to this .NET what is the difference between N-Tier and 3- Tier Architecture. If they are same. How to pass the values from presentation layer to business logic layer.
For Example
I have 10 controls in presentation layer. I passing values to these controls. How the architecture works.
View 3 Replies
Jun 24, 2010
I am building a web site following the tutorials on asp.net. I am using dataset as data access lay, and writing classes to access the dataset. But the example is just basic ideas, how do I retrieve individual table column value in the business layer?For example, if I have a table called Product, I only want to find out what is the product name by product id. I did this in my ProductBLL:
public ProductBLL
{
public int GetProductName(string productId)
{
ProductDataSet.ProductDataTable prodData = Adapter.GetProductById(productId);
[code]...
Is there a better way, or am I doing this correctly? Can anybody give me a reference to a more complicated business logic model?
View 16 Replies
Feb 23, 2011
I've even got my JQuery Ajax submission going on now but I've encountered another problem. I *think* it's something to do with the structure I'm using but like I say, I'm fairly newo this.I have my AJAX form submission which builds my "PersonViewModel" (model for the presentation layer) in JSON and sends it to "@Url.Action("RegisterSubmit")" in my Person Controller. Now, I seperate my business layer from my View/presentation layer so in "RegisterSubmit"I'm verifying the model is valid then instantiating a new instance of my business model "Person", adding the values from "PersonViewModel" and then calling my "Save" function.
View 7 Replies
Mar 7, 2011
We're building a large web app that has numerous layers. In order to communicate to the business layer we're using a service layer that the web layer calls when data is needed. Unfortunately, it seems that if exceptions are thrown in the business layer, it seems that the services on the web side are wrapping the exceptions and re-throwing them. We're looking for a clear way to encapsulate the error and log it, without WCF wrapping a new exception around the original.
View 2 Replies
May 6, 2010
My repositories throw exceptions (System.Exception) when some things go bad and I know this is bad practice.. so i will create a custom exception (DataException). My question is should this custom ex class be in the repository layer or the domain layer? Im thinking it should be in Domain layer where all business objects and repository interfaces live but just want to make sure.
View 3 Replies
Jan 26, 2011
I'm trying to reevaluate our n-layer architecture and would love to get some based on your experiences. Here is our typical .NET n-layer (sometimes n-tier) design.
Project.UI
Project.Services
Project.Business
Project.Model
Project.DataAccess
DataAccess typically consists of Entity Framework 4 and Repository classes. I attempt to follow the Aggregate Root concept in order to avoid having a repository for table, easier said than done in my experience. I tend to have ~70% match between Repositories and Tables.
Model usually consists of my Entity Framework 4 entities, I've been using Self-Tracking EF entities with success.
Business is what I struggle with the most. I typically have a Manager class for every Repository. This class will contain methods like .Add() which will perform business validation before forwarding down to repository.Add().
Services, typically I will only implement this if in fact I am looking to create a web service based solution. This layer will be tasked with marshaling requests/responses between DTOs and entities. And most importantly provide the more coarse grained interface. For example a TradingService.SubmitTrade(), which is really a facade for a business transaction which might include AccountManager.ValidateCash(), OrderManager.SubmitOrder(), etc.
My business layer is very entity centric, really it's just the glue between the entities and the repository, with validation in between. I've seen many designs where the Service Layer is what holds a reference to the repositories (in essence skipping the "business layer"). In essence it serves the same purpose as my Business layer, it does the validation, however its' responsibility (and naming) is a higher level, more coarse grained business transaction. Using the example above the TradingService.submitTrade() will not delegate to any business manager classes, it would itself query the necessary repositories, perform all the validation etc.
I like my design in a sense that I can reuse a business layer method in multiple service calls, however I hate the fact that for every repository I have a matching business layer manager, creating tons of extra work. Maybe the solution is a different type of grouping at the Business Layer level? For example combine individual Manager classes like PhoneManager and EmailManager (note I have Phone entities and Email entities) into a logical Manager class such as ContactsManager (note I don't have a "Contact" entity type). With methods such as ContactManager.GetPhones() and ContactManager.GetEmail(), etc.
View 1 Replies
Jun 3, 2010
here i have in 3-tier architecture , how to pass the data between DAL and BAL. i am using grid view to edit the data,when ever i click on the edit button all the corresponding fields should come to textboxes. i tried for delete ,it works fine bt not working to EDIT.
View 7 Replies
Apr 4, 2011
I'm new to using the MVP pattern and I just want to make sure on the best way to call a presenter from within a user control.
MyPage.aspx has a presenter MyPresenter
The page contains a user control which accepts MyPage's Presenter via a property which I setup from MyPage
MyUserControl.Presenter = this.Presenter
I'm now trying to call Method1 within the presenter which retrieves some config and sets it on the view from the user control.
Presenter.Method1(); // calls method and sets config to the view
My question is firstly
should I be using the presenter in the user control in this way?
If so, is it valid to be accessing the view value via the user control as shown below.
Presenter.View.MyData
I just want to make sure I'm not going off down the completely wrong path with this!
View 1 Replies
Jun 11, 2010
What is the best way to get a number of property values of a business object from the View to the Presenter in a WebFormsMvp page?
Bearing in mind this issue with DataSources: [URL]
Here is what i propose:
The scenario is, I have a business object called Quote which i would like to load form the database, edit and then save. The Quote class has heaps of properties on it. The form is concerned with about 20 of these properties. I have existing methods to load/save a Quote object to/from the database. I now need to wire this all together.
So, in the View_Load handler on my presenter i intend to do something like this:
[code]....
View 1 Replies
Jan 26, 2010
In Model-View-Presenter what is the correct pattern to do a page that:
a) contains a grid for browsing a list of items
b) an alternate mode for editing single items .maybe you are toggling between two asp:panels.
Do you just make the presenter smart enough to do two types of presentations?
Make 2 presenters?
I'm new to this pattern and want to do it correctly. I understand how I would do this functionality on two pages. Just not sure what is the accepted practice when the browse and detail exist on the same page.
View 1 Replies
Jul 23, 2010
I'm using Model-View-Presenter framework. When Loading a page, I'm having trouble setting the selected item that came from the Database.
In view, I know I need:
protected void ddlStatus_SelectedIndexChanged(object sender, EventArgs e)
{
presenter.DdlStatusSelectedIndexChanged();
// what should this pass?
}
Then in Presenter:
public void DdlStatusSelectedIndexChanged()
{
view.DdlStatus = ???
// Should I pass the SelectedIndex?
}
I also think that part of my problem is that DdlStatus I have as a List.
Interface:
List<StatusDTO> DdlStatus { set; get; }
The best I found is here (but needs formatted!) ---> [URL]
View 2 Replies
Jan 26, 2011
Just wondering, in an ASP.NET MVC3 environnement with entity framework. Should the Unit of Work point to the service layer or the repository (and then the repository point to the service layer) ?
Ive saw two example:
* One where the unit of work and repository both have an instance to the service layer..
Link: Entity Framework 4 CTP 4 / CTP 5 Generic Repository Pattern and Unit Testable
Doesn't use a service layer but its obvious that one could be use in that case.
* Second where the unit of work have an instance to the repository which have an instance to the service layer..
[URL]
What would be better ?
View 11 Replies
Jun 2, 2010
I have been reading about different model for development
model view control mvc
model view presenter MVP
Model view view model MVVM
i belive MVC has two big Advantage over webform 1) TDD 2) More control on HTML
MVP is bit variation in mvc model. rapid development as well as 1) TDD 2) More control on HTML (correct me if i m wrong) see the below link
[URL]
View 7 Replies
Sep 17, 2010
I wanted to know which all design pattern have you used in your application. Just wanted to see a general idea of most commonly used, popular design patterns. I was going through this site"
http://www.dofactory.com/Patterns/Patterns.aspx
and it has tons of design patters, I have heard about singleton and factory but not others.
So guyz which all popular efficient patterns are there and how would you determine which one suits your app. Can we make a app without a design pattern.
And lastly which one are the most simplest ones out there which are easier to implement.
View 2 Replies
Aug 4, 2010
I have a class which fetches the data from the database. Say First name, Last name , Telephone number etc and display it in my .aspx page. This data is common to all the users. So i would like to use Singleton pattern so that the object is not created again ,just use the created object for all the users. Can any one help me with the simple code snippet example.
View 3 Replies
Jan 12, 2010
I am new to IOC design. My company application has this following code:
My Question in regards to the below code:
1. I did not see .TheDefaultIsConcreteType.How does the below code knows which is the default type.
2. Also if someone can explain me what is that scan method in the below code doing?
[Code]....
View 1 Replies