MVC Variations Confusing Me

I've read this in one article:
# a model consisting of the application with no external interface;
# a view consisting of one or more graphical frames that interact with the user and the application; and
# a controller consisting of the ``main'' program that constructs the model and the view and links them together.Additionally,
When a program with a graphical interface starts, the controller
   1. creates the model (application),
   2. creates the view consisting of one or more graphical frames and attaches commands to the graphical input controls (buttons, text boxes, etc.) of the view,
   3. activates the graphical components in the view, and
   4. terminates.Here's what I understand: anything that can be seen or has a graphical component is automatically a view. This includes Swing, AWT, even a JFrame with all the buttons and stuff in it. I've also read somewhere that Views can opt to register to a Model to automatically update itself when the Model changes, but that the Controller would handle the registration process. Models only store state, or data. They DO NOT have to do any special formatting or know how to present themselves. They don't know about any Views. Controllers contain the application-specific logic. They just tie the two together then terminate. They don't have a user interface. Hence, the following code...
class Model
     // misc. code.
     private String name;
     public void setName(String name)
          this.name = name;
     public String getName()
          return name;
class Controller
     // misc. code.
     private Model model;
     private View view;
     public Controller()
          model = new Model();
          model.setName("I am Sam");
          view = new View();
          view.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          view.addOkButtonListener(new ActionListener()
               public void actionPerformed(ActionEvent e)
                    view.setNameTextFieldText(model.getName());
     public static void main(String[] args)
          new Controller();
class View extends JFrame
     // misc. code.
     private JButton okButton;
     private JTextField nameTextField;
     public void addOkButtonListener(ActionListener l)
          okButton.addActionListener(l);
     public void removeOkButtonListener(ActionListener l)
          okButton.removeActionListener(l);
     public void setNameTextFieldText(String text)
          nameTextField.setText(text);
}is an example of MVC, or at least that is my understanding of it. I was just beginning to appreciate the above pattern when all of a sudden, I encounter this(http://www.cs.tufts.edu/~jacob/106/lecture/25_MVC.html), again putting me in a state of confusion.
If I stick to the definition of a controller given earlier in this post, I would say that the second example's controller is...."wrong". The Controller class has a view of its own. Additionally, the Controller uses a common callback for handling button events. I've read in the same article that this is bad design. The author presents some reasons, but in short, a common callback could turn into one long MONSTER IF statement mayhem.
Since the focus of MVC is on improved object reuse, model and view objects should be loosely coupled. Controller objects get reused the least. In the second example, all Views have a Model object inside of them, lessening their reusability. If in the first example, the Controller object acts as the glue that magically binds the model and view objects together, in the second example, glue is all over the place.
In the first example, if one removes the Controller class, the Model and View objects remain intact. If the Model is removed, the Controller is surely affected but the View still remains intact. We can even change the Model's API, and all that would need to be changed is the Controller.
In the second example, if one removes the Model object, the Controller and View objects are compromised. If we completely change the Model's API, the Controller and View objects would need to be changed too.
The second example has gotten me so confused I feel I need to ask these questions:
1.) Why does the second example maintain a tight coupling between the Model and the View?
2.) Why does the Controller have it's own View?
3.) Does the second example have any strengths over the first example? Or does the first example have any weaknesses too? In short, what can the first example do that the other can't and vice versa?
3.) In what types of problems is one more suitable than the other?
4.) Which is better in the long run or in larger projects (in terms of modularity, ease of coding, maintainability, etc.)?
I really need to clear this up. :)

MVC is a great design goal, but more often than not, you end up with model-delegate. The delegate contains controller and view, more tightly coupled than one would like in full-blown MVC.
You should avoid coupling the model and view in any way. If you have to, write the controller closely coupled to the view, and then have the controller invoke model classes. That way, you can at least keep your domain model classes if you ever switch views or add a view.
Conceptually:
View - Displays the model to the user
Model - Application data and business objects
Controller - Parses user requests and mediates between view and model
You can also check out the following URL that may explain the concepts differently (and better) than I could:
http://java.sun.com/blueprints/patterns/MVC-detailed.html
It's very difficult to totally separate the view and controller. The closest I've ever come is to implement the Command pattern and then use dynamic method invocation.
- Saish
"My karma ran over your dogma." - Anon

Similar Messages

  • MVC model confusion...

    I don't know if this is an mvc model:
    I have an HTML pages for viewing and input of data....
    a JSP file to get the request from the HTML page....
    and Java beans that has functions that is called by the JSP file...
    The beans also gets the data to the database......
    Im really confused on how I would make this an MVC model or is this already an MVC model?

    You are right...
    MVC(Model-View-Controller) is used to separate the presentation from the business logic.
    Your jsp page has nothing to do with business logic.
    Model includes Beans & EJBsThis is something you have to correct...
    view is your databaseview .. its nothing to do with database instead its the jsp's html's
    and controllers can be your servlets..

  • Confused about CLASSPATH and how java handles import statements...

    Hello,
    I must admit I don't get it. I read the articles about setting CLASSPATH etc. but I still wonder:
    If you use an import statement, what does the compiler do? I.e. where does it look for the specified classes? I find it confusing because I see in different locations different .jar files:
    C:\jdk1.3.1_03\lib\dt.jar
    C:\jdk1.3.1_03\lib\htmlconvertor.jar
    C:\jdk1.3.1_03\lib\tools.jar
    and also
    C:\jdk1.3.1_03\jre\lib\i18n.jar
    C:\jdk1.3.1_03\jre\lib\rt.jar
    C:\jdk1.3.1_03\jre\lib\jaws.jar
    C:\jdk1.3.1_03\jre\lib\sunrassign.jar
    Can someone explain me what the purpose is of these files?
    And why do I have the same contents in
    C:\Program Files\JavaSoft\JRE\1.3.1_03\lib
    and in
    C:\jdk1.3.1_03\jre\lib
    Why is that?
    Thanks for answering my questions!
    -mike

    Thanx for the answers, but I still wonder, everyone
    here says I need to set the classpath, but I don't.Probably because your classes are already in the class path. The compiler/jvm also look for classes by themselves not just in jar files, when just a directory is supplied in the class path. And a period (".") is a valid directory.
    Programs importing different classes compile with no
    problem. So what's up with that?
    Presumably you are referring to your own code - because they are in the class path.
    Second, I still don't understand why the runtime needs
    the .jar files. The runtime uses classes, like String, that have to come from somewhere.
    This would also mean that end-users
    need to set the classpath to the .jar files in their
    JRE directory to be able to run programs that import
    classes from these .jars. But this is not true, right?No it is true. The end-users will have to set the class path. There are variations on this which make it seem like no class path is set. For instance applets in a browser are java but the end-user does not need to set a class path. That is because the browser knows how to download classes/jars and how to set it up so it uses them. (Actually it uses a class loader, but that is probably more information that you need.)
    Because if I make some nice classes myself and import
    them, how can I expect my end-user to install these
    classes and make a classpath for them?That would be between you and you end-user.
    First installation is not part of java. For installation you will have to find something outside of java to accomplish the goal.
    Additionally how the class path gets set is OS specific. Java does not deal with that. You will also have to find some way to deal with this (most likely part of the installation.)
    There are also variations on this. For example the browser example I gave above. Or using the ext directory. Or creating an executable jar. Or simply setting the class path.
    In my understanding it should only be needed in the JDK, not
    in the JRE. True or am I mistaken?Mistaken. The class path is needed in the JRE as well. You will need to set it.

  • Database access in a MVC architecture

    Hi!
    I'm a bit confused with regards to where the database access code should be put in a MVC architecture. From reading various articles and posts on this forum, there seem to be a lot of different opinions.
    Some seem to put the database access code in the controller servlet(or JSP), while some seem to use helper classes from the JavaBeans, while a few people even seem to access the database directly from the JavaBean.
    My questions is: What is the best place to put the database stuff in a MVC architecture? An explanation as to why a particular solution is the best would be great..
    Thanks!
    regards,
    Vidar

    Let's say I have a class called Department that contains methods like getName(), getId(), setName(), etc... The Department class is my business object. To save and load Departments from a database, I have a class called DepartmentManager. The DepartmentManager saves and loads the departments to the database, and has methods like saveDepartment(), saveDepartments(), loadDepartment(), getDepartments(), etc... In some cases, my manager classes also caches the results so they don't have to load from the database each time. Often times, the manager class is a singleton. My Department class has no idea how it is persisted, or that it is part of a cache. It just knows about itself. The DepartmentManager is resonsible for managing all the persistance and lookup functionality for Departments.
    Therefore, if I have a JSP page that needs to display Departments, my code might look like:
    DepartmentManager dm = DepartmentManager.getManager();
    ArrayList listDepartments = dm.getDepartmentList();
    for (int i = 0; listDepartments != null && i < listDepartments.size(); i++) {
         Department dept = (Department)listDepartments.get(i);
         out.println("<option value=\"" + dept.getId() + "\">" + dept.getName());
    }If I had a specific Department I needed, I would get it as follows:
    DepartmentManager dm = DepartmentManager.getManager();
    Department dept = dm.getDepartment(nId);

  • Confused on creating a rectangle and validating its size & position afterwards

    If one creates a rectangle in a layer like this:
    var childLayer = parentLayer.pathItems.rectangle(top, left, someWidth, someHeight);
    childLayer.stroked = false;
    childLayer.filled = true;
    After creating the rectangle, would one read it back like this:
    var bounds = childLayer.geometricBounds;
    alert("bounds: "+bounds[0]+","+bounds[1]+","+bounds[2]+","+bounds[3]);
    or should I use visibleBounds, or controlBounds? Or something else?
    I know if stroke not used or can exclude can use geometric bounds? Or rather all 3 bounds could be the same in that case?
    I'm confused right now because I'm assuming the bounds represent the four corners of the rectangle's position in the document and when read back out, the values (bounds[0] and bounds[1]) don't match against the top & left values originally passed in to create the rectangle. Shouldn't they be the same?
    If not, how am I supposed to validate that the layer/object uses the same top & left values for it's position as when the rectangle was created (for say validation purposes)?
    Also I assume I should be able to fetch the position of one corner using childLayer.top & childLayer.left as well right? For some reason, that doesn't match with top & left either.

    Using your code snippet, I get same values. I'm using Adobe Illustrator CS6 (64-bit).
    But using a slightly different snippet, adapted from original script code I'm working with:
    var doc = app.activeDocument;
    var finishedWidth = 6.74 * 72;
    var finishedHeight = 4.84 * 72;
    var top = (362.88 - finishedHeight) / 2;
    var left = (502.56 - finishedWidth) / 2;
    alert("orig left: "+left+", top: "+top+", width: "+finishedWidth+", height: "+finishedHeight);
    var trimLayer = doc.pathItems.rectangle(top, left, finishedWidth, finishedHeight);
    alert("done left: "+trimLayer.left+", top: "+trimLayer.top);
    var bounds = trimLayer.geometricBounds;
    alert("bounds: "+bounds[0]+","+bounds[1]+","+bounds[2]+","+bounds[3]);
    the results are off regarding trimLayer.left & trimLayer.right compared to the original top & left values passed in. But the bounds values are correct. From your code snippet, I checked the rect.left and rect.top & it's still correct.
    Here's the output of the alerts (with some rounding of values as opposed to what was displayed):
    orig left: 8.64, top: 7.19, width: 485.28, height: 348.48
    done left: 8.14, top: 7.7
    bounds: 8.64,7.2,493.92,-341.28
    and debugging the original script code, the script I'm working with, (the rect.left, rect.top and) the bounds don't match up, with a difference from 0.14 to 0.42 to the actual value it's supposed to be. Extracting the area of code that I'm debugging out (for generalization and sharing code) results in the snippet above, and for some reason there, outside the context of the full script, the bounds are correct but not the rect.left & rect.top. Unfortunately, can't share the rest of the code at present.
    Guess I'll have to investigate further, with help from my team's developers. At the moment I'm perplexed by these variations. Logically, from reading the code & scripting reference, I would have expected the values to match up in all cases.

  • Tints vs. transparency; printing indesign file - so confused now

    Hello!
    I'm still learning indesign so i'm definitely not a pro. I've been working on an assignment which consists of creating compositions in indesign. The indesign file basically has text, lines and colored areas.
    I've just realized that I am only allowed to use a couple of colors and their tints. This whole time i've been using color and working with its transparency. Is that remotely the same thing? I am not sure how to get the exact same color i've produced when working with the transparency of a color as a tint. (I'm not suppose to be using transparency yet... XD) Please help.
    Also, once the above is figured out, what is the correct way to export this file as a pdf? Finally, I also need to export all 12 compositions as a 72dpi jpeg to upload online-- how do i do that? The file in indesign is a cmyk file and i'm pretty sure it exports as a cmyk pdf which is okay since i'm printing the pdf. The jpeg part really throws me off though.
    So far, this is what i'm 100% sure on:
    Indesign:
    File> Adobe PDF presets> High Quality Print> give the file a name and save
    then
    this is where i get confused - do I changed the standard options and compability options as well? what about the compression? i've basically printed so many variations of the project playing with the above (from what i've read) and have reached a point in which i'm no longer sure what the correct colors of my file are once exported as a pdf.
    Please help me. Thank you in advance!!!
    (forgot to mention i'm working with indesign CS5.5 and adobe acrobat pro x)

    Hello!
    Thank you for your kind and helpful replies. I was away celebrating Thanksgiving. Hope everyone had a good Thanksgiving, rest of the week!
    @ Peter
    Thank you for your explanation of what offset printing is. It really helped me visualize the process. Is this something used only when it comes to printing large quantities of work then? (I'm assuming large files as well)
    @ Dov
    Thanks for explaining your answer in simpler terms. I now understand what you meant. If i'm understanding things correctly, it's not good to use tints over other colors/objects yet it's alright to use them when they are on white backgrounds. Also, it's best not to use tints when it comes to overprinting; transparency is best.
    @ Will
    Thanks for your information! I'm a bit confused now to be honest; pdfx-4 is not recommended when overprinting with transparency?
    @ Dov
    If I'm understanding correctly, what you and Will are saying is that it's best not to import pdfs that are saved as pdfx-4? I really enjoyed reading all the extra info. It's all quite exciting! (trying to wrap my head around this)
    Thanks guys!!
    I decided to export the indesing file under Adobe Pdf Presets> High Quality Print. I didn't change any of the standard settings. With regards to the jpgs, I used the advice recommended - File > Export, choose JPEG, 72 ppi. I do have one large question though...
    This is what one of the compositions looks like in indesign:
    This is what it looks like when I view it under View> Proof Colors in Indesign:
    This is what it looks like when I export it as a Hight Quality Print pdf:
    This is what the jpeg image looks like when I export it under the following settings:
    And this is what the jpeg image looks like when I export it under these settings:
    Is it correct of me to use the exported jpegs with the simulate overprint option selected even though i'm only digital printing this pdf file? The color of the jpeg resenmbles the most of the pdf color. Thus... is it alright to do that?
    Thank you

  • MVC - Organizing models and managing GUI windows

    I'm having difficulty organizing my MVC models and basically controlling the whole application in general. My application works, but all the controlling logic is being dumped into the main class (Main.java). Here's a simple example of the problem I'm having:
    Objectives
    1) Display a list of Companies; i.e. Sun, Microsoft, Adobe, etc. (JFrame with a JList)
    2) The user select a Company and it pops up a new dialog with a list of Employees. (JDialog with a JList)
    Here are the classes I came up with:
    Models:
    1) CompanyListModel
    2) EmployeeListModel
    Listeners:
    1) CompanyListener
    Views:
    1) CompanyListFrame
    2) EmployeeListDialog
    Domain Objects:
    1) Company
    2) Employee
    And then there's the main application class. To implement the above objective, I've been using my main class to control the GUI.
    Here's an example of how I've implemented it.
    public class Main implements CompanyListener {
        /** Creates a new instance of Main */
        public Main() {
            CompanyListModel companyModel = new CompanyListModel();
            companyModel.addCompanyListener(this);
            CompanyListFrame gui = new CompanyListFrame(companyModel);
        // A company was selected.  Open a new dialog and display the employees
        public void companySelected(CompanyModel companyModel) {
            Company company = companyModel.getCompany();
            EmployeeListModel employeeModel = new EmployeeListModel(company));
            EmployeeListDialog = new EmployeeListDialog(employeeModel);
        public static void main(String[] args) {
            new Main();
    }My program is similiar design wise to the above, but contains many more classes. I'm still using my main class to control GUI logic (popping up new windows and creating models, etc). Thus, my main class implements like 5 different listeners. I'm sure this is a really poor design choice, I just don't know how else to implement it.
    I should not nest models... correct? I was thinking about nesting the models, i.e. CompanyListModel contains an EmployeeListModel, but then the CompanyListModel will need to spawn the EmployeeListDialog when a Company is selected, right? Thus, I'd be mixing the view with the model.
    Please provide some advice! :( Thanks!

    I'm sorry, I read your reply about 3 times and I've
    spent the last 20 minutes trying to implement it.
    I'm just not sure how the controllers are involved.
    Could you possibly provide source code for the
    controllers (and any part of the models / views that
    communicate with the controller)?No source code. Read about the MVC pattern.
    I feel like this is a wasted effort. I'm the sole
    entry level programmer at my company and I have only
    one year real wold experience . I work with about 10
    other senior level (microsoft) programmers and none
    of them code in this fashion. All of our
    applications are desktop applications using C#,
    C/C++, or scripting languages.What's a wasted effort? You posting a question? Me posting a response? You writing Java? You trying to think about how to do this properly?
    So why are you using Java if you're in a Microsoft shop? How's this working out with your co-workers?
    I feel like if I worked on a project with one of
    them, they would criticize me for using MVC and
    "complicating" such a simple issue.That's usually because Microsoft likes tying a particular text box to a column in a table. If you change the textbox value you change the database. Nice and easy, right?
    In trying to implement this solution, my workspace
    now has a huge load of classes for something so
    simple:
    Company
    CompanyFrame
    CompanyListController
    CompanyListListener
    CompanyListModel
    CompanyListPanel
    Employee
    EmployeeListDialog
    EmployeeListModel
    EmployeeListPanel
    Main
    11 classes and I left out the Emp Controller and
    Listener to simplify the example. The more classes
    that you have, the slower the application startup
    time. Moving the Views to JPanels as you suggested
    seemed smart but it wound up making it more
    difficult. I'm using NetBeans and Matisse and I
    don't believe you can use another JPanel class in the
    GUI editor unless you make it a bean.
    Traditionally, I would have implemented as follows.
    I would have completed it in 5 minutes and it would
    be much easier to understand what's going on:
    Company
    CompanyFrame - contains a list of companies
    Employee
    EmployeeListDialog - contains a list of employees
    Main
    Of course doing it this way I'd be mixing data with
    the view, but is that always a bad thing or is it
    only bad for large scale applications? Should MVC
    not be used for small modules like this?For small modules that are nothing more the CRUD operations, it might be that a simpler approach is fine. (PS - CRUD stands for Create/Read/Update/Delete, standard relational operations on tables. I'm not commenting on you or your code.)
    It only becomes a problem when that "simple" CRUD application decides to branch into something bigger. The approach of mingling view and data can become problematic then.
    It's still possible to have a clean application for small apps. I think most Microsoft programmers do it that way because the wizards and stuff they're used only allow it to be done that way.
    The reasons why I'm going away from my old "academic"
    programming practices is:
    1) I want to become a better programmer of course!Kudos to you. At least you're still thinking about it.
    2) There's alot of database queries in this
    application so I wanted to separate that from the GUI
    as much as possible. Thus, each model knows how to
    query the database and it's all done on separate
    threads.That's good motivation, too.
    I'd really like to do this right. If you could
    provide source that would be great. Also, are there
    any good books on desktop GUI development geared
    towards Java (or even C#)?I don't write for the desktop, so I'm not much help.
    I already purchased the e-book Desktop Java Live,
    which is great but they don't go into detail about
    MVC and instead use Model-Presenter which has been
    retired (according to Fowlers website). I found that
    section fairly confusing so I figured I'd start with
    MVC since it's more widespread (?).If you're reading Martin Fowler you're doing well.
    Thank you.I'm sorry that I'm not more helpful.
    %

  • How to implement mvc model in designing game architecture

    I have a problem in implementing the mvc architecture in my game designing. I want you to suggest me how should I do it ?
    I have created 3 packages viz : model , view , and controller
    I am confused in which package should include canvas ? which should implement Runnable ? and what actually the model package must include ?
    Also i would like to know that whatever dynamic active background is generated in my game play must it be treated as model or not ?

    Hi
    Here is a good article about this: http://www-128.ibm.com/developerworks/library/wi-arch6/?ca=drs-wi3704
    Mihai

  • In MVC, how should already-loaded data be handled?

    I have an AS3 application and I'm trying to implement an MVC framework.
    On the model's initialization, data is gathered about the user. When the user clicks a button, say to print their first name, I want to request and retrieve only that data from the model.
    I currently have the view listening for a button click. The button click is handled by the controller. The controller fires a "getUserFirstName" method in the model. I'm confused about this part...
    Since the controller and not the view is calling the method, I can't do a return of the user's first name in this method. Should I dispatch an update event? I'm not sure how to pass this data to the view in the most efficient way. Thank you.

    Good question Kevin.  Design patterns are my forte, so I can assist. first the view is allowed to receive input events but rarely should.  The view as it's referring to is the reflection of data and nothing more.  The controller is the gate way of the users input to the model,  The controller either passes data to the model or can control a views placement/initialization.   Both view and controller have access to the model. The model should retain a reference of any of it's subscribers.  When data is changed in the model, the model should send a notification to any and all subscribers.  I in your case this is the view and controller.  Upon this notification, the view and controller will access the model and retrieve what they require.  There are two types of models.  A push and a pull.. What I just described is the pull methd.  A push is where the model will send in e dispatch what has changed.  For more information feel free to order my latest design pattern book for design patterns on amazon.  advanced action script design patterns.

  • Javabeans in MVC architecture

    Hi
    Building a web application based on MVC architecture. I am new at this so my implementation may not be correct. My Javabeans are representations of SQL DB tables. So, e.g. I have a Customer table in my SQL database, I would have a CustomerBean to represent this table.
    My problem is that Javabeans can only have empty constructors. So how can I get a single record from my customer table? Currently, I am using a method to get this record.
    E.g.
    CustomerBean customer = new CustomerBeanImpl();
    customer.setRecord(primaryKeyOfCustomerTable);
    In setRecord(int PK) method, I execute a SQL query to retrieve the record with that primary key and set all the instance variables for that object.
    I find that this method "not elegant".
    However, if I break the requirements of Javabeans, i.e to implement non-empty constructors, i.e.
    Customer customer1 = new Customer(primaryKey1);
    this would be better. In this case, my class is not a JavaBean anymore.

    Thanks. So, I conclude from your reply that Javabeans
    must have empty constructors. That's what I thought
    too. Until I was looking at an example from "Core
    servlets and JSPs" and came across an example where
    the class used (if anyone is interested, it is
    "TravelCustomer.class" in page 365 of the book) is not
    an Javabean per se, as it did not have a empty
    constructor but was used in the <jsp:useBean> tag like
    any other Javabean!
    That got me confused. Anyone care to explain this?As you know, <jsp:useBean> first checks whether a reference to the specified class exists as an attribute under the specifed id and scope.
    If the reference is found, then the scripting variable is set to that reference. If not found, then <jsp:useBean> checks whether the class can be instantiated and has a no-args constructor. If yes, an object of that class is instantiated (in Tomcat using Beans.instantiate) and the reference is stored as an attribute in the specified scope as well as in the scripting variable.
    In the "Core Servlets..." example, the TravelCustomer object is always instantiated in a servlet and its reference saved as a session attribute with id = "customer". The servlet then forwards to a JSP that includes:
    <jsp:useBean id="customer" class="coreservlets.TravelCustomer" scope="session" />Since the "customer" attribute is always present, the useBean never has to instantiate a TravelCustomer object and so the lack of a no-args constructor does not come into play.
    I'm not sure if this is good or bad practice, but that's why it works.

  • Confusion about shared objects...

    Hi...
    I'm building an application using JSP/Servlet technology and I've ecountered some behavior that is not that unexpected, but is something I can't seem to figure out how to get around.
    I've been using two reference manuals over the last year, to learn JSP/Servlet development and I'm not sure that either one of them, do a very good job of explaining how to avoid the problem I'm seeing. (Or maybe they do, but I'm just too dense to figure it out.)
    Both are O'Reilly manuals:
    Java Servlet Programming - Jason Humber with William Crawford
    Java Server Pages - Hans Bergsten
    Anyway, I've tried to model my application using a MVC approach.
    My controller servlet UserCtl.java is small and routes requests as a controller should.
    My business logic is in a bean. UserBean.java This object has properties that represent the fields from my UserMaster table and corresponding setter/gettter methods. It also has methods to retrieve an individual user record, insert a record, update a record, delete a record and retrieve a list of records.
    The scenario I'm experiencing is as follows:
    I bring up my application in the browser on two different PC's.
    I display the user list on each PC.
    Now...
    On each PC, I simultaneously click the Update User, selecting user 1 on pc 1 and user 2 on pc 2.
    My application then, creates a record in a lock file, for each user record. This seems to work properly, even during the simultaneous click.
    However...
    When the update form is subseqently displayed, I have a situation where the form on each of the 2 pc's contains the same data.
    I can verify that 2 different lock records were created, indicating that I did not click the same user by accident, however, the data in the form is clearly for only one of the users.
    I've read the sections over and over and I feel like I understand their comments on concurrency and how the condition I'm seeing could occur, however, I've tried many things to overcome this and nothing seems to work.
    Originally, I opened my JDBC database connection at the servlet level. I've subsequently tried doing it when I create the bean in the controller and subsequent to that, creating the connection object within the method that retrieves the user data inside the bean.
    I've tried moving all my code into functions, so that any bean variables would be localized.
    I've creating a bean from the JSP session bean object and then retrieving the record, and putting the bean back into the session object before moving to the update page.
    Note... I've also enclosed my record retrieval code within a synchronize block.
    I'm at a complete loss here. Nothing I do seems to work and I can consistently recreate this condition. Obviously, I can't move forward until I find out how to do this properly.
    I'm disappointed in the Java Server Pages book, because the author encapsulated/wrapped all of his database i/o into his own database management routines.
    This is a terrible practice for an author to perform. I understand the concept of why you would do that, however, it complicates learning the fundamentals first. I say show us how to do it the long way first, then show us how to improve on the implementation. Don't confuse an already complicated process with your own home-grown methodology.
    Anyway... I digress. Can anybody give me any pointers or recommend a good book or web based example, that can show me how to overcome the issue I am encountering? My implementation is a straightforward, simple, approach. I am trying to grasp how this stuff works, without adding in all the extra stuff like tag libraries and XSLT, etc.
    I just need to understand how to write a simple thread-safe application. I'll tackle the other stuff later. Oh... by the way... I have built the simple samples that overcome servlet class level counters that show the result differences between global variables at the servlet instance level versus reporting back localized variable values. I think that JDBC database access and/or bean creation, is more complex than that and that's where my problem is.
    Any comments, pointers, references to simple samples, will be greatly appreciated.
    Thanks,
    Brett

              You do not need a shared files system - that is just for
              convenience. You do need to have identical directory stuctures
              for all instances in the cluster.
              Mike.
              "Tomato Bug" <[email protected]> wrote:
              >
              >hi all,
              > I have a confusion with shared objects in cluster.
              > A cluster needs a shared file system to store
              > configuration
              >files and shared objects. Can I only put the shared things
              >in the
              >shared file system but not put them on the servers in
              >the cluster.
              > Thanks.
              >
              > Tomato.
              

  • Confused about FCExpress 3.5 Upgrade

    I'm looking to purchase FCExpress 3.5 version but find
    many offers for version 3.5 Upgrade.
    Amazon even has a version 3.5 Upgrade (old version)
    They all seem to offer the full monty package, but the wording is confusing.
    Any clarification is appreciated.
    Also, I'm noticing a huge variation in price.
    Tips for avoiding scams are also appreciated.
    Thank you
    CR

    If you're looking for FCE 3.5 you'll find it here
    http://macbuy.macworld.com/search_getprod.php?masterid=6735482&
    Upgrade to FCE 4.0 is $99.00 on Apple's site.
    Buying FCE 4.0 as a new bundle has everything but doesn't offer SoundTrack which comes with the 3.5 version. It'll set you back $199.00

  • MVC implimentation with Sun ONE Portal server 6.0

    Hi friends,
    As I am starting to build a few channels for the Portal Server. What I want is to have a JSP channel (JSPProvider), that initiates the first page, but the anything that gets submited by this page will be controlled by a servlet that invokes model (somthing like struts). So far, I haven't been able to do this as I don't know how to with the portal. What I've managed is to hack it by submiting back to itself with some parameters and then use <jsp:include/> to include a different page.
    As you know, I know it's a hack, I'd like to know if there is a proper way to do this? such as somehow extends DesktopServlet so when we do <form action="subclassofdt"> it'll work OK?
    Note that, I want the page to stay within the portal (not opening a new browser and then using normal web server stuff to handle this). The portal server that we are using is on a web server (not on the application server).
    Please help, some code would be really helpful.
    Thanks & regards,
    Thinh

    Again, thanks Alex for the reply. What I am confusing about is how do we get the desktop servlet to renders JSP pages in the portal.
    For example Test.jsp
    <form action="/anotherservlet/" method="post">
    <input type="submit" value="submit">
    </form>
    If we do this, how does the desktop servlet renders the page when we click on Submit? It'll just have to go to a new page (without portal context or portal pages and just normal web pages).
    Another include that I tried is
    Test.jsp
    <%
    if (request.getParameter("nextJSP") != null) {
    %>
    <jsp:include file="Test2.jsp" flush="true"/>
    <%
    %>
    <form action="dt" method="post">
    <input type="hidden" name="nextJSP" value="Test2.jsp">
    etc..
    <input type="submit" value="Submit"
    </form>
    However, doing this inside a JSP is kind of hacking, I'd like to do proper MVC as in Struts based applications .
    Thanks & regards,
    Thinh
    Hi,
    MVC with portal 6.0 :
    - JSP Channel as "View",
    - uses JavaBean as "Controller"
    - to interact with "Model".
    Now instead of JavaBean you have servlet
    running on the same container. It seems, that
    you only need a JSP-proxy.
    (Also you can try to forward in the jsp)
    Cheers,
    Alex :-)

  • OOP And AS 3.0, Something That Confuses Me ALOT!

    Hello everybody, there's something that's been on my mind for quiet a while now, and everytime I think about I get confused even more lol. Anyway, this might sound stupid to most of you but I donno, I just don't get it.
    There are many flash developers out there who are building flash applications using OOP, some of them provide their scripts for download and that's good. The problem is that when I download those files, I have no idea how to incorporate them into my project. The files usually contain the fla, the swf, class files inside a package, and the document class. All of this looks nice but the confusing part is how to use it in my project! I have some questions and hopefully when they're answered I won't be confused anymore:
    1. Suppose I downloaded two different applications, each has its own classes and its own document class. I customized them to my liking and everything and now it's time to use BOTH of them in my project. How am I supposed to use both document classes in one? Do I make my own document class, import the classes of both projects to it, then copy the codes of the document classes into mine? Or is there some other way of doing it?
    2. Can I use OOP and timeline code in the same project? Like some big application could be used in the project using the OOP/Classes approach, while other simple stuff like navigation could be coded in the timeline. But usually isn't the document class a replacement for the main timeline of my flash file? Hmmm confused as you can see...
    That's all I could think of for now... I would appreciate anyone that answers these questions for me because this confusion is really bothering me... Thanks in advance

    Technical books by nature are disconnected in many ways from realities of every day tasks. It is especially true, in my view, in Flash/ActionScript. In many case authors treat Flash development the same way they would relate to an enterprise level application. Many authors come not from design but development background in other stronger languages (Java, C++, etc.) and computer science. This is, actually, great for it is about time Flash/ActionScript gets a status of a “serious” development tool.
    Nevertheless, I see Flash development as a very special set of skills and, in some instances, as something that needs an artistic talent and imagination as prerequisite. In a lot of cases Java/C++, etc. developers, no matter how genius they are, just cannot hold entire picture together. Flash developer must be able to coordinate sometimes humongous amount of use cases and forks in order to implement the final vision. As a visual result oriented process, Flash development deviates toward immediate practical needs more than in the direction of satisfying abstract programming concepts and may legitimately go against conventional structure because structure is getting in the way.
    One of the important aspects of products developed in Flash that is often overlooked is that they must be very lean. Even with advances in bandwidth application loading speed and financial implications are still tangible. I saw many awesome, smartly and correctly architected cool looking Flash applications that resulted in huge multi-MB blobs that run their appeal to the ground for a single reason of slow loading.
    Another thing that often makes little sense is design patterns. Don’t take me wrong – I got very useful ideas how to structure my applications from design pattern concepts. But what really annoys me is when design patterns become the goal – not a tool. I see this propaganda for DP went as far as making novices in AS to attempt learning patterns and custom frameworks before getting a clear idea of how to add event listener to a button. This is totally detrimental to learning and creativity IMHO. I hope you will not fall into this pitfall. Just for the safety reasons, though, you just should learn how to say “Design patterns are invaluable” with a wide smile because odds are huge you will encounter a militant interviewer who will kill your chances because you were not fast enough to scream “MVC!” This is a trade off of dealing with unimaginative programming dictators who made career by repackaging someone else’s ideas and convincing CTOs that JSON and JQERY are the best inventions after beer.
    I am available, though, to admit that this may be my combative ignorance talking and in a year I might post a Mao Zedong quotations book-like proclamation that design patterns are the only way to go. But today I rather sit in the center of Pyongyang in a silent protest against Kim Jong Il’s drinking habits rather than deal with proponents of DP.
    So, don’t listen to anyone including me. Just keep in mind that some humans like to drink warm vodka.
    There is another brainwash that penetrates virgin minds. People say that if you use timeline – it is not OOP. I think it is a total BS. When one writes code on timeline – he/she declares and instantiates variables and classes, uses functions, etc. – all these things ARE objects. So, why is not it OOP? Who said that only writing classes is OOP?
    I am saying that even though I practically don’t use timeline coding any longer - not for political but for purely practical reasons. And yes, a newly awaken geek in me loves cleaning and refactoring my code. We all loose our purity at some point.
    OOP is grand and it has proven its usefulness and dominance. But even then one encounters periodically very smartly substantiated cases against OOP in defense of procedural programming. Again, remember diluted ethanol at room temperature preferences.
    In other words, as Kennedy said, it is not what I can do for encapsulation but what encapsulation can do for me.
    My point is that unless one sincerely internalizes an OOP concept and see its usefulness – one cannot utilize it correctly anyway?
    Again, to me encapsulation, for one, is extremely useful and I love to do things in as abstract manner as possible for a single reason – I am lazy and I love to reuse things. But I also want to be in control and I want to have a very clear idea how this staff that I reuse works.
    There are applications whose code is worth incorporating into your projects and others that are worth emulating by writing your own code after just looking at what it does as a result for it is easier that repainting Sistine Chapel to the specs. More often than not, reverse engineering takes longer than writing code from scratch. With very few exceptions someone else’s code is not sufficient at best. Let alone that the code is applied to a limited number of use cases where your vision is not represented.
    For instance, TeewnLite/TweenMax is a very useful package. It is tightly focused and accomplishes common and often used functionality. The best thing is that you don’t need to tweak it – it is totally cooked. It can be used in many different environments and applications. Another positive example is Papervision3D. These two things are strong and sufficient to stand on their own two feet.
    But if you get an FLA with packages attached – you probably need to relate to it as a suggestion that may help you to come with architecture quicker and allow for pasting code snippets but, at the end of the day, your thing is almost always is different.
    This brings us to your questions (finally).
    Document class is sort of a needle that pulls all the thread into the tapestry. One of its purposes is to initialize the application and make sure that all these things that one wrote are in order. As such – it is most probably manifests application’s architecture in a very tight manner. “Tight” is a keyword for once doc class is taken out of context it renders useless.
    For instance, you have three applications that you just love to the point of you dreaming about them at siesta. These programs are slide show, video player and Mona Lisa rotating in 3D space in an insane coupling with Saddam Hussein’s photo taken while he was wistfully defecating in the hot winds of Babylon oasis.
    Now you decide that your video player should have slide show’s thumbnail navigation and transitions like relationships between the beauty and the dictator. Combining document classes most probably will not accomplish anything and you will have to dig deep into the code in order to fuse these three breathtaking features. Also, even if there was a way to fuse these three doc classes – because they use their own packages the size of your application will be three times bigger than it is supposed to be for all of them import their own mucus and litter memory with the staff you don’t use.
    Q2.
    I hope that it is clearer now that if you use Flash IDE and its compiler – you are better off with a document class. Otherwise, you will need to find another way to start. In case of other compilers you have another way to initialize.
    Q3.
    If you      use a movie clip only once and code for this mc pertain to this mc only – there is no practical difference between a timeline code inside this mc or      writing a class and attach it to mc. But, more often than not, you will discover that several symbols in your library share a lot of      functionality. So, if you create a class that combines these commonalities and then extend it – you will end up with a slimmer code as well as with a      smaller swf. I like writing classes also because all my code is in one place – not in two - timeline and .as files.
    You ARE using OOP approach if one believes anything I say. I suggest you delegate as little as possible to doc class. And yes, you can view doc class as a rightful representative of timeline.
    You know what I mean?
    Now I have to find this sauce pan my cleaning lady puts into different locations every time she tidies the kitchen (I feel like a bloodhound in training) and, hopefully, eat the necessity of which (despite the offensive nature of metabolism) has transpired from all this low glucose level / manic phase delirium I typed. And NO, I don’t like warm vodka.

  • How to determine percentage variation in flow rate during various time periods

    Hi,
    Am in medical electronics division.
    I want to simulate infusion pump.
    How to do it.

    You are confusing me.
    In the title you are trying to determine the variations in flow rate, but in the message body you want to simulate an infusion pump.
    Can you add a few more sentences to explain what you are trying to do.
    Controlling a pump is very different to measuring exact flow rates.
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for

  • Outgrowing iPhoto? I want more metadata options

    I use PSE 8 for my external editing program and iPhoto '09. This setup is great for what I do. At least until now, as I feel I may be outgrowing iPhoto. I'm wanting to add more information to metadata file info. I have keywords, but I would like to i

  • How to update all the record for a particular column in a table based on search criteria.

    Hi All, I am new to ADF. I have a requirement, where i have to perform mass update on a table. Scenario: Ex: I have a dept manual search region. where i search with deptId: 20. I get 20 records in my table. now i have  another region where i have a i

  • Button Event Handler in a JList, Please help.

    Hi everyone, I have created a small Java application which has a JList. The JList uses a custom cell renderer I named SmartCellRenderer. The SmartCellRenderer extends JPanel and implements the ListCellRenderer. I have added two buttons on the right s

  • How to build project in NWDS from ear file?

    I do know that it maynot be possible to build a project from a .ear file but I am sure there must be a way out. I am sure someone else would have faced the same problem that I am facing. This is what happened. We had a consultant working on our ESS/M

  • U410 SSD Error- Found uncorrectable data error LBA

    I have lenovo ideapad U410. Few weeks back it felt down from table. Since then it was running slow. I formatted my laptop twice. But after formatting whenever I tried to install other software it was slowing down again. I have checked with lenovo ser