JSP, BEANS AND DAO best practice... (and a little of STRUTS & JSTL)

Hi,
Want to get your opinion on how to really use bean and dao in jsp pages.
Imagine that you wants to display a news list on the jsp index page for example.
You've got a dao with method getLastNews(int size) which returns a Collection of News beans. Then with jstl or struts you iterate ove the collection to display the news in a formatted way.
Easy to build collection with scriptlets & co but not very clean...
What is the best way to call my dao and its method with a tag whithout using scriplets ?
Thanks

Yes this is the solution i use when the collection is displayed alone in a jsp page, but how do you do this when you include this collection in a page, and if you have other collections in other parts of the page ? Is there a clean solution of doing this in the jsp page? For example:
<sometag:loadmycollection name="list"/>
<logic:iterate id="myCollectionElement" name="list">
Element Value: <bean:write name="myCollectionElement" />
</logic:iterate>
I know that i can write my own tag by if there is an existing solution...

Similar Messages

  • Manage bean Request Scope Best Practice

    Hi,
    I am wondering the following practice which one is better.
    I have a listing page and a edit properties page. From the listing page i will click on the record from the data table and click on Edit button to submit the action and navigate to the edit properties page. My BookListingBean and BookPropertyBean have a BookVO variable defined.
    public class BookListingBean { BookVO selectedVO; }
    public class BookPropertyBean {BookVO bookVO;}
    When action submitted, i have a custom navigation handler which eventually will pass the selected row which is an value object, says bookVO to my action method. Then i need to retrieve the book's properties from the database based on the selected bookVO's id and set to book value object for display.
    The question is, in BookPropertyBean action method, i can either point the bookVO to the selectedVO directly and use it for display or i wil instantiate a new BookVO and just retrieve the id from the selectedVO and set it to my bookVO.
    // selectedVO contains the needed id
    public String edit(BookVO selectedVO) {
    bookVO = selectedVO;
    // invoke API to retrieve the book's properties by passing bookVO
    Or
    public String edit(BookVO selectedVO) {
    bookVO = new BookVO();
    bookVO.setId(selectedVO.getId());
    // invoke API to retrieve the book's properties by passing bookVO
    For me, i would prefer the latter one which is instantiate a new VO as the selectedVO is belongs to previous request and i think i should use new object for the new request but not to own anything from previous request when displaying the edit page.
    Am i wrong?

    I would use first edit implementation... From description I don' t see reason to duplicate BookVO object... If BookVOs properties is used by API to retrieve and fill page with data for current request without anu modification of BookVOs state there is no need to duplicate... But api changes BookVO and if you need use original member values of BookVO after edit in some other method it's reasonable to use second implementation.
    Still I can't exactly be sure in my statements because this is jus a fragment of your application.
    Best regards!

  • Philisophical Question:  Tools for synchronizing JSPs, Java Beans and XML?

    This is a "best practices" question...
    The JSTL and JSF tags provide a lot of support for minimizing the amount of text that must be included in a JSP page. For example:
    <c:out value="${customer.firstName}"/>This snippet will find an object named "customer" in any of the JSP scopes, extract the value of the property named "firstName", and output it as part of the page.
    Here are my questions:
    (1) Is there a recommended method to communicate to the page designer what objects are in scope for a particular page, and what the properties of those objects are?
    (2) Is there any programmatic way to determine from the program's source code that an object with the specified name and of the expected type will be in scope at run time?
    I would love to have an IDE that would be able to help the page designer by providing a list of the objects that are expected to be in scope, along with the name of their properties. What conventions exist to make this possible?

    Maybe you like this, it's one of dozens of tools for Struts and in version 3.0
    http://www.scioworks.com/scioworks_camino.html
    hth,
    .V

  • JSP Best Practices and Oracle Report

    Hello,
    I am writing an application that obtains information from the user using a JSP/HTML form and then submitted to a database, the JSP page is setup using JSP Best Practices in which the SQL statments, database connectivity information, and most of the Java source code in a java bean/java class. I want to use Oracle Reports to call this bean, and generate a JSP page displaying the information the user requested from the database. Would you please offer me guidance for setting this up.
    Thank you,
    Michelle

    JSP Best Practices.
    More JSP Best Practices
    But the most important Best Practice has already been given in this thread: use JSP pages for presentation only.

  • Best practice for dealing with Recordsets, JDBC and JSP?

    I've spent the last three years developing web apps using JSP, Struts and Kodo JDO for persistence. All of the content for the apps was created as Java objects using model classes and saved to an Oracle db. Thus, data retrieved from the db was as instances of the model classes and then put into Struts form beans, etc.
    I changed jobs last month and am now having to use Servlets with JDBC to retrieve records from db tables and returning it into Recordsets. Oh, and I can't use Struts in my JSPs either. I'm beginning to think that I had it easy at my previous job but maybe that's just because I was used to it.
    So here are my problems/questions:
    I have two tables with a one to many relationship that I need to retrieve data from, show in a jsp and be able to update eventually.
    So here's what I am doing:
    a) In a servlet, I use a SQL statement to join the tables and retrieve the results into a Recordset.
    b) I created a class with a bunch of String attributes to copy the Recordset data into, one Recordset row per each instance of the bean and then close the Recordset
    c) I then add the beans to an ArrayList and save the ArrayList into the session.
    d) Then, in the JSP, I retrieve the ArrayList from the session and iterate over each bean instance, printing the data out to the jsp. There are some logic statements to determine when not to print redundant data caused by the one to many join.
    e) I have not written the code to update the data yet but was planning on having separate jsps for updating the (one) table and the (many) table.
    Would most of you do something similar? Would you use one SQL statement to retrieve all of the data for display and use logic to avoid printing the redundant part of the data? Or would you have used separate SQL queries, one for each table? Would you have saved the results into something other than an instance of a bean class that represents one record in the RecordSet? Would you have had a bean class with attributes other than Strings - like had a collection attribute to hold the results from the "many" table? The way that I am doing everything just seems so cumbersome and difficult compared to using Struts and JDO before.
    Your help/opinion will be greatly appreciated!

    Would you use one SQL statement to retrieve all of the data for display Yes.
    and use logic to avoid printing the redundant part of the dataNo.
    I believe in minimising the number of queries. If it is a simple one-many join on a db table, then one query is better than one + n queries.
    However I prefer to store the objects in a bean class with attributes other than strings - ie one object, with a collection attribute to hold the related "many" records.
    Does the fact you are not using Struts mean that you have to use scriptlet code? (shudder)
    Or are you using JSTL, or other custom tags?
    How about tools like Ant? Junit testing?
    The way that I am doing everything just seems so cumbersome and difficult
    compared to using Struts and JDO before.Anything different takes adjusting to. Sounds like you know what you're doing for the most part. I agree, in terms of best practices what you have described so far sounds like a step backwards from what you were previously doing.
    However I wouldn't go complaining about it too loudly, too quickly. If you're new on the block theres nothing like making a pain of yourself, and complaining how backwards the work they have done is to put your new workmates' backs up
    Look on it as a challenge. Maybe discuss it quietly with a team leader, to see if they understand how much easier/better/less error prone such approaches can be?
    Struts, cumbersome as it can be, definitely has the advantage of pushing you to follow good MVC practice.
    Good luck,
    evnafets

  • What are best practice for packaging and deploying j2EE apps to iAS?

    We've been running a set of J2EE applications on a pair of iAS SP1b for about a year and it has been quite stable.
    Recently however we have had a number of LDAP issues, particularly when registering and unregistering applications (registering ear files sometimes fails 1st time but may work 2nd time). Also We've noticed very occasionally that old versions of classes sometimes find their way onto our machines.
    What is considered to be best practice in terms of packaging and deployment, specifically:
    1) Packaging - using the deployTool that comes with iAS6 SP1b to package is a big manual task, especially when you have 200+ jsp files. Are people out there using this or are they scripting it with a build tool such as Ant?
    2) Deploying an existing application to multiple iAS's. Are you guys unregistering old application then reregistering new application? Are you shutting down iAS whilst doing the deployment?
    3) Deploying ear files can take 5 to 10 mins, is this normal?
    4) In a clustered scenario where HTTPSession is shared what are the consequences of doing deployments to data stored in session?
    thanks in asvance for your replies
    Owen

    You may want to consider upgrading your application server environment to a newer service pack. There are numerous enhancements involving the deployment tool and run time layout of your application that make clear where you're application is loading its files from.
    If you've at a long running application server environment, with lots of deployments under your belt, you might start to notice slow downs in deployment and kjs start time. Generally this is due to garbage collecting in your iAS registry.
    You can do several things to resolve this. The most complete solution is to reinstall the application server. This will guarantee a clean ldap registry. Of course you've got to restablish your configurations and redeploy your applications. When done, backup your application server install space with the application server and directory server off. You can use this backup to return to a known configuation at some future time.
    For the second method: <B>BE CAREFUL - BACKUP FIRST</B>
    There is a more exhaustive solution that involves examining your deployed components to determine the active GUIDS. You then search the NameTrans section of the registry searching for Applogic Servlet *, and Bean * entries that represent your previously deployed components but are represented in the set of deployed GUIDs. Record these older GUIDs, remove them from ClassImp and ClassDef. Finally remove the older entries from NameTrans.
    Best practices for deployment depend on your particular environmental needs. Many people utilize ANT as a build tool. In later versions of the application server, complete ANT scripts are included that address compiling, assembly and deployment. Ant 1.4 includes iAS specific targets and general J2EE targets. There are iAS specific targets that can be utilized with the 1.3 version. Specialized build targets are not required however to deploy to iAS.
    Newer versions of the deployment tool allow you to specify that JSPs are not to be registered automatically. This can be significant if deployment times lag. Registered JSP's however benefit more fully from the services that iAS offers.
    2) In general it is better to undeploy then redeploy. However, if you know that you're not changing GUIDs, recreating an existing application with new GUIDs, or removing registered components, you may avoid the undeploy phase.
    If you shut down the KJS processes during deployment you can eliminate some addition workload on the LDAP server which really gets pounded during deployment. This is because the KJS processes detect changes and do registry loads to repopulate their caches. This can happen many times during a deployment and does not provide any benefit.
    3) Deploying can be a lengthy process. There have been improvements in that performance from service pack to service pack but unfortunately you wont see dramatic drops in deployment times.
    One thing you can do to reduce deployment times is to understand the type of deployment. If you have not manipulated your deployment descriptors in any way, then there is no need to deploy. Simply drop your newer bits in to the run time space of the application server. In later service packs this means exploding the package (ear,war, or jar) in to the appropriate subdirectory of the APPS directory.
    4) If you've changed the classes of objects that have been placed in HTTPSession, you may find that you can no longer utilize those objects. For that reason, it is suggested that objects placed in session be kept as simple as possible in order to minimize this effect. In general however, is not a good idea to change a web application during the life span of a session.

  • Best Practices for NCS/PI Server and Application Monitoring question

    Hello,
    I am deploying a virtual instance of Cisco Prime Infrastructure 1.2 (1.2.1.012) on an ESX infrastructure. This is being deployed in an enterprise enviroment. I have questions around the best practices for moniotring this appliance. I am looking to monitor application failures (services down, db issues) and "hardware" (I understand this is a virtual machine, but statistics on the filesystem and CPU/Memory is good).
    Firstly, I have enabled via the CLI the snmp-server and set the SNMP trap host destination. I have created a notification receiver for the SNMP traps inside the NCS GUI and enabled the "System" type alarm. This type includes alarms like NCS_DOWN and PI database is down. I am trying to understand what the difference between enabling SNMP-SERVER HOST via the CLI and setting the Notification destination inthe GUI is? Also how can I generate a NCS_DOWN alarm in my lab. Doing NCS stop does not generate any alarms. I have not been able to find much information on how to generate this as a test.
    Secondly, how and which processes should I be monitoring from the Management Station? I cannot easily identify the main NCS procsses from the output of ps -ef when logged in the shell as root.
    Thanks guys!

    Amihan_Zerrudo wrote:
    1.) What is the cost of having the scope in a <jsp:useBean> tag set to 'session'? I am aware that there are a list of scopes like page, application, etc. and that if i use 'session' my variable will live for as long as that session is alive. (did i get this right?). You should rather look to the functional requirements instead of costs. If the bean need to be session scoped (e.g. maintain the logged in user), then do it so. If it just need to be request scoped (e.g. single page form data), then keep it request scoped.
    2.)If the JSP Page where i use that <useBean> is to be accessed hundred of times a day, will it compensate my server resources? Right now i am using the Sun Glassfish Server.It will certainly eat resources. Just supply enough CPU speed and memory to a server. You cannot expect that a webserver running at a Pentium 500MHz with 256MB of memory can flawlessly serve 100 simultaneous users at the same second. But you may expect that it can serve 100 users per 24 hour.
    3.) Can you suggest best practice in memory management given the architecture i described above?Just write code so that it doesn't unnecessarily eat memory. Only allocate memory if your application need to do so. You should rather let the hardware depend on the application requirements, not to let the application depend on the hardware specs.
    4.)Also, I have implemented connection pooling in my architecture, but my application is to be used by thousands of clients everyday.. Can the Sun Glassfish Server take care of that or will I have to purchase a powerful sever?Glassfish is just an application server software, it is not server hardware. Your concerns are rather hardware related.

  • Best JSP/Beans Practices

    I am setting up a very simple guestbook using JSP. I have a GuestBean in which I set the info passed from the <form>. Is it best practice to have a separate bean for db connection and inserting the info or can I do it all in one bean?
    If separate is the better route, do I add a <jsp:useBean> tag in my JSP page to instantiate an instance of the db connection/insert bean?
    Input greatly appreciated....Thanks!

    From my own expierence, the best way to handle database connections is to let the Web Container handle them. I usually have the bean do a JNDI lookup each time it needs a connection. This seperates the bean from any database connection logic. It also gives you the flexibility of changing eitehr the connection method or the database server without having to modify your bean code.
    - Chris

  • Sessions and Controllers best-practice in JSF2

    Hi,
    I've not done web development work since last using Apache Struts for its MVC framework ( about 6 years ago now ). So bear with me if my questions does not make sense:
    SESSIONS
    1) Reading through the JSF2 spec PDF, it mentions about state-saving via the StateManager. I presume this is also the same StateManager that it used to store managed-beans that are in @SessionScoped ?
    2) In relation to session-scoped managed beans, when does a JSF implementation starts a new session ? That is, when does the implementation such as Mojarra call ExternalContext.getSession( true ) .. and when does it simply uses an existing session ( calling ExternalContext.getSession( false ) ) ?
    3) In relation to session-scoped managed beans, when does a JSF implementation invalidate a session ? That is, when does the implementation call ExternalContext.invalidateSession() ?
    4) Does ExternalContext.getSession( true ) or ExternalContext.invalidateSession() even make sense if the state-saving mechanism is client ? ( javax.faces.STATE_SAVING_METHOD = client ) Will the JSF implementation ever call these methods if the state-saving mechanism is client ?
    CONTROLLERS
    Most of the JSF2 tutorials that I have been reading on-line uses the same backing-bean when perfoming an action on the form ( when doing a POST or a GET or a post-back to the same page ).
    Is this best practice ? It looks like mixing what should have been a simple POJO with additional logic that should really be in a separate class.
    What have others done ?

    gimbal2 wrote:
    jmsjr wrote:
    EJP wrote:
    It's better because it ensures the bean gets instantiated, stuck in the session, which gets instantiated itself, the bean gets initialised, resource-injected, etc etc etc. Your way goes goes behind the scenes and hopes for the best, and raises complicated questions that don't really need answers.Thanks.
    1) But if I only want to check that the bean is in the session ... and I do NOT want to create an instance of the bean itself if it does not exist, then I presume I should still use ExternalApplication.getSessionMap.get(<beanName>).I can't think of a single reason why you would ever need to do that. Checking if a property of a bean in the session is populated however is far more reasonable to me.In my case, there is an external application ( e.g. a workflow system from a vendor ) that will open a page in the JSF webapp.
    The user is already authenticated in the workflow system, and the external system from the vendor sends along the username and password and some parameters that define what the request is about ( e.g. whether to start a new case, or open an existing case ). There will be no login page in the JSF webapp as the authentication was already done externally by the workflow system.
    Basically, I was think of implementing a PhaseListener that would:
    1) Parse the request from the external system, and store the relevant username / password and other information into a bean which I store into the session.
    2) If the request parameter does not exist, then I go look for a bean in the session to see if the actual request came from within the JSF webapp itself ( e.g. if it was not triggered from the external workflow system ).
    3) If this bean does not exist at all ( e.g. It was triggered by something else other than the external workflow system that I was expecting ) then I would prefer that it would avoid all the JSF lifecycle for the current request and immediately do a redirect to a different page ( be it a static HTML, or another JSF page ).
    4) If the bean exist, then proceed with the normal JSF lifecycle.
    I could also, between [1] and [2], do a quick check to verify that the username and password is indeed valid on the external system ( they have a Java API to do that ), and if the credentials are not valid, I would also avoid all the JSF lifecycle for the current request and redirect to a different page.

  • Best Practice For Display Description and getting Id from  af:selectOneChoice

    HI Experts,
    I have a table DeptTable with the two attributes. 1) DeptId and 2)DeptName
    I want to diplay List of all DeptName in <af:selectOneChoice component. and in backingbean or managedbean I want to get
    corresponding DeptId for Selected DeptName in <af:selectOneChoice.
    To be precise, IN UI I want to see -
    Dept A
    Dept B
    Dept C
    And in bean I want to get-
    101
    102
    103.
    If I select DeptA I want to get 101.
    Therefore what is the best practice to achieve it.
    Regards,

    CJ,
    I vote for solution 1 as it's just your use case. As you said you what to update the his_status_id and her_status_id through the by selecting a STATUSES.short_txt_descr by a drop down. This is exactly the LOV solution.
    ViewLinks are used fro master detail navigation (which you don't do here) and Joining the data make it difficult to update (and you still need a LOV for the drop down box.
    Timo

  • How can i use JAVA BEAN and JSP?

    well, i have developed all my web apps by using pure JSP only, i know this sucks, but i dont know how to start on using beans... what directory should i put them into... etc... what are the good programminmg practices/standards/techniques when incorporating beans in jsp???

    Standards are pretty loose, but generally, Beans hold a lot of the backend logic for your JSP. This can include data validation before entering into the database, database inserts, queries, data manipulation. The JSP should really only contain code that will retrieve the data from the bean and appropriately output it.
    As far as using them, you can use the <jsp:useBean> tag in your JSP. As long as the bean is stored somewhere that your classpath points to, you're all set. From then on, you can use it like any other object in your JSP.

  • Question about main difference between Java bean and Java class in JSP

    Hi All,
    I am new to Java Bean and wonder what is the main difference to use a Bean or an Object in the jsp. I have search on the forum and find some post also asking the question but still answer my doubt. Indeed, what is the real advantage of using bean in jsp.
    Let me give an example to illustrate my question:
    <code>
    <%@ page errorPage="errorpage.jsp" %>
    <%@ page import="ShoppingCart" %>
    <!-- Instantiate the Counter bean with an id of "counter" -->
    <jsp:useBean id="cart" scope="session" class="ShoppingCart" />
    <html>
    <head><title>Shopping Cart</title></head>
    <body bgcolor="#FFFFFF">
    Your cart's ID is: <%=cart.getId()%>.
    </body>
    <html>
    </code>
    In the above code, I can also create a object of ShoppingCart by new operator then get the id at the following way.
    <code>
    <%
    ShoppingCart cart = new ShoppingCart();
    out.println(cart.getId());
    %>
    </code>
    Now my question is what is the difference between the two method? As in my mind, a normal class can also have it setter and getter methods for its properties. But someone may say that, there is a scope="session", which can be declared in an normal object. It may be a point but it can be easily solved but putting the object in session by "session.setAttribute("cart", cart)".
    I have been searching on this issue on the internet for a long time and most of them just say someting like "persistance of state", "bean follow some conventions of naming", "bean must implement ser" and so on. All of above can be solved by other means, for example, a normal class can also follow the convention. I am really get confused with it, and really want to know what is the main point(s) of using the java bean.
    Any help will be highly apprecaited. Thanks!!!
    Best Regards,
    Alex

    Hi All,
    I am new to Java Bean and wonder what is the main
    difference to use a Bean or an Object in the jsp. The first thing to realize is that JavaBeans are just Plain Old Java Objects (POJOs) that follow a specific set of semantics (get/set methods, etc...). So what is the difference between a Bean and an Object? Nothing.
    <jsp:useBean id="cart" scope="session" class="ShoppingCart" />
    In the above code, I can also create a object of
    ShoppingCart by new operator then get the id at the
    following way.
    ShoppingCart cart = new ShoppingCart();
    out.println(cart.getId());
    ...Sure you could. And if the Cart was in a package (it has to be) you also need to put an import statement in. Oh, and to make sure the object is accessable in the same scope, you have to put it into the PageContext scope. And to totally equal, you first check to see if that object already exists in scope. So to get the equivalant of this:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart"/>Then your scriptlet looks like this:
    <%@ page import="my.pack.ShoppingCart %>
    <%
      ShoppingCart cart = pageContext.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        pageContext.setAttribute("cart", cart);
    %>So it is a lot more work.
    As in my mind, a normal class can also
    have it setter and getter methods for its properties.True ... See below.
    But someone may say that, there is a scope="session",
    which can be declared in an normal object.As long as the object is serializeable, yes.
    It may be
    a point but it can be easily solved but putting the
    object in session by "session.setAttribute("cart",
    cart)".Possible, but if the object isn't serializable it can be unsafe. As the point I mentioned above, the useBean tag allows you to check if the bean exists already, and use that, or make a new one if it does not yet exist in one line. A lot easier than the code you need to use otherwise.
    I have been searching on this issue on the internet
    for a long time and most of them just say someting
    like "persistance of state", "bean follow some
    conventions of naming", "bean must implement ser" and
    so on. Right, that would go along the lines of the definition of what a JavaBean is.
    All of above can be solved by other means, for
    example, a normal class can also follow the
    convention. And if it does - then it is a JavaBean! A JavaBean is any Object whose class definition would include all of the following:
    1) A public, no-argument constructor
    2) Implements Serializeable
    3) Properties are revealed through public mutator methods (void return type, start with 'set' have a single Object parameter list) and public accessor methods (Object return type, void parameter list, begin with 'get').
    4) Contain any necessary event handling methods. Depending on the purpose of the bean, you may include event handlers for when the properties change.
    I am really get confused with it, and
    really want to know what is the main point(s) of
    using the java bean.JavaBeans are normal objects that follow these conventions. Because they do, then you can access them through simplified means. For example, One way of having an object in session that contains data I want to print our might be:
    <%@ page import="my.pack.ShoppingCart %>
    <%
      ShoppingCart cart = session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        session.setAttribute("cart", cart);
    %>Then later where I want to print a total:
    <% out.print(cart.getTotal() %>Or, if the cart is a JavaBean I could do this:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart" scope="session"/>
    Then later on:
    <jsp:getProperty name="cart" property="total"/>
    Or perhaps I want to set some properties on the object that I get off of the URL's parameter group. I could do this:
    <%
      ShoppingCart cart = session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        cart.setCreditCard(request.getParameter("creditCard"));
        cart.setFirstName(request.getParameter("firstName"));
        cart.setLastName(request.getParameter("lastName"));
        cart.setBillingAddress1(request.getParameter("billingAddress1"));
        cart.setBillingAddress2(request.getParameter("billingAddress2"));
        cart.setZipCode(request.getParameter("zipCode"));
        cart.setRegion(request.getParameter("region"));
        cart.setCountry(request.getParameter("country"));
        pageContext.setAttribute("cart", cart);
        session.setAttribute("cart", cart);
      }Or you could use:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart" scope="session">
      <jsp:setProperty name="cart" property="*"/>
    </jsp:useBean>The second seems easier to me.
    It also allows you to use your objects in more varied cases - for example, JSTL (the standard tag libraries) and EL (expression language) only work with JavaBeans (objects that follow the JavaBeans conventions) because they expect objects to have the no-arg constuctor, and properties accessed/changed via getXXX and setXXX methods.
    >
    Any help will be highly apprecaited. Thanks!!!
    Best Regards,
    Alex

  • Best practices for JavaFX architecture and patterns?

    Hi,
    I want to write reusable, easy to maintain JavaFX code for a larger UI project and wonder what are the best practices doing so.
    1) Are there preferred UI patterns? MVC, MVP, Presentation Model, ...?
    2) Does it make sense to use FXML to separate View from Logic? Or should I use 2-3 Java classes instead (one for View, one for Logic, one for Domain Model, depending on the pattern)
    3) How to organize all the views? Should I use Dependency Injection? Or Singletons for each view? Spring or Guice framework, if at all?
    Currently I use singletons for most views, so that I can use them from anywhere in my application. If a window is closed and opened again, I use the same instance for that, which still resists in memory.
    For patterns, I try to lean on Presentation Model, since this is what I know from Flex development: Having a View layer, which contains all the UI stuff and an abstract view layer, which holds properties, that describe the View, e.g. submitButtonDisabledProperty. The View knows the abstract layer (Presentation Model), but not vice versa and the UI elements are bound to its properties.
    I am unsure if this is appropriate for JavaFX, too (for Flex or Silverlight it is).
    What are your recommendations / experiences for large UI projects?

    You are correct that in 'pure' MVP the View should know as little about it's presenter implementation as possible. The view should just notify one or more 'listeners' that something has happened.
    You can use event listeners for this, but I would highly recommend not exposing your Control-specific GUI events and instead create your own. So for example, don't expose ActionEvent or MouseEvent as these expose too much detail about your View's implementation, instead create 'semantic' events, so you might have something like 'sayHelloRequested' or 'printOptionSelected' (whatever naming system you want). This hides how the option is implemented, so you might have a 'print' button, a 'print' menu option, a CTRL+P print shortcut, or a double tap anywhere on your screen to print. The listener knows only that the view thinks 'print was requested by the user' - decoupling achieved.
    Once you start doing this however you end up with an explosion of event listener interfaces. So say a view has 10 callbacks it wants to notify about, then you end up with 10 interfaces, and if you're being really pure you also end up with 10 'Event' beans (or DTOs) to encapsulate the details of that event. It starts to get ungainly even for a semi-purist like me. So the logical progression from there is usually just to define all 10 callbacks in one interface and call it something like MyViewListener.
    There are two common ways to implement listeners, the traditional way is to allow an arbitrary number of listeners to be added. Whereas another option is to allow only a single listener to be added. In JFX you will notice that Button for example has a setOnAction() method not a addOnAction() method - it allows a single event handler only and let's face it this is generally fine in 95% of cases. For the remaining 5% you can just write your own aggregate event handler that dispatches the event to multiple listeners.
    So if we go down the road of single event listeners, using an interface for all of the callbacks and not bothering with full 'Event' objects, you end up with something like this:
    public interface MyViewListener {
        void printRequested();
        void doSomething(int someParam);   
        void doSomethingElse(String someOtherParam);   
    }And if you look closely at the 'Purist' option in my MVP pattern where I define interfaces for everything, then you will see that this is pretty much the exact interface I've created for the 'Presenter'. You could just as easily rename this interface to MyViewListener in this pattern and have the same outcome.
    So to wrap all that up, yes, the Presenter should be decoupled and I highly favour the 'purist' option in my blog and would definitely use it if FXML didn't dictate a impure design pattern (there are some ongoing discussions about this on the OpenJFX discussion group). And, yes, my 'purist' option could be even more pure if you went for the full-blown event callback model and if you go down that road you will have an extremely clean architecture but also an extremely large code-base - totally your call whether it's worth it.
    It's also worth remembering in all this, that there are a lot of people from a lot of different backgrounds using JFX and some people hate (passionately) even my semi-pure option - especially those coming from other, less heavy-weight languages. They just don't get why you wouldn't build it all into one class and reduce the overheads. So what you have in my blog is my thoughts on it, other people will most definitely differ. I'm a big fan of developer's choice, and that's why I did the smorgasboard approach even though I personally would never use some of those implementations.
    Also this video on GWT is an awesome reference on GUI design patterns: http://www.youtube.com/watch?v=PDuhR18-EdM
    JFX Flow draws a lot from GWT as I think it is a very clean architecture (just such a shame that they put all that effort into hiding the horrid, sordid mess that is the web+html+css, instead of making something proper, like JFX).
    Hope that helps,
    zonski

  • Best Practice to fetch SQL Server data and Insert into Oracle Tables

    Hello,
    I want to read sqlserver data everry half an hour and write into oracle tables ( in two different databases). What is the best practice for doing this?
    We do not have any database dblinks from oracle to sqlserver and vice versa.
    Any help is highly appreciable?
    Thanks

    Well, that's easy:
    use a TimerTask to do the following every half an hour:
    - open a connection to sql server
    - open two connections to the oracle databases
    - for each row you read from the sql server, do the inserts into the oracle databases
    - commit
    - close all connections

  • Best Practice for Image placement and Anchored Frames for use in Robohelp 9

    Hi,
    I'm looking for the best practices in how to layout my images in Framemaker 10 so that they translate correctly to Robohelp 9.  I currently have images inside of Anchored frames that "Run into" the right side of my text. I've adjusted the size of the anchored frame so that my text flows correctly around the image. Everything looks good in Framemaker! Yeah! The problem is that when I link my Framemaker document to Robohelp, the text does not flow around my image in the same manner. On a couple of Robohelp screens the image is running into the footer. I'm wondering if I should be using tables in Framemaker in order to get the page layout that I'm looking for. Also, I went back and forth...is this a Framemaker question or is this a Robohelp question. Any assistance would be greatly appreciated.

    I think Jeff is meaning this section of the RoboHelp forums:
    http://forums.adobe.com/community/robohelp/robohelp_framemaker

Maybe you are looking for

  • Index file won't update on server

    I have changed &amp;amp; uploaded mjy index.html file many, many times with no problem. Now I have another update &amp;amp; when I upload it with either Dreamweaver or GoDaddy's FTP it does not update the file...even though I get no error message. I

  • Connecting my Macbook to an LG t.v

    I'm interested in connecting my computer to my L.G tv... The TV model is LH 20 and I have a black macbook with mac os x 10.6.2. I have done a quick internet search on which cords I should buy to do this and I have come across a few articles saying th

  • Word insert pdf object problem

    Adobe 8.1 and Word 2003 sp3 are installed on XP64 box. From word, when we do insert > object > Adobe Acrobat Document (Create New) we get the error: This object was created in AcroExch. This application is not available to open this object. Make sure

  • Recently Changed Items web part line spacing

    I have this web part setup and it looks great except that it has extra space between each line. The options for changing this in the web part properties are: Diagnostic Large Picture Two Lines Videos (the other options include pictures)

  • How compare 2 dates

    hello i need compare 2 dates and fird difference between them for example 30 september and 1 october difference = 1 day how i can make it ? compareTo(Date) make it something else here is code import java.util.*; import java.text.*; public class DateW