Best practice to create views

Hi,
I've a question about best practice to develop a large application with many complex views.
Typically at each time only one views is displayed. User can go from a view to another using a menu bar.
Every view is build with fxml, so my question is about how to create views and how switch from one to another.
Actually I load fxml every time the view is required:
FXMLLoader loader = new FXMLLoader();
InputStream in = MyController.class.getResourceAsStream("MyView.fxml");
loader.setBuilderFactory(new JavaFXBuilderFactory());
loader.setLocation(OptixController.class.getResource("MyView.fxml"));
BorderPane page;
try {
     page = (BorderPane) loader.load(in);
     } finally {
          if (in != null) {
               in.close();
// appController = loader.getController();
Scene scene = new Scene(page, MINIMUM_WINDOW_WIDTH, MINIMUM_WINDOW_HEIGHT);
scene.getStylesheets().add("it/myapp/Mycss.css");
stage.setScene(scene);
stage.sizeToScene();
stage.setScene(scene);
stage.sizeToScene();
stage.centerOnScreen();
stage.show();My questions:
1- is a good practice reload every time the fxml to design the view?
2- is a good practice create every time a new Scene or to have an unique scene in the app and every time clear all elements in it and set the new view?
3- the views should be keep in memory to avoid performace issue or it is a mistake? I think that every time a view should be destroy in order to free memory.
Thanks very much
Edited by: drenda81 on 21-mar-2013 10.41

>
>
My questions:
1- is a good practice reload every time the fxml to design the view?
2- is a good practice create every time a new Scene or to have an unique scene in the app and every time clear all elements in it and set the new view?
3- the views should be keep in memory to avoid performace issue or it is a mistake? I think that every time a view should be destroy in order to free memory.
In choosing between 1 and 3 above, I think either is fine. Loading the FXML on demand every time will be slightly slower, but assuming you are not doing something unusual such as loading over a network connection it won't be noticeable to the user. Loading all views at startup and keeping them in memory uses more memory, but again, it's unlikely to be an issue. I would choose whichever is easier to code (probably loading on demand).
In choosing between reusing a Scene or creating a new one each time, I would reuse the Scene. "Clearing all elements in it" only needs you to call scene.setRoot(...) and pass in the new view. Since the Scene has a mutable root property, you may as well make use of it and save the (small) overhead of instantiating a new Scene each time. You might consider exposing a currentView property somewhere (say, in your main controller, or model if you have a separate model class) and binding the Scene's root property to it. Something like:
public class MainController {
  private final ObjectProperty<Parent> currentView ;
  public MainController() {
    currentView = new SimpleObjectProperty<Parent>(this, "currentView");
  public void initialize() {
    currentView.set(loadView("StartView.fxml"));
  public ObjectProperty<Parent> currentViewProperty() {
    return currentView ;
  // event handler to load View1:
  @FXML
  private void loadView1() {
    currentView.set(loadView("View1.fxml"));
  // similarly for other views...
  private Parent loadView(String fxmlFile) {
    try {
     Parent view = FXMLLoader.load(getClass().getResource(fxmlFile));
     return view ;
    } catch (...) { ... }
}Then your application can do this:
@Override
public void start(Stage primaryStage) {
   Scene scene = new Scene();
   FXMLLoader loader = new FXMLLoader(getClass().getResource("Main.fxml"));
   MainController controller = (MainController) loader.getController();
   scene.rootProperty().bind(controller.currentViewProperty());
   // set scene in stage, etc...
}This means your Controller doesn't need to know about the Scene, which maintains a nice decoupling.

Similar Messages

  • BEST PRACTICES FOR CREATING DISCOVERER DATABASE CONNECTION -PUBLIC VS. PRIV

    I have enabled SSO for Discoverer. So when you browse to http://host:port/discoverer/viewer you get prompted for your SSO
    username/password. I have enabled users to create their own private
    connections. I log in as portal and created a private connection. I then from
    Oracle Portal create a portlet and add a discoverer worksheet using the private
    connection that I created as the portal user. This works fine...users access
    the portal they can see the worksheet. When they click the analyze link, the
    users are prompted to enter a password for the private connection. The
    following message is displayed:
    The item you are requesting requires you to enter a password. This could occur because this is a private connection or
    because the public connection password was invalid. Please enter the correct
    password now to continue.
    I originally created a public connection...and then follow the same steps from Oracle portal to create the portlet and display the
    worksheet. Worksheet is displayed properly from Portal, when users click the
    analyze link they are taken to Discoverer Viewer without having to enter a
    password. The problem with this is that when a user browses to
    http://host:port/discoverer/viewer they enter their SSO information and then
    any user with an SSO account can see the public connection...very insecure!
    When private connections are used, no connection information is displayed to
    SSO users when logging into Discoverer Viewer.
    For the very first step, when editing the Worksheet portlet from Portal, I enter the following for Database
    Connections:
    Publisher: I choose either the private or public connection that I created
    Users Logged In: Display same data to all users using connection (Publisher's Connection)
    Users Not Logged In: Do no display data
    My question is what are the best practices for creating Discoverer Database
    Connections.
    Is there a way to create a public connection, but not display it in at http://host:port/discoverer/viewer?
    Can I restrict access to http://host:port/discoverer/viewer to specific SSO users?
    So overall, I want roughly 40 users to have access to my Portal Page Group. I then want to
    display portlets with Discoverer worksheets. Certain worksheets I want to have
    the ability to display the analyze link. When the SSO user clicks on this they
    will be taken to Discoverer Viewer and prompted for no logon information. All
    SSO users will see the same data...there is no need to restrict access based on
    SSO username...1 database user will be set up in either the public or private
    connection.

    You can make it happen by creating a private connection for 40 users by capi script and when creating portlet select 2nd option in Users Logged in section. In this the portlet uses there own private connection every time user logs in.
    So that it won't ask for password.
    Another thing is there is an option of entering password or not in ASC in discoverer section, if your version 10.1.2.2. Let me know if you need more information
    thnaks
    kiran

  • Best practice to create multi tier (atleast 3 level) table

    What is the best practice to create multi tier (minimum 3 levels) of table?. Could any one provide a sample structure?.
    Thanks.

    Can u b more specific as to what you are trying to do. What u mean by 3 level table?

  • What are the best practices to create surrounding borders?

    Good day everyone,
    I was wondering what is the best practices to create a look in my iOS app like the one below? How are they accomplishing the creation of the borders, is there a tool in Xcode IB to do that?
    Thank you in advance

    Once again thanks for your input, however I am still not clear how you have accomplish the rounded corners, you do not mention that in your reply.
    I did some research on my end and I was able to accomplish what I want with a UIView using the code below in an outlet:
    redView.layer.cornerRadius = 10;
    redView.layer.borderColor = [UIColor greenColor].CGColor;
    redView.layer.borderWidth = 5;
    However, I cannot do the same for the UITableView or UITableView cell.
    Thanks

  • Best practice to create Voyager conn on SAP BI INFOCUBE OR  SAP BI Query

    I wanted to know which is the best practice to create a Voyager connection on SAP BI Infocube or SAP BI  Query?
    which is gud for more performance?

    Hi Nirmansyah,
    Please check the below link.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/business-intelligence/s-u/step-by-step%20procedure%20for%20creating%20customized%20bex%20maps.pdf
    Hope this helps.
    Veerendra.

  • Best practice to create a database

    please can you send me the best practice to create a database which is want to be used in the future for a dataware house

    Hi,
    For Dataware housing purpose only means you can create the database by using DBCA. or for only transctional purpose means you can create manyally. like create control file , datafiles and all.
    Thanks and Regards
    Venkat.K.Raju
    Mindlance,
    Oracle Applications Team
    BANGLORE..66
    Mobile:+919986556688
    Land:080-41464843 Ext-4942
    [email protected]

  • Best practice to create users - Hybrid scenario

    I would like to know what is the best practice for creating new users in a Hybrid scenario with all mailboxes hosted and no mailboxes on-premise.
    Currently when creating a new user we go to our local EMC and create a 'New Remote Mailbox'.  This creates the mailbox in Office365 and the local user account in one wizard.
    After the new user is created we have to manually add the user to the correct distribution groups, and security groups.
    We would like a way to create new users using a template which already has the correct distribution groups and security groups.  This is how we did it prior to setting up the Hyrbrid scenario.
    Is this possible?  Can we create a user from a template and have the mailbox created in Office365 at the same time?  We do not wish to create the mailbox locally then migrate it.

    Thanks for the response DJStatik.  I think this tool might be useful for creating users in bulk, however we are looking for a user template in the traditional sense.
    Occasionally we have a new user and (prior to O365) would 'copy' the template user to ensure correct groups etc.
    We have tried making users from the existing template we have, but in order to create the mailbox in O365, you need to 'mail enable' the user.  We have noticed that doing this process causes issues with Autodiscover for that particular user.
    To avoid the autodiscover issue, we have found it best to create the user and the mailbox in the same wizard - hence our new process that we would like a template.

  • Best practices to create Universe on top of SAP BW

    Hi Experts,
    I would like to know the Best Practices for Creating Universe on top of SAP BW.
    1. is it advisable to create Universe on top of SAP BW CUBE directly. in my case , we are starting a fresh BW implementation for one application on SAP BI.7 ; and BOE 3.1
    2. if we create a universe on top of BEX Query, what need to be done if want to upgrade to Business Objects 4.0 version.
    3. if we create a universe on BEX Query, will  SAP is going to support  universe on BEX for future releases.
    4. what is the support period for BEX and its integration with Business objects.
    Thanks
    Bhnau.

    Hi,
    1. is it advisable to create Universe on top of SAP BW CUBE directly. in my case , we are starting a fresh BW implementation for one application on SAP BI.7 ; and BOE 3.1
    First go through by below link.This guide describe how you can create universe based on Cube and Query and what features are available via Cube and Query.
    http://help.sap.com/businessobject/product_guides/boexir3/en/xi3_sap_olap_universes_en.pdf
    You can check on the Page 12 in the PDF what supported by Cube and BW Query while designing of a universe.
    Best practices says to design universe on top of one generic query for one Cube because CFK,RFK can not generate in the universe on top of BW Cube.
    2. if we create a universe on top of BEX Query, what need to be done if want to upgrade to Business Objects 4.0 version.
    check below links.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c0d937fa-1261-2e10-6388-e71afb6b5ff6?quicklink=index&overridelayout=true
    http://biguru.wordpress.com/
    Thanks,
    Amit

  • Best Practices for creating reports/Dashboards from BW systems

    HI Gurus,
    Best  Practices of creating BO Dashboards / Xcelsisus from BW systems
    Prasad

    You can use the BICS connector that leverages BW queries directly.  It is listed in the Connection Manager as "SAP NetWeaver BW Connection".  You will need both the ABAP and Java stack and SSO configured between the two.  You will also need to have SAP GUI and BEx installed on the machine you are doing development on.  Note that dashboards using this connection can only be hosted in NW Portal for the time being until the next release of BI 4.x platform.
    Here are some links on getting started with the BICS connector:
    [Building Fast and Efficient Dashboards with BW and Xcelsius|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/d0ab8cce-1851-2d10-d5be-b5147a651c58]
    [Requirements for BICS|http://wiki.sdn.sap.com/wiki/display/BOBJ/prerequisitestoXcelsiusandSAPNetWeaverBW+Connection]

  • Best practice for creating JCO destinations

    Hi All,
       I have a project which uses 10 to 12 BAPIs.What is the best practice
      1) Create 10 JCO destinations one for each BAPI .
      2) Create one JCO and use it for all BAPIs.
         Can some one tell me what is the best practice.What are the advantages and the disadvantages.
    Regards,
    Rajini.

    Hi,
    these docs helps you to get idea over the jco best practices.
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/705f2b2e-e77d-2b10-de8a-95f37f4c7022
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/85a483cb-0d01-0010-2990-c5168f01ce8a
    Regards,
    ramesh

  • Looking for best practices when creating DNS reverse zones for DHCP

    Hello,
    We are migrating from ISC DHCP to Microsoft DHCP. We would like the DHCP server to automatically update DNS A and PTR records for computers when they get an IP. The question is, what is the best practice for creating the reverse look up zones in DNS? Here
    is an example:
    10.0.1.0/23
    This would give out IPs from 10.0.1.1-10.0.2.254. So with this in mind, do we then create the following reverse DNS zones?:
    1.0.10.in-addr.arpa AND 2.0.10.in-addr.arpa
    OR do we only create:
    0.10.in-addr.arpa And both 10.0.1 and 10.0.2 addresses will get stuffed into those zones.
    Or is there an even better way that I haven't thought about? Thanks in advance.

    Hi,
    Base on your description, creating two reverse DNS zones 1.0.10.in-addr.arpa and 2.0.10.in-addr.arpa, or creating one reverse DNS zone 0.10.in-addr.arpa, both methods are all right.
    Best Regards,
    Tina

  • Best-practice for Catalog Views ? :|

    Hello community,
    A best practice question:
    The situtation: I have several product categories (110), several items in those categories (4000) and 300 end-users.    I would like to know which is the best practice for segment the catalog.   I mean, some users should only see categories 10,20 & 30.  Other users only category 80, etc.    The problem is how can I implement this ?
    My first idea is:
    1. Create 110 Procurement Catalogs (1 for every prod.category).   Each catalog should contain only its product category.
    2. Assign in my Org Model, in a user-level all the "catalogs" that the user should access.
    Do you have any idea in order to improve this ?
    Saludos desde Mexico,
    Diego

    Hi,
    Your way of doing will work, but you'll get maintenance issues (to many catalogs, and catalog link to maintain for each user).
    The other way is to built your views in CCM, and assign these views to the users, either on the roles (PFCG) or on the user (SU01). The problem is that with CCM 1.0 this is limitated, cause you'll have to assign one by one the items to each view (no dynamic or mass processes), it has been enhanced in CCM 2.0.
    My advice:
    -Challenge your customer about views, and try to limit the number of views, with for example strategic and non strategic
    -With CCM 1.0 stick to the procurement catalogs, or implement BADIs to assign items to the views (I experienced it, it works, but is quite difficult), but with a limitated number of views
    Good luck.
    Vadim

  • Best Practice for creating Excel report from SSIS.

    I have a requirement to create an Excel report on a daily basis which pulls data from SQL. I have attempted to resolve this by creating a stored procedure to save the results in SQL, a template in Excel to hold the graphs & pivot tables and an SSIS package
    to copy the data to the template.
    Problem 1: When the data turns up in Excel it is saved as text rather than numbers.
    Problem 2: When the data turns up in Excel it appends the data rather than overwriting it.
    I resolved problem 1 by having another sheet which converts the text to numbers (=int(sheet1!A1))
    I resolved problem 2 by adding some VB script to my SSIS package which clears the existing cells before copying the data
    The job runs fine, however when I schedule the job to run overnight it complains "System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID". A little googling tells me that running the client side commands in
    my vb script (workSheet1.Range("A2:F9999").Clear(), workBook.Save(), workBook.Close() etc) from a server side task is bad practice.
    So, I am left wondering how people usually get around this problem; copy a SQL table into an existing Excel file and overwrite the data, without having the numbers turn up as text. My requirements are that the report must display pivot charts with selectable
    options and be automatically updated overnight.
    Help appreciated,
    Bish.
    Office 2013 on my PC, Office 2010 on the server, Windows Server 2008R2 Enterprise, SQL Server 2008R2.

    I think that the best practice in case like this is to Link an excel file to a view or directly to a table. So you don't have to struggle with changing template, with overnight packages, etc. If the data are too much complex and the desiderate too excessive
    then I tend to create a Cube and that's it...dashboard, graph and everyone is happy. In your case if the request is not too much try to don't use SSIS but directly build a view and point directly on SQL.
    SSIS is really strong for the ETL, to run some stored procedure too heavy, to use a cut time scheduled, etcetera , etcetera, etcetera...I love it. But sometimes we need to find the easier solutions...
    I hope this post helped you

  • What is the best practice for creating primary key on fact table?

    what is the best practice for primary key on fact table?
    1. Using composite key
    2. Create a surrogate key
    3. No primary key
    In document, i can only find "From a modeling standpoint, the primary key of the fact table is usually a composite key that is made up of all of its foreign keys."
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16579/logical.htm#i1006423
    I also found a relevant thread states that primary key on fact table is necessary.
    Primary Key on Fact Table.
    But, if no business requires the uniqueness of the records and there is no materilized view, do we still need primary key? is there any other bad affect if there is no primary key on fact table? and any benifits from not creating primary key?

    Well, natural combination of dimensions connected to the fact would be a natural primary key and it would be composite.
    Having an artificial PK might simplify things a bit.
    Having no PK leads to a major mess. Fact should represent a business transaction, or some general event. If you're loading data you want to be able to identify the records that are processed. Also without PK if you forget to make an unique key the access to this fact table will be slow. Plus, having no PK will mean that if you want to used different tools, like Data Modeller in Jbuilder or OWB insert / update functionality it won't function, since there's no PK. Defining a PK for every table is a good practice. Not defining PK is asking for a load of problems, from performance to functionality and data quality.
    Edited by: Cortanamo on 16.12.2010 07:12

  • What is the best practice for changing view states?

    I have a component with two Pie Charts that display
    percentages at two specific dates (think start and end values).
    But, I have three views: Start Value only, End Value only, or show
    Both. I am using a ToggleButtonBar to control the display. What is
    the best practice for changing this kind of view state? Right now
    (since this code was inherited), the view states are changed in an
    ActionScript function which sets the visible and includeInLayout
    properties on each Pie Chart based on the selectedIndex of the
    ToggleButtonBar, but, this just doesn't seem like the best way to
    do this - not very dynamic. I'd like to be able to change the state
    based on the name of the selectedItem, in case the order of the
    ToggleButtons changes, and since I am storing the name of the
    selectedItem for future reference.
    Would using States be better? If so, what would be the best
    way to implement this?
    Thanks.

    I would stick with non-states, as I have always heard that
    states are more for smaller components that need to change under
    certain conditions, like a login screen that changes if the user
    needs to register.
    That said, if the UI of what you are dealing with is not
    overly complex, and if it will not become overly complex, maybe
    states is the way to go.
    Looking at your code, I don't think you'll save much in terms
    of lines of code.

Maybe you are looking for

  • Problem with outer jon

    Hi, some performance issue with the query. in the below query is forming px_from and px_to and finally joins together. If i execute the query seperatly both px_from and px_to comes very fast (within 20 secs). But when finally joining between px_from

  • Problem With Double

    I'm executing the code abouve, but I found an error: double d4 = 19.64 + .51; System.out.println(">>d4:" + d4); [out] >>d4:20.150000000000002 // erro

  • Intel iMacs and Bluetooth

    Did all Intel based iMacs ship with bluetooth?

  • Windows 8 - Can I upgrade BIOS without loosing embedded product-key?

    On machines with Windows 8 pre-installed, the product-key is embedded in bios. So... what happens with the product-key if I upgrade Bios? Can I be sure I don't loose the product-key?

  • Flat file transformation to xml with encoding in iso-8859-1

    We have a BPEL process that picks up a flat fle (fixed length), transforms it to xml and emails it. The flat file is in iso-8859-1 (when I look at special characters like e-accent's in hex). The basic transformation that you get from (the wizards) of