JDAF Session based application

This forum is used by users to request and discuss new product features. Please do not use this forum for technical support including bug reports.

Moderator: JIDE Support

Forum rules
Product suggestions only. Please do not use this forum for technical support including bug reports.

JDAF Session based application

Postby RGogolin » Tue Jul 31, 2007 9:35 pm

I have been trying out JDAF and I've got to say I love the idea of a desktop application framework. For the past couple of days I've been using the framework I find it intuitive and very useful.

Still I feel there is one glaring omission that I would love to see and I think would be a valuable addition to JDAF. For lack of a better term, session based applications. I am thinking of corporate based applications that have a central server application layer.

A couple of things typically characterises desktop applications that are a client to server application layer:
1) A user must sign in / out to establish a session. The current JDAF application lifecycle only considers application opened and closed; it would be neat to also have signed in and signed out.
2) Apart from a menu and toolbar the UI typically contains a navigator tailored to the user. Eg. List of their jobs, Pending Claims ect. A session based application tends to be a combination of a session bound navigator and the document approach. The current JDAF application controller is very document centric - building a navigator would be outside the framework which is a shame.
3) Some displayed data is entirely server controlled, such as the navigator’s data. I guess this would be like a read-only data model. But to go a bit further, rather than just calling updateView(model) every time we refresh the data model it would be neat to have the framework recognise when the data model has been updated with new data with an event to recognise this and only call updateView(mode) when new data is received. Because of JDAF’s document centric nature the using the current DataModel would have unintended consequences for this scenario.

To me file based applications are for consumers, where as session based applications are typically corporate applications often in-house; and I would have thought corporate in-house development efforts are JIDE's main source of sales.
RGogolin
 
Posts: 2
Joined: Wed May 23, 2007 12:39 am

JDAF Session based application

Postby JDAF Support » Wed Aug 01, 2007 7:49 am

Thanks for taking the time to explore the JDAF. Please allow us to comment and clarify some concepts:

First, there is nothing stopping one from creating a Session-based application using JDAF. The plethora of adapters, listeners, cutomizers, and integration features for our other products, are explicitly intended for developers to implement the functionlity you describe. We currently only provided one specialized application type, the FileBasedApplication, due to the significant challenges this type of application causes for cross-platform developers. Perhaps this influenced your conception of the product.

To be clear, our initial release provides a foundation from which many different types of applications can be built, and we plan on using JDAF as a platform for releasing other application types. Concerning the characteristics you have outlined, here are some suggestions for acheiving this:

>> 1) A user must sign in / out to establish a session. The current JDAF application lifecycle only considers application opened and closed; it would be neat to also have signed in and signed out.

If the user can only open a single session, the ApplicationLifecycleListener is perfect. It is intended to allow you to provide this very functionality using the applicationOpening() event. If multiple-sessions are appropriate, the DataModelListener can trap each newData() event and provide a log-in there. In either case, you may throw an ApplicationVetoException to have the framework reject the user.

Also, don't get hung up on the Action names. "New" could just as easily be changed to say "New Session". Simply change the name in NewAction or OpenAction and set the criteria that is appropriate for your DataModel. Normally a new DataModel is opened by default so you could even remove these commands from the menus (See MenuBarCustomizer) if there where no need to have different kinds of sessions.

>> 2) Apart from a menu and toolbar the UI typically contains a navigator tailored to the user, Eg. List of their jobs, Pending Claims ect. A session based application tends to be a combination of a session bound navigator and the document approach. The current JDAF application controller is very document centric - building a navigator would be outside the framework which is a shame.

Building a navigator is not outside the framework. It is integrated by the use of the JIDE Docking Framework. You simply set useJideDockingFramework() option to true, and use a DataViewListener to create DockingFrames with the content you desire. For example:

Code: Select all
application.getApplicationUIManager().setUseJideDockingFramework(true);       
application.addDataViewListener(new DataViewAdapter() {
  public void dataViewOpening(DataViewEvent e) {
      DockableHolder holder = (DockableHolder)e.getWindow();
      if(holder.getDockingManager().getFrame("title") == null) {
          DockableFrame dockableFrame = new DockableFrame("title");
               dockableFrame.setInitMode(DockContext.STATE_FRAMEDOCKED);
                 dockableFrame.setInitSide(DockContext.DOCK_SIDE_SOUTH);
          holder.getDockingManager().addFrame(dockableFrame);
      }
  });


DataViews are reserved manage the users data, hence you get exactly your prescription for "a combination of a session bound navigator and the document approach".

In addition, FileBasedApplication is actually just a usability interface. The FileHandlingFeature actually is the culprit that adds file-handling to the application (what you are identifying as Document-Centric behavior). Therefore, you could use/subclass GUIApplication, and implement your session-based application. And if you needed to allow the user to access the File system, just plug-in a FileHandlingFeature, to get the best of both worlds.

>> 3) Some displayed data is entirely server controlled, such as the navigator’s data. I guess this would be like a read-only data model. But to go a bit further, rather than just calling updateView(model) every time we refresh the data model it would be neat to have the framework recognise when the data model has been updated with new data with an event to recognise this and only call updateView(mode) when new data is received. Because of JDAF’s document centric nature the using the current DataModel would have unintended consequences for this scenario.

JDAF is Data-Centric not Document-centric. As mentioned above, use the DockingFramework and apply your server logic to a normal Swing component. DataModel is intended for the users data, i.e. that which you would normally place in the docking managers Workspace, not for the DockingFrame contents. Develop docking frames as you have done in the past.

>> it would be neat to have the framework recognise when the data model has been updated

Use a DataModelListener (dataSaving(), dataSaved() events). These are called from application saveData().

Also, concerning attributes of a session-based application there is another more fundamental attribute; they tend to be DB-sourced. If you implement your own DataModel (subclass AbstractDataModel recommended) you can implement how your data is stored to/from a DB as well. See the OpenAction and the idea of "criteia" as parameters to how a DataModel is selected. As "criteria" you could use a query string or even a ResultSet. It pretty wide open.

Hope this helped to clarify some things for you and I hope you will continue to explore JDAF. We are always developing and improving, and to reiterate, more specialized application types are a planned extension to this platform. You comments have helped our focus. Thanks.
JDAF Support
 
Posts: 637
Joined: Mon Jul 23, 2007 4:52 am

Re: JDAF Session based application

Postby RGogolin » Wed Aug 01, 2007 8:09 pm

JDAF Support wrote:First, there is nothing stopping one from creating a Session-based application using JDAF. The plethora of adapters, listeners, cutomizers, and integration features for our other products, are explicitly intended for developers to implement the functionlity you describe. We currently only provided one specialized application type, the FileBasedApplication, due to the significant challenges this type of application causes for cross-platform developers. Perhaps this influenced your conception of the product.


Agreed, and I am trying that at this moment. I probably termed it the wrong way, its not an ommission of the the framework at all its an opportunity. I've been prototyping the usage of JDAF for a session based application in a similar way to your comments with pretty good success so far. Perhaps all that is needed, at some time in the products life amoungst other priorities, is an example.
RGogolin
 
Posts: 2
Joined: Wed May 23, 2007 12:39 am

Postby JDAF Support » Thu Aug 02, 2007 6:05 am

Point well taken. As a matter of fact, we found ourselves reviewing the developer guide after that post and wondering how best to illustrate the possibilites. There are so many variences possible for a session-based application because there really is no set standard, unlike file-based apps which have a fairly standard work-flow.

I noticed we do talk abstractly about using a db for DataModels and of coarse we offer suggestions when talking about the app lifecycle like authentication, but I can see clearly that we need something more concrete, as you suggested. For example, something similar in scope to "PlainTextEditor", but session-based, like "SimpleSessionBrowser" or something. Perhaps it could connect to a small-footprint db, have a docking framework with say some data in a tree navigator, open DataModels from the tree nodes, and allows adding and editing of the data. My primary concern with this type of demo is 1) making the code too verbose with non-JDAF issues. 2) setting precedents; there are lots of ways to do things.

What do you think? We're open for suggestions, anyone.
JDAF Support
 
Posts: 637
Joined: Mon Jul 23, 2007 4:52 am

Re: JDAF Session based application

Postby mszeles » Tue May 05, 2009 6:58 am

Is this new kind of example application exist at the moment? I also would like to implement a session based application and an example JDAF program/tutorial would be really helpful.
mszeles
 
Posts: 54
Joined: Wed Apr 22, 2009 7:34 am

Re: JDAF Session based application

Postby JDAF Support » Tue May 05, 2009 7:53 am

Since that post was made we have added demos providing kind of a split application style. Check out "SplitCodeEditor" It's provides a basic tree. "DockedTextEditor2" uses the docking framework. Theses could get you started. Still no direct DB support. Very difficult to determine how to do this in a way that makes sense. But we have the AddressBook DB demo as well.
JDAF Support
 
Posts: 637
Joined: Mon Jul 23, 2007 4:52 am

Re: JDAF Session based application

Postby mszeles » Wed May 06, 2009 6:04 am

I think the problem is not with split or not split application type. Both of the examples are also file based and not seession based examples. The problematic part for me is that it is hard to decompose/migrate a system which is not file based since all the examples are filebased where you have one thing to work with: a file. Let's try first with a simple case. I have a login form. It asks for a username and password and then connects to a server. How should I decompose this according JDAF rules? I think I should change JPanel to DataViewPane. And what will be the DataModel? A class with two properties(username and password)? What should it do with newData, openData,....
An example like this would be really helpful.
Thanks in advance
mszeles
 
Posts: 54
Joined: Wed Apr 22, 2009 7:34 am

Re: JDAF Session based application

Postby JDAF Support » Wed May 06, 2009 7:18 am

Both of the examples are also file based and not seession based examples.


We're back to my fundimental problem...and why we've never produced an example: What exactly is a "Session Based" application? It seems to mean different things to different people. Whether it works with files or not I don't think is a determiner. Othewr users seem to think that Eclipse and other RCP's are examples. The fact is, a JDAF app could work with a combination of files, db, network, or whatever. That is simple a matter of your factories (DataModelFactory).

Let's try first with a simple case. I have a login form. It asks for a username and password and then connects to a server.


Just a point in fact before I answer this; an app with a login, does not mean it cannot be file-based....it just requires authorization to get in.

How should I decompose this according JDAF rules? I think I should change JPanel to DataViewPane. And what will be the DataModel? A class with two properties(username and password)? What should it do with newData, openData,....




In JDAF DataModels/DataViews are intended to provide a "lifecycle" for application data (origination->modification->persistence). Models and Views are connected to a data-lifecycle, which includes the menuing/action subsystem as well as the windowing subsystem, both of which are OS-depenedent, and not something that Swing does for you by default, as well as providing different UI-styles.

So in JDAF, dialog's fit into a different MVC data-cycle. Often, In JDAF dialog's introduce data whose results are used to create Models and Views, as opposed to being models and views themselves. For dialogs you have have the DialogRequest (model) and any standard Component (view). We have a special JPanel extention called DialogPane, which provides methods that are convenient to a dialogs lifecycle (init, update, validate, commit).

I recommend you:
1) Convert your panel into a subclass of DialogPane, and move your logic to the appropriate methods:
- initComponents() should setup your UI pane
- updateComponents() can be empty unless you have a reason to update cached data.
- validateComponents() would do the authorization logic, throwing a ApplicationVetoException if the auth is bad.
- commitComponents() would create a User object with the values (your class) and set them as the "value" of the DialogResponse. (which is passed to the dialog caller.)
2) Register a ApplicationLifecycleListener that uses the applicationOpening() method to send this view via a StandardDialogRequest.showDialog("Please Login", myLoginPane).
3) Using DialogResponse.isOK(), you could then get your User and store in your app, or if not ok, throw a ApplicationVetoException from the applicationOpeneing(), which will exit the app.

AS a further exercise, you could wrap this all up into a reusable ApplicationLifecycleListenr, or better yet, an ApplicationFeature that could then be reused in any JDAF app.
JDAF Support
 
Posts: 637
Joined: Mon Jul 23, 2007 4:52 am

Re: JDAF Session based application

Postby mszeles » Wed May 06, 2009 7:29 am

Thank you for your quick reply. I'll check it and return back with my results soon.
mszeles
 
Posts: 54
Joined: Wed Apr 22, 2009 7:34 am

Re: JDAF Session based application

Postby mszeles » Wed May 20, 2009 2:03 am

I made the changes to login dialog. Now it works without a problem. I have another question: How can I migrate the following component. It' a component which contains a JTree, and display some custom data using the DefaultTreeDataModel and a custom TreeCellRenderer. The data is read from an XML file(or simply comes from the memory, becuase it has been read previously). With the view part I think I only have to modify my component to extend DataViewPane instead of JPanel. Unfortunatelly I don't exactly know how to "JDAFize" the data model part. Can you exlpain it to me?
Thanks in advance,
mszeles
 
Posts: 54
Joined: Wed Apr 22, 2009 7:34 am

Re: JDAF Session based application

Postby JDAF Support » Wed May 20, 2009 7:04 am

I made the changes to login dialog. Now it works without a problem.


Cool!

With the view part I think I only have to modify my component to extend DataViewPane instead of JPanel.


Correct. Should be fairly painless. I recommend checking out the FileSystemDataView (used in the SplitCodeEditor demo). It uses a tree. While the tree is based on a the underlying file system, it should give you a clear idea what to do. You would use updateView() to move the xml into your tree. Let's pretend you call it SessionTreeDataView.

the data is read from an XML file (or simply comes from the memory, becuase it has been read previously)....Unfortunatelly I don't exactly know how to "JDAFize" the data model part. Can you exlpain it to me?


Sure. JDAF actually can manage the model for you an just serve the xml to your DataView.

1) Create a FileHandleFeature. (unless you extended from FileBasedApplication, in which case you can use the usability methods in the app)

Code: Select all
FileHandlingFeature fileHandling = new FileHandlingFeature();


2) Add a file format mapping to bind xml files to your SessionTreeDataView.

fileHandling.addFileMapping(new XMLFileFormat("xml", "XML"), SessionTreeDataView.class);


3) Add to the application

Code: Select all
application.addFeature(fileHandling);


In your SessionTreeDataView you would create the tree like:

Code: Select all
public void updateView(DataModel dataModel) throws DataModelException {
   Document dom = (Document)((FileDataModel)dataModel).getData();   
   TreeModel model = new MyXMLTreeModel(dom);
   tree.setModel(model);
}


4) Finally, we need to install the view along the side of the window. I don't know if your using JIDE Docking Framework or not. If not, you would use the FramedApplicationFeature, which provides a infrastructure that creates peripheral panes around the primary workspace. If so, just swap to the DockingApplicationFeature.

Code: Select all
FramedApplicationFeature frameFeature = new FramedApplicationFeature();
application.addApplicationFeature(frameFeature);
frameFeature.addFrameMapping("Session", SplitApplicationUI.WEST, // title and position
                                        SecondaryFileDataModel.class, // the DataModel implementation to use
                                        SessionTreeDataView.class,  // your view
                                        new File("tree.xml")); // the xml file


You may want to set these application optons as well:

Code: Select all
// application settings
application.setExitApplicationOnLastDataView(false);
application.setNewDataOnRun(false);
ApplicationWindowsUI windowsUI =  application.getApplicationUIManager().getWindowsUI();
windowsUI.setPreferredWindowSize(windowsUI.getPreferredMaximumWindowSize());


That should get you started. Its been a pleasure talking to you. I hope it works out, and Iook forward to continuing my discussion with you as a customer!
JDAF Support
 
Posts: 637
Joined: Mon Jul 23, 2007 4:52 am

Re: JDAF Session based application

Postby mszeles » Thu May 21, 2009 12:56 am

Thanks for the reply.
Unfortunatelly I have some problems. First of all, I can't assign SessionTreeDataView to xml files, since I use several XML files to confgiure different aspects of the application.
I use an appliction created with the JDAF designer, as a base of my application. It uses JIDE docking framework:
application.getApplicationUIManager().setUseJideDockingFramework(true);
application.getApplicationUIManager().getWindowsUI().addWindowCustomizer(new WindowCustomizer() {
public void customizeWindow(ApplicationWindowsUI windowsUI, Container window) {
if(windowsUI.getApplicationUIManager().isUseJideDockingFramework()) {
DockableHolder holder = (DockableHolder)window;
installDockableFrames(holder);
}
}
public void disposingWindow(ApplicationWindowsUI windowsUI, Container window) {
}
});
IS this okay, or should I use the mentined dockings.

The designer also created code like:
application.addDataModelFactory(new BasicDataModelFactory());
application.addDataViewFactory(new BasicDataViewFactory(ApplicationView.class));

// -- Manage your data --
// Register a listener to manage each DataModel instance
application.addDataModelListener(new DataModelAdapter() {
// Call e.getApplication().setData() with whatever data your using
public void dataModelInitialized(DataModelEvent e) {
// handle "New" here
}

// implement other methods as desired
});
Should I modify this code? I mean I have the main application which has a view called ApplicationView. Shouldn't I have a data model for this view? And how should I handle the relationship between my applicaion's view/model and different component's view/model. Since the application's view/model consist of the view/model of the components. Should I create factory for every model and view and add it to the application using application.addDataModelFactory and application.addDataViewFactory

Sorry for the too much question, but I really like JIDE/JDAF and I want to understand every aspect to use it the proper way. I'm sure I will become a customer very soon.
mszeles
 
Posts: 54
Joined: Wed Apr 22, 2009 7:34 am

Re: JDAF Session based application

Postby JDAF Support » Thu May 21, 2009 8:32 am

I use an appliction created with the JDAF designer:


Ok first, for what you are doing, I do not recommend using the default application from the designer wizard. Toss it. What you want is very specific and the wizard does not really get you where you want to be.

As I mentioned in the previous post, I recommend you follow the pattern of SplitCodeEditor, from an architecture standpoint (Tree on the side, main workspace in the center). Now, SplitCodeEditor uses FramedApplicationFeature. If you want docking, you "should" be able to literally swap the FramedApplicationFeature for the DockingApplicationFeature. (Please check out DockedTextEditor2 to see further examples of using DockingApplicationFeature.)

I can't assign SessionTreeDataView to xml files, since I use several XML files to confgiure different aspects of the application...


Not knowing what "different aspects of the application" you are referring, for a proof of concept I recommend choosing a file that will facilitate your tree and using that for now.

Now. I do want you as a customer. But aplication development is complicated and posting is not the best way to handle this scope of a question. So, this is the best I can do for you, without getting into some consulting time:

JDAF Crash Coarse: :)
    - The criteria argument in JDAF is passed into the application to originate DataModels via openData(criteria) or newData(criteria) (criteria > DataModelFactory > DataModel). You define DataModelFactory and DataModel. This criteria object is of your making. It can be any POJO; a String or a complex Object, whatever.

    - DataModels then originate DataViews (DataModel > DataViewFactory > DataView). You define DataViewFactory and DataView.

    - This results in an association between the model and view in the application. (getDataModel(dataView), getDataView(dataModel)).

    - In the case of GUIApplication, installation into the UI depends on a) the application style and b) primary status of the DataModel.
    a) DataModel.isPrimary() == true results in DataView installed according to the application style (in a prominent position - window (SDI), workspace (Docking), a tab (TDI), etc.) Primary data is used by the menuing items New, Open, Save, etc, window navigation, etc.
    b) DataModel.isPrimary() == false (also called secondary model) requires the developer to provide DataView installation. This is done by providing a DataViewHandler, installed into the ApplicationUIManager.

JDAF comes with many implementations ready for you to reuse. JDAF also comes with ApplicationFeatures (reusable plug-ins) that minimize certain tasks (and are also a great way to develop modularly).

For example, the FileHandlingFeature sets up an infrastructure with special DataModelFactories and DataViewFactories that automatically create DataModels (FileDataModels) by capitalizing on the java.io.File object as criteria (or a string resolvable to a file type). It uses various FileFormat handler objects to automatically read/write data to the DataModel on openData() and saveData().

Another example are the FramedApplicationFeature and the DockingApplicationFeature (later requires Docking Framework jar). These provide infrastructure that routes secondary DataModels to auxiliary UI positions such as side frames or docking frames, respectively, based on the criteria.

Now...

Concerning your multiple xml files, you don't have to use FileHandlingFeature. You could present whatever criteria you want into the Frame/Docking mapping as criteria so that when MyDataModel.openData(yourCriteria) is called, you can do whatever....create from memory, read from multiple files (using the FileFormat objects manually as helpers)...whatever. In your model's openData() method call setData(myResultingDataBasedonMyCriteria). When the view is installed (thanks to the docking or framed feature) you will be passed your DataModel from which you can synchronize your view/tree.

Session-Based App Summary:

1) Choose appropriate GUIAppication architecture:
Use Docking/FramedApplicationFeature. (FramedApplicationFeature requires SPLIT_APPLICATION_STYLE in GUIApplication)

2) Create bootstrap criteria for app:
Create some kind of object that can be used to designate your multiple xml files as criteria.

3) Create a DataModel (for nav bar):
Subclass BasicSecondaryDataModel (important because you need to handle construction of your data. "Secondary" DataModel status is important so that it is not considered primary and routes to a side UI). Override BasicSecondaryDataModel.openData(creteria)... use your criteria to load in your tree data from your various xml files. Call setData() with the data you want the dataview to see.

4) Create a DataView (for nav bar):
Create your SessionTreeDataView as previously discussed. Implement updateView(dataModel) to access the data in your BasicSecondaryDataModel. FileSystemDataView will give you some hints on tree handling that will open new DataModels/DataViews.

5) Install into application:
Add a framed or docking mapping in the framed/docking feature. The feature sets up DataModelFactories and DataViewFactories to facilitate binding all this together.

6) Support for data/views in the workspace area
Finally, create more DataModels and DataViews and install respective DataModelFactories and DataViewFactories to originate them based on criteria from your tree, when the user clicks. (See FileSystemDataView). Note: Do not use BasicDataModelFactory and BasicDataViewFactory in your GUIApplication at this point as these are for one-off apps that always produce the same model and view.

I hope this helps. With an investment in the doc I think you could do the rest.
JDAF Support
 
Posts: 637
Joined: Mon Jul 23, 2007 4:52 am


Return to Product Suggestions

Who is online

Users browsing this forum: No registered users and 16 guests

cron