Last modified by David Avendasora on 2008/07/01 16:52

Show last authors
1 This tutorial will help you create a single Eclipse/WOLips project that contains both the client- and server-side classes of a WebObjects Java Client project, build both applications and then launch them both.
2
3 You can also create a Java Client application using two separate Eclipse projects. One for the server (a WOLips project), and one for the client (most likely a plain Java project). This will make the separation between client and server much more obvious, but then you will have two Eclipse projects to maintain. The approach described in this tutorial is most appropriate for WebStart based client app distribution.
4
5 1. Create a new WebObjects Application
6 [[image:attach:Picture 9.png]]
7 1. Name it "WebStartJNLPTest" in Eclipse with a package of "your.app"
8 1. {{note title="Note!"}}If you change the Project name or packages, then you'll need to make additional changes in the subsequent steps.{{/note}}Modify the Main.html by adding:
9 1. {{code 0="html" title="Main.html Changes"}}<WEBOBJECT NAME=JavaClientLink>click here</WEBOBJECT>{{/code}}Modify the Main.wod file by adding:
10 1. {{code title="Main.wod Changes"}}JavaClientLink: WOHyperlink {
11 href = javaClientLink;
12 }{{/code}}Modify the Main.java file by adding:
13 1. {{code 0="java" title="Main.java Changes"}}public String javaClientLink() {
14 return WOJavaClientComponent.webStartActionURL(context(), "JavaClient");
15 }{{/code}}Create a WOComponent named "JavaClient".
16 [[image:attach:Picture 11.png]][[image:attach:Picture 10.png]]
17 This WOComponent will be what passes the specifics about your client-side application to WebObjects.
18 1. Modify the JavaClient.html replacing the contents with:
19 1. {{code 0="html" title="JavaClient.html Contents"}}<WEBOBJECT NAME=JavaClientComponent></WEBOBJECT>{{/code}}Paste the following as the contents of the JavaClient.wod file. Feel free to change the applicationName, applicationDescription and vendor parameters to anything you wish.
20 1. {{note title="Note!"}}If you are not creating a Direct To Java Client (D2JC) application, then you will need to replace the applicationClassName parameter (com.webobjects.eogeneration.EODynamicApplication) with the name of your client-side application class. Your non-D2JC client-side Application class **must** subclass EOApplication.{{/note}}If you didn't add an EOModel file to the project when you created it, do it now. Drop any existing EOModel in the Resources directory, or create one from scratch.
21 If you don't specify a client class name for each entity, then WebObjects will automatically use EOGenericRecord as it's class. Once you want to start specifying client-side logic including default values and such, you will need to add the Client Class Name to the Entity in the EOModel, and then setup a new .eogen file in eclipse to generate the client-side classes.
22 1. Add the following frameworks to the project build path:
23 JavaDirectToWeb
24 JavaDTWGeneration
25 JavaEOApplication
26 JavaEOControl
27 JavaEODistribution
28 JavaEOGeneration
29 JavaEOInterface
30 JavaEOInterfaceSwing
31 JavaEOProject
32 JavaEORuleSystem
33 JavaFoundation
34 JavaJDBCAdaptor
35 JavaWebObjects
36 JavaWOExtensions
37 1. {{note title="Note!"}}If you are not creating a D2JC application, then you won't need all of these, but they won't hurt anything either.{{/note}}Create a ClasspathClient.txt file in the root of the project and paste the following as contents: {{code title="ClasspathClient.txt File"}}# ApplicationClass == com.webobjects.eoapplication.client.EOClientApplicationSupport
38 # JDB == jdb
39 # JDBOptions ==
40 # JVM == java
41 # JVMOptions ==
42 APPROOT/WebServerResources/Java/WebStartJNLPTest.jar
43 /System/Library/Frameworks/JavaFoundation.framework/WebServerResources/Java/JavaFoundation.jar
44 WOROOT/Library/Frameworks/JavaEOControl.framework/WebServerResources/Java/JavaEOControl.jar
45 WOROOT/Library/Frameworks/JavaXML.framework/WebServerResources/Java/JavaXML.jar
46 WOROOT/Library/Frameworks/JavaDirectToWeb.framework/WebServerResources/Java/JavaDirectToWeb.jar
47 WOROOT/Library/Frameworks/JavaEOApplication.framework/WebServerResources/Java/JavaEOApplication.jar
48 WOROOT/Library/Frameworks/JavaEODistribution.framework/WebServerResources/Java/JavaEODistribution.jar
49 WOROOT/Library/Frameworks/JavaEOGeneration.framework/WebServerResources/Java/JavaEOGeneration.jar
50 WOROOT/Library/Frameworks/JavaEOInterface.framework/WebServerResources/Java/JavaEOInterface.jar
51 WOROOT/Library/Frameworks/JavaEOInterfaceSwing.framework/WebServerResources/Java/JavaEOInterfaceSwing.jar
52 WOROOT/Library/Frameworks/JavaEORuleSystem.framework/WebServerResources/Java/JavaEORuleSystem.jar
53 WOROOT/Library/Frameworks/JavaWOJSPServlet.framework/WebServerResources/Java/JavaWOJSPServlet_client.jar
54 HOMEROOT/Library/Java
55 LOCALROOT/Library/Java
56 WOROOT/Library/Java
57 /Network/Library/Java
58 WOROOT/Library/Frameworks/JavaVM.framework/Classes/classes.jar
59 WOROOT/Library/Frameworks/JavaVM.framework/Classes/ui.jar{{/code}} This file is only required by the application when it is being launched from within Eclipse.
60 1. Create a Java Client Incremental Builder by following the [[instructions>>doc:documentation.Home.Development Architecture.Java Client.Java Client-WebStart Incremental Build.WebHome]]. This file is needed to make up for the lack of Java Client application building by the WOLips Incremental Builder. It also copies the client launch scripts into the project so that the application will auto-launch when you run it from within Eclipse.
61 1. If you did not setup the Java Client Incremental Builder, then right-click on the javaclientbuild.xml file and select "Run As -> Ant Build"
62 [[image:attach:Picture 12.png]]
63 1. Right-click on the project and select "Run As -> WebObjects Application"
64 [[image:attach:Picture 13.png]]
65 1. Select your.app.Application as the Application class
66 [[image:attach:Picture 14.png]]
67 1. If you want to actually deploy this application, then you will also need to [[modify the build.xml file>>doc:documentation.Home.Development Architecture.Java Client.Java Client-WebStart Distribution Building.WebHome]].
68 This is it. WebStart should automatically download your client application and launch it. If you are creating a D2JC application and did not put an EOModel file in the Resources directory of your project, then you'll see something like this:
69 [[image:attach:Picture 15.png]]
70 If you don't want a D2JC application, then you are on your own for creating the user interface for it. Your client-side application can be a command-line or GUI application. If you want a Swing GUI, then I **highly** recommend Florijan Stamenkovic's [[JBND Framework>>url:http://web.mac.com/flor385/JBND/||shape="rect"]]