wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes Swing and ofbiz (type) frameworks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing and ofbiz (type) frameworks" Watch "Swing and ofbiz (type) frameworks" New topic
Author

Swing and ofbiz (type) frameworks

John Fabiani
Greenhorn

Joined: Dec 20, 2003
Posts: 9
HI,
I'm a newbie - that said here's my question.
Most of the stuff I see in the Java world centers around browser interfaces with servers providing the content (tomcat, J2EE stuff). What I don't understand is how swing code interfaces with these servers. Case in point: there is a free framework (ofbiz) that uses tomcat and has many features all written in Java. But the interface (at least as far as I understand) is a web browser. I don't like the general L&F of a browser and would like to use swing. So with that in mind I have centered my reading (learning) on using swing as my interface to database apps. In my reading (Head first Java) I come understand that there are beans I can create to access data (maybe bizObjects) to work with my swing programs - but I don't understand the difference between my bean and the ones in the framesworks like JBoss or how the swing wigets use the access the JBoss beans. TIA
John


John Fabiani
Phil Chuang
Ranch Hand

Joined: Feb 15, 2003
Posts: 251
Well, all Swing is really responsible for is a GUI - just another option for the front-end of an application. A well-architected application will have a design that permits you to build a Swing GUI application as well as a web browser front-end. The actual business logic of the application should not have any front-end specific code, and be completely independent of Swing or JSP/HTML/etc.
So what's your question again?
John Fabiani
Greenhorn

Joined: Dec 20, 2003
Posts: 9
So if I understand you correctly I can use the framework (OFBiz for example) I just need to understand how to call/use the framework beans? What reading material do you suggest that I read that might explain the general issue of using J2EE servers (I really hope I'm not mixing apple and oranges here) from a swing perpective. TIA
John
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

What Phil says is correct, and to build on that -

Taking a look at the OFBiz framework it looks like it is specifically made for accessing back-end data sources (text files, databases, or EJB) through a web front-end (JSP/servlets). It looks like it needs a web container (like Tomcat) to even run. If it wasn't web specific, you could probably just make custom models in Swing to call OFBiz components. Since it needs a web container, though, you'll need to do something like this -

Run the OFBiz framework in a web-container, along with a controller servlet that simply takes requests and returns data. Don't worry about presentation (i.e. HTML forms, table, etc.), just return the data as an XML file or text data in some format. Have your Swing program request data from the controller servlet by using the java.net.URL class to get a connection to the servlet and send it a request. Parse the response the same as if you are reading a text or XML file to get the data. If your primary data source is a servlet, you're going to have to build your interface kind of like a browser... the data in the models is seen as temporary, and the application uses button presses to 'submit' requests or changes, which tells the application it needs to pull data from the servlet again. You have to worry about your data getting stale, and you can't have the server notify you if data changes, you always have to request all the data you are concerned with.

When you mention JBoss, you probably aren't talking about the same kind of beans. OFBiz probably uses regular JavaBeans (sometimes called POJOs - Plain Old Java Objects) to access the back-end data. JBoss is mainly used to provide EJBs (Enterprise JavaBeans). EJBs are quite different than regular JavaBeans. EJBs are more like the front part of the back-end... they can be thought of like an Object-Oriented wrapper around the actual back-end data. (EJBs also provide a lot more, but I'm just making a short mention of them here.) In this case you would use run JBoss as an EJB container and you would use JNDI to look up the Home interface of the EJB you wanted to get a connection to in your Swing application.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
John Fabiani
Greenhorn

Joined: Dec 20, 2003
Posts: 9
Thanks that helped. I think I understand that servlets are web objects but EJB are different animals. Servlets use the tomcat and EJB's use the JBoss. Is there a better way to get around the servlet issue with swing? Better yet was do you suggest I read to get a better understanding.
John
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

I don't think there's really any good books out there that address both servlets and Swing... usually these two technologies aren't used together. Swing programs usually just operate on local data by loading files or using JDBC to access databases. If a Swing app is client/server, it usually has a custom written server piece that allows the client piece to register for events. This lets the client only get events as changes are made - you can see changes made by other people immediately, and you only have to get what changed - you don't have to make new requests and get all the data you are interested in to make sure it is the same.

In your case, the custom server piece would just be a servlet. I would just work at learning Swing first and make a program based off local XML or text files. Then add some code to request these files from a URL. This shouldn't change the rest of the program any. Then, instead of just putting a static file at that URL, put up a servlet that will dynamically generate the file.
John Fabiani
Greenhorn

Joined: Dec 20, 2003
Posts: 9
thanks - it appears that I was comparing apples to oranges.
John
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Swing and ofbiz (type) frameworks
 
Similar Threads
Error in Loading WAR file
Newbie Question: Java EE vs Tomcat+Hibernate+Struts
Client Accessing EJBs from Different Physical App Servers
Jboss Service
Here is the complete JBoss Config. for EJB