Tuesday October 03, 2006
Generically Setting UI Component Properties in Java Studio Creator - Part 2
This is a follow on to the my blog "
Generically
Setting UI Component Properties in Java Studio Creator".
Based on comments from Alex and other
forum posts, I need to
update the information I gave about generically setting component
properties. My first blog technique will work for a
"postback" situation, that is if you have a button to do some action
then show the same page again. In JSF 1.1, the UIViewRoot
component tree is not built until after the render response.
This means neither Creator nor any other ViewHandler or
PhaseListener can catch the UIViewRoot at the right time on a page that
has not yet been rendered.
I asked a couple JSF experts,
Jayashri Visvanathan
and Matt Bohm about this issue and they proposed another solution. This blog covers that solution.
If you're new to Java Studio Creator, get used to "binding".
Use property binding whenever you possibly can. The JSF
life cycle was designed to support "binding" and it will help you in
cases like this where you feel you need to go around the life cycle.
The solution involves creating properties on the Session Bean to
cover the properties you want to set for multiple components.
As an example, suppose you have a page with multiple "Text Field"s. The page might look like this.
In this example, we want to initialize all the text fields to be
disabled until a certain condition like a user logging in. To
accomplish this we need to create a property on the Session bean to
bind to. So add a property to the Session bean called "
textFieldDisabled". To do this, right-click on the "Session Bean" in the Project window and choose "Add->Property".
Next, add a property of type
boolean called "
textFieldDisabled".
Now that we have a property to bind to, we need to bind all the Text
Fields to this property. To select all the Text Fields, drag a
box around the Text Fields like this.
Now you can change the "Disabled"
property binding for all the selected Text Fields. From the
Property window, click on the "..." next to the "disabled" property.
The property binding dialog will be brought up and you need to
choose "SessionBean1.textFieldDisabled".
Not you can manipulate the same property on all the selected components
from the backing bean code. Open the "Java" view for Page1 and go
to the "prerender" method. Where you actually put the logic to
change the component properties will depend on what you are basing the
change on. If the condition for changing the properties may
changed before each render, you should put the logic in "prerender".
If the condition only needs to be checked once, you can put the
logic in the "init" method. For this example, add the following
code to the "prerender" method.
public void prerender() {
/**
* Some logic to check for read only. For now, set to true.
*/
boolean readOnly = true;
if(readOnly) {
this.getSessionBean1().setTextFieldDisabled(true);
}
}
Running the web application will show a web page that looks like this.
Notice the text fields are gray because they are disabled.
Points to Remember
- In JSF 1.1 UIViewRoot component tree is not available unless you are doing a "postback" to the same page.
- You can bind multiple components to the same property to achieve dynamic initialization.
- You can select multiple components in the Designer by dragging a box around the components.
- You can change the same property for multiple components by
selecting multiple components and changing the property in the Property
window.
Thanks go to Alex for patience and willingness to work with us on this issue.
Cheers!
-David
Posted by David Botterill
( Oct 03 2006, 11:22:27 AM MDT )
Permalink

|

|
Friday August 25, 2006
Java Studio Creator 2 Update 1 Performance Enhancements
I'm very happy to announce Java Studio Creator 2 update 1 performance
improvements! Many aspects of the IDE got way faster. To
get the performance improvements, get the latest set of Hot Fixes by
visiting the Update Center. Inside Java Studio Creator 2 Update
1, choose "Tools->Update Center". Check out the
Hot Fix web page for more information.
Cheers!
-David
Posted by David Botterill
( Aug 25 2006, 09:06:49 PM MDT )
Permalink

|

|
Wednesday August 23, 2006
Refreshing Web Services in Java Studio Creator 2
In a previous developer's life, like almost two years ago, I worked on
the web service consumption feature in Java Studio Creator. I
struggled with defining the scenario for "refreshing" a web service.
A developer has recently brought the subject up again so I though
I would blog on the topic. So in this blog, I'll cover how to
"refresh" a WSDL in Java Studio Creator.
Required Background Information
Before I dive into the how-to, I need to cover some background
information about scopes in Java Studio Creator. There are
basically two scopes in Java Studio Creator that matter for this
discussion,
IDE scope and
Project scope.
IDE Scope
When you do an "Add web service..." using the following dialog, you are adding to the
IDE scope.
All web services in the
IDE scope are available to all projects. The "Web Services" node in the "Servers" window shows the
IDE-scoped web services.
Project Scope
When you use a web service in a web page, the web service is copied to the
Project scope.
There are two techniques for adding a web service to the web page and thus the
Project scope, via the
context menu and
drag-n-drop.
With the visual designer showing the target page...
Context Menu: Entire Web Service
- Select a web service from the "Web Services" node.
- Right-click on the web service and select "Add to page".
Web Service Added to Project Scope
This will add a web service client property to the page as shown in the Outline window and the web service client Jar files to the project as shown in the Projects window.
Context Menu: Web Service Method
- Select a web service method from the "Web Services" node.
- Right-click on the web service method and select "Add to page".
Web Service Method Added to Project Scope
This will add a web service client property and a web service data provider to the page as shown in the Outline window and the web service client Jar files to the project as shown in the Projects window. The web service data provider wraps the web service client.
Drag-n-Drop: Entire Web Service
- Select a web service from the "Web Services" node.
- Drag the web service and drop it on the visual
designer background. A component is not a valid drop target for
an entire web service.
You'll get the same results as adding a
web service from the context menu above.
Drag-n-Drop: Web Service Method
- Select a web service method from the "Web Services" node.
- Drag the web service method and drop it either on the visual designer background or on a component.
You'll get the same results as adding a
web service method from the context menu above.
On to Refreshing
The most common use case of refreshing a web service I've seen involves
a developer who is trying to get a web service interface correct so
they keep changing the WSDL. When they change the WSDL, they'd
like to "refresh" the view of what Creator sees as that web service.
So now that we've looked at the scope issue above, you should
know that we need to refresh the web service in both the
IDE and the
Project scope.
Refreshing the Web Service in the IDE Scope
Unlike the EJB consumption in Java Studio Creator, the web service
consumption doesn't have a "refresh" option. I have some good
excuses but I won't go into those here.

In order to refresh
the web service in the IDE scope, if you want to use the same name, you
need to delete the web service and re-add it. If you are OK with
keeping multiple versions of the web service around, you don't have to
delete the old one. Simply add the new one. The new name
will have a number postfixed that will be incremented each time you add
the same named web service.
Refreshing the Web Service in the Project Scope
This is a little more involved. As I discussed above, a web
service client property and also a web service data provider property
are added to the web page. Web service client Jar files are also added
to the project libraries. If you really want to refresh the web
service, the safest way is to delete the web service artifacts and
re-add the web service to the project.
For example, if I drag-n-drop the "WorldTime->web service in the
"samples" folder to a web page, I'll have these web service
client artifacts added.
- Added to the Page (viewed in the Outline window) - "worldTimeTzStampNow1" data provider and "worldTimeClient1" web service client.
- Added to the Project window "Libraries" node - "worldtime.jar" and "worldtimeDesignTime.jar". If a non-sample web service was added, the jar name will be prefixed with the web service name. like "TravelWS-".
So to refresh this web service in this project, I would
delete the "
worldTimeTzStampNow1" data provider and "
worldTimeClient1" web service client from the Outline window and I would
remove the "
worldtime.jar" and "
worldtimeDesignTime.jar"
from the "Libraries" node. Then I would again drag-n-drop the
"WorldTime->web service in the "samples" folder to a web
page.
Also note that if you've written code around the web service client,
re-adding the web service increments the number in the name. To
change this, click on the "..." next to the name in the property for
the web service client and change it back to the name you used in the
code. Here's an example of some code that uses "worldTimeClient1".
try {
this.staticText1.setText(this.worldTimeClient1.tzStampNow("MST"));
} catch (Exception ex) {
log("Error Description", ex);
}
Here's a snapshot of what you would change.
Now isn't that refreshing!
Cheers!
-David
Posted by David Botterill
( Aug 23 2006, 06:42:52 PM MDT )
Permalink

|

|
Wednesday August 16, 2006
Sun Java Studio Creator 2 and Version Control: Part 2
Sun Java Studio Creator 2 and Version
Control: Part 2
In
my
blog entry, "Sun Java Studio Creator 2 and Version Control: Part 1,
I discussed how to get started using Java Studio
Creator 2 and CVS. In this blog I'll show you how to checkout
a
module. I will also discuss some of the common project artifacts and
scenarios for version control including JSP files, Java backing beans
files, and the navigation file.
Checking Out a Project
In CVS, to get started with something you need to do a "check out".
You check out at the module level. As you've
probably guessed
by now, a CVS module is a Java Studio Creator 2 project. To
check out a project, you first need to set up a CVS working directory.
This is the directory that you will contain all your CVS
controlled Java Studio Creator 2 projects.
First, from the "Versioning" menu, choose "CVS->Check Out...".
When the CVS Check Out" dialog opens fill in the details
pointing to a directory that you want to be a working directory.
You will have to type the module name in because there is currently a
defect in the "Select..." button functionality causing no modules to be
found. I've filed a defect and hope to get this fixed very
soon. Remember the module name is the project name.
While the defect makes this process less convenient, typing
in the project name isn't lots of work.
Now from the "View" menu, choose "Versioning->Versioning".
You'll see something similar to the following diagram with
all the working directories you've defined. When you create a
new project that will be controlled via CVS, you should create use the
working directory as the root for the project. This will
allow you to keep all your shared projects in the same working
directory. If you don't follow this practice, you might have
several working directories making tracking project versions very
difficult.
The Versioning window reflects entries
in a files in your user directory called
"userdir/config/VCSMount/org-netbeans-modules-vcs-advanced-CommandLineVcsFileSystemXX.xml".
This means if you ever delete your user directory, you will loose
these Versioning mount points. There will be one file for each
mount point.
Working With JSP Files
Scenario 1 - One user changes a
component on the JSP page
Description:
User1
has Page1 open that shows a static text field saying "Hello World".
User2 opens Page1 of the
same project, changes "Hello World" to "I like Ice Cream".
User2 then
"commits" the change through CVS in Creator.
Result:
If
User1 does a CVS
"update", when they do any action in the visual designer that requires
a refresh, they will see the static text saying "I like Ice Cream".
User1 can also refresh the page to see the changes.
Tips:
User2 must "Save" his changes before committing. The CVS
commit action will not automatically save everything changed. |
Scenario
2 - Two users change the
same component on the JSP page
Description: User1
has Page1 open that shows a static text field saying "Hello World".
User2 opens Page1 of the
same project, changes "Hello World" to "I like Ice Cream".
User2 then
"commits" the change through CVS in Creator. User1 changes
the Page1 static text field to say "I hate Ice Cream". User1
then
"commits" the change through CVS in Creator.
Result:
User1 will see the following log.
cvs commit: Examining sharedapplication1 cvs commit: Examining sharedapplication1/conf cvs commit: Examining sharedapplication1/nbproject cvs commit: Examining sharedapplication1/src cvs commit: Examining sharedapplication1/src/sharedapplication1 cvs commit: Examining sharedapplication1/web cvs commit: Up-to-date check failed for `sharedapplication1/web/Page1.jsp' cvs commit: Examining sharedapplication1/web/WEB-INF cvs commit: Examining sharedapplication1/web/resources cvs [commit aborted]: correct above errors first!
The key is "Up-to-date
check failed for `sharedapplication1/web/Page1.jsp". User1
needs to do a CVS "update" to get past this problem. When
User1 does an update, they'll see output similar to this.

There will be a conflict "C" between the changes. To resolve
the conflict, on the "Versioning" window, select the file in question,
right-click and choose "Resolve Conflicts". You'll be
presented with a window like the following.
User1 needs to choose which change they want from the right or left
window and select "Accept" in that window.
Tips:
- The conflict resolution and merging happen on a line
by line basis.
This means making two different changes, like different style
changes (e.g. bold,italic), to the same component will not result in a
merge but rather a conflict.
- If User1 makes a cosmetic change in the visual
designer to
a button and User2 double-clicks the button, adds backing bean action
code and then commits the change, User1 will get a conflict on the
button. The conflict will arise because double-clicking on
the
button in the visual designer adds an "action" attribute.
|
Java Backing Bean Files
Scenario 3 - One user changes
Page1.java
Description: User1
has Page1.java open. User2 opens Page1.java and adds a method
"getIceCream()". User2 commits the changes.
Result: If
User1 does a CVS
"update", they will see the method "getIceCream()" in
Page1.java.
Tips:
- User2 must "Save" his changes before committing.
The CVS
commit action will not automatically save everything changed.
- If User1 has been making modifications via the visual
designer that impact the Java backing bean Page1.java, User1 may get a
conflict when they do an "update" than can easily be fixed with a
"Resolve Conflicts".
|
Scenario 4 - Two users changes
Page1.java
Description: User1
has Page1.jsp open in the visual designer. User2 opens Page1.java
and adds a method
"getIceCream()". User2 commits the changes. User1 double-clicks
a button and is looking at the action method for the button in
Page1.java. User1 adds code to the action method and commits the
change.
Result: If
User1 does a CVS
"commit", they will see the following in the output window.
cvs commit: Up-to-date check failed for `Page1.java'
cvs [commit aborted]: correct above errors first!
If User1 does a CVS "update", they'll see something like the following.
You'll notice the changes were "Merged" in Page1.java.
|
The JavaServer Faces Navigation File (navigation.xml)
Scenario 5 - One user changes page navigation
Description: User1
has the navigation editor open. User2 adds "Page2" and
adds a navigation rule from the button on "Page1" to "Page2".
User2 then does a CVS "add" for Page2.jsp and Page2.java.
User2 then does a CVS "commit".
Result: Three files will be modified;
- managed-beans.xml - Page2.java will be added as a JavaServer Faces managed bean
- Page1.jsp - the button used to navigate will have the "action" property added.
- navigation.xml - a <navigation-rule> will be added for navigating from Page1 to Page2.
If User1 does a CVS "update", the will see the new page in the navigation rule in the navigation editor.
Tips:
- When doing a CVS "update", do it from the project directory
level so you get all affected files. Since Java Studio Creator
can change many files with a single visual action like adding a page
navigation, you will miss added/modified files if you try to only
update at the file level or a directory within the project directory.
|
Scenario 5 - Two users changes page navigation
Description:
User1
has the navigation editor open and adds "Page3". User1 then adds
a button to "Page2" and draws a navigation from "Page2" button to
"Page3". User2 has the navigation editor open and adds "Page4".
User2 adds a
navigation rule from the "Page2" button to "Page4". User2
then does
a CVS "add" for Page4.jsp and Page4.java. User2 then does a CVS
"commit".
Result: Three files will be modified;
- managed-beans.xml - Page4.java will be added as a JavaServer Faces managed bean
- Page2.jsp - a button was added.
- navigation.xml - a <navigation-rule> will be added for navigating from Page2 to Page4.
If User1 does a CVS "commit", the will see an up-to-date error.
User1 will then have to do a CVS "update". After doing the
CVS "update", User1 will see the following in the VCS output window.
As you can see, there will be conflicts in the managed-beans.xml as
well as the navigation.xml. Also, the merge last the navigation
User2 put in going from "Page2" to "Page4".
If you "Resolve Conflicts" on the managed-beans.xml, you'll see the this dialog.
Resolving the managed-beans.xml Conflicts
You can see that the merge couldn't distinguish that both User1 and
User2 added a page. To get out of this situation, User1 will need
to "Accept" the "Working File", the one on the left, then re-add the
managed-bean entry for Page4. Before User1 accepts,
User1 must copy the "Revision x.x" pink highlighted text by
highlighting the text and hitting "CTL-C". User1 must then open
the "managed-beans.xml" file from the "Files" window under
"web->WEB-INF" and near the end of the right before the
</faces-config> tag and do a paste "CTL-V".
Resolving the navigation.xml Conflicts
The merge also
leaves the navigation.xml file broken. To fix this, User1 will
need to accept the "working file" changes then re-add the navigation
link from a new button on "Page2" to "Page4".
Tips:
- Restrict Page Navigation Editing By Assigning "Keeper"
- Since the merging and conflict resolution don't work that well when
page navigation is changed by multiple users, assign a page navigation
"keeper". The keeper will be solely responsible for editing the
page navigation.
- Specify Multiple Navigation Files -
This technique involves having multiple navigation files. The
problem with this solution is that Java Studio Creator will only
recognize the "navigation.xml" file when the visual navigation editor
is opened. This means only one developer will be able to visually
edit the navigation file.
Steps to create multiple navigation files.
- For the user who will NOT have the "navigation.xml" file,
from the "Files" window, right-click on the "navigation.xml" file
and do a "copy".
- Select the "web/WEB-INF" folder and do a "paste".
- You will now have "navigation_1.xml".
- Edit "navigation_1.xml" by double-clicking on it and choosing the "Source" view.
- Manually change the navigation rules to only include the rules you will be adding/maintaining.
- Edit the "web.xml" file by double-clicking on it.
- Expand the "Context Parameters" node.
- Select the "javax.faces.CONFIG_FILES" line and select "Edit".
- In the "Param Value:", add ",/WEB-INF/navigation_1.xml" to
the end of the string. Don't forget the comma separating the
entries.
|
Posted by David Botterill
( Aug 16 2006, 12:11:15 AM MDT )
Permalink

|

|
Wednesday August 09, 2006
Defining Java Studio Creator 2 Data Sources in Tomcat
I'm sure this will be old information to some people. But, I had
the need to look at a Java Studio Creator 2 web application in Tomcat
5.5 the other day and I needed to define the sample Travel database in
JavaDB to the Tomcat container. There is a good help topic on
this in Java Studio Creator 2 than can easily be found by searching on
"tomcat". The first hit is "Deployment Example: Tomcat".
This will give you most of the necessary information. In
this blog I'll give you some critical pieces to allow you to talk to
the sample database in JavaDB bundled with Java Studio Creator 2.
Yes this applies to Java Studio Creator 2 Update 1 as well.
Copying the JavaDB JDBC Jar File
First, you will need to copy the JavaDB JDBC Jar file to the Tomcat
container so Tomcat can load the JDBC driver when needed. To do
this, copy
creator_install_dir/SunAppserver8/derby/lib/derbyclient.jar
to
tomcat_install_dir/common/lib.
Add a "context.xml" to Your Project
Next you will need to define the data resource to the Tomcat container.
There are really two places a JNDI (Java Naming and Directory
Interface) data resource needs to be defined. The first place is
in the application itself. This definition is taken care of by
Java Studio Creator in the "web.xml" file via the
"<resource-ref>" element. The other definition needs to be
in the container. In Tomcat, this can be in the "server.xml" file
which will be applicable for every web application or in a
"context.xml" in the web application's "META-INF" directory.
Here are the steps to create the "context.xml" file for your Java Studio Creator 2 web application.
1. Add a directory called "
META-INF"
to your project by selecting the "File" window, then the "web"
directory. Right-click on the "web" directory and select
"New->Folder". When the dialog comes up, name the folder
"META-INF" and hit the "Finish" button.
2. Add a "context.xml" file to the
"META-INF" directory by selecting the "File" window, then the
"web/META-INF" directory. Right-click
on the "web/META-INF" directory and select "New->File/Folder...".
When the "New File" dialog appears, select "Resources->XML
Document". Select "Next" and name the XML Document "context.xml".
Select "Next" and choose "Well-formed Document". Press
"Finish". When the "context.xml" file appears in the editor,
replace the contents with the following and save the file.
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/CorporateTravelCenter" docBase="CorporateTravelCenter"
debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/Travel" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="travel" password="travel" driverClassName="org.apache.derby.jdbc.ClientDriver"
url="jdbc:derby://localhost:21527/sample"/>
</Context>
Lastly, you'll want to "clean and build" your project. Now when
you create a WAR file, the context.xml file will be part of it and used
by Tomcat to setup the data resource.
Posted by David Botterill
( Aug 09 2006, 05:55:52 PM MDT )
Permalink

|

|
Saturday August 05, 2006
Java Studio Creator 2 and Liferay Portal Server Update
I thought I would give some update on Java Studio Creator 2 portlets running on Liferay portal server.
Liferay 4.0
To get Java Studio Creator 2 update 1 portlets to work correctly on
Liferay 4.0 you will need to remove the "lib/portlet.jar" file
and the "tld" folder from the WAR file. I have a defect filed
against Java Studio Creator to permanently remove the "portlet.jar"
file from the portlet since all portal servers will most likely supply
this at the container level.
Liferay 4.1
The good news is that you don't have to worry about removing the
"portlet.jar" file nor the "tld" folder from the WAR file in 4.1.
There are, however, some other issues.
Apparently Liferay 4.1 does not support the
Servlet 2.4 spec in a web.xml.
I've tried with both
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
and
<web-app version="2.4">
But both trigger the following exception.
org.dom4j.DocumentException: Error on line 3 of document : Document is invalid: no grammar found. Nested exception: Document is invalid: no grammar found.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.dom4j.io.SAXReader.read(SAXReader.java:365)
at com.liferay.portal.service.impl.PortletLocalServiceImpl._readWebXML(PortletLocalServiceImpl.java:983)
at com.liferay.portal.service.impl.PortletLocalServiceImpl.initWAR(PortletLocalServiceImpl.java:259)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
I've done some debugging in the liferay code and the exception is thrown in this part of the code.
PortletLocalServiceImpl.java -
private List _readWebXML(String xml) throws DocumentException, IOException {
List servletURLPatterns = new ArrayList();
if (xml == null) {
return servletURLPatterns;
}
SAXReader reader = new SAXReader(true);
reader.setEntityResolver(new EntityResolver());
=====> Document doc = reader.read(new StringReader(xml));
Element root = doc.getRootElement();
Iterator itr = root.elements("servlet-mapping").iterator();
I'm not familiar with the 3.6 codebase so I don't know if dom4j's
SAXReader was used or if it always used the "true" option to validate
the schema. In any case, apparently it has a problem resolving
the schema for servlet 2.4.
Work Around:
In Java Studio Creator 2 update 1, choose the J2EE 1.3 as the target
WAR type when you do the export WAR. The dialog will look like
this.

Posted by David Botterill
( Aug 05 2006, 09:38:16 PM MDT )
Permalink

|

|
Friday August 04, 2006
Sun Java Studio Creator 2 and Version Control: Part 1
Sun Java Studio Creator 2 and Version Control: Part 1
Sun Java Studio Creator 2 takes advantage of the NetBeans Platform
Version Control System (VCS). Specifically, Creator supports CVS and
Visual Source Safe(VSS). I'll be focusing some blog entries on doing version control using Creator and CVS.
Creator web applications consist of files organized at the project
level. The project file structure can be seen in the "Files" window
next to the "Projects" window.
Preparing a Project For Version Control
Library References
Before adding a project to CVS, you must make sure all the
necessary files are part of the project. You don't want logical
references
outside the project structure. The NetBeans project structure
supports a logical library reference. A library reference is a
collection of Jar files. Creator ships with some standard library
references that are part of each developers environment. To make a
project “portable” you must be careful defining library
references. Library references are typically defined either at the
user level or at the System level. This means if you define a
library reference, that library reference definition will be in your
user directory and not in the project file structure. If you need to
add Jar files to your project, avoid using libraries references.
Instead, you need to add the Jar file to a
directory within the project structure. For example, if you are
using the Hibernate framework and want to add
“hibernate3.jar” to your
project, you would do the following.
- You should first create a directory called “projectlibs”
within the project. like the following.
- Next, you'll add the “hibernate.jar” file to
the directory by doing an "File->Add existing Item->Other". Note
that you'll have to move (cut/paste) the Jar file from the source
folder because that's where Creator puts it by default.
- Lastly, you'll do an “Add Jar/Folder...” from the
project “Libraries” node and add the Jar file. This will ensure
that the Jar file can be controlled by CVS and available to all team
members working on the project.
AJAX Components
When you drop an AJAX component on a
web page in Creator, Jar files are added to the project directory
“lib/complibs”. Also, a library reference is created to
reference this set of Jar files. The library reference is created in
your user directory. If you open your library references and select the
AJAX Blueprint that was created, you'll see something similar to the
following.

When the first AJAX component is dropped on the designer, a
library reference is created in your user directory. The file
where the library reference is created is "build.properties".
Since the user directory can't be included with the project,
you'll need to take steps to add the Jar references that were added to
the project "lib/complibs" to the project libraries. To do this,
right-click on the "Libraries" node under the "Project" window and
select "Add JAR/Folder..." like this.
You will need to add these files from the "lib/complibs/ui.complibxxxxx" directory.
- ui.jar
- ui-dt.jar
- shale-remoting.jar
The following figure shows what this will look like. Notice that
you have to select "package" for the "ui.jar" and the
"shale-remoting.jar" so they will be deployed with the web application.
While you're in this dialog, remove the reference to the
"xxx_Design-time_BluePrints_AJAX_Components".
You'll also need to remove any library references in your project to
the AJAX runtime library references in your user directory
"build.properties". This is a little more involved. You'll
have to search for all references to the runtime library reference in
the "nbproject" directory.
From the "Files" window, select the
"nbproject" directory, right-click and select "Find...". Enter
"Runtime_BluePrints" as the search string and search. You'll be
presented with a set of hits at the bottom of the IDE.
Double-clicking on each entry will open the file and position the
cursor at the hit in the file. You need to remove each line found
in every file. In the "project.xml" file, you'll need to
delete the entire "<library>" element for the reference.
Repeat
the find/replace process for the string "Design-time_BluePrints".
The good news is you will only need to do this once per project
for AJAX components. The next time you open the project, you may
see a dialog like the one below. Simply press the "Regenerate"
button and proceed.
Testing the Project
Now you should test your project for "portability". That is, you
want to test whether or not you've successfully taken care of file
references that are outside the project file system. To do this,
simply
MOVE the entire project
folder, "webapplication1" for example, to a different location.
Once you've moved the project folder, try to open it in Java
Studio Creator from the new location. If the "Project" window
node for your project shows up red. If you open the "Resolve
Reference Problems..." as show below, you can see the resources that
you missed.
Also, do a "clean and build project" from the project node to make sure you've included all the necessary external Jar files.
Adding the Project to CVS
At this point, your project should be ready to add to CVS. Please check out the article, "Source Code Control in the Sun Java Studio Creator 2 IDE" for details on setting up CVS and adding your project.
IMPORTANT - The
only tip I would add to this is about ignoring certain files. For
sure you want to ignore the "nbproject\genfiles.properties" from CVS
since it represents IDE session specific information. To do this,
go to the "Versioning" window next to the "Palette" window.
Select the "genfiles.properties" file under the "nbproject"
directory. Right-click on the file and select "CVS->ignore".
This will create a ".cvsignore" file in the "nbproject" directory
for that file.
Next Time
In my next blog, I plan to discuss a technique for specifying multiple
navigation files so multiple developers can add to the page navigation
simultaneously.
Posted by David Botterill
( Aug 04 2006, 07:20:05 PM MDT )
Permalink

|

|
Sunday July 23, 2006
Generically Setting UI Component Properties in Java Studio Creator
I recently saw a forum question about setting page component properties
generically instead of specifying each property name. I've done
similar things using Swing and Visual Basic and this is also possible
with Java Studio Creator.
As with any type Java Studio Creator development you MUST be ware of the application model. Please see the article
The Java Studio Creator 2 Application Model
for details on the application model. The following solution will
only work in the case of navigating from a JavaServer Faces page
to a JavaServer Faces page. This will NOT work going from a
non-JavaServer Faces page to a JavaServer Faces page such as navigating
to the Creator application for the first time. If you refer the
section "
Page Bean Life Cycle"
in the article mentioned above, you'll see the "Update Model Values"
phase is not invoked when first navigating to the Creator page.
Because of this, the components model is not complete and renders
the following code useless. This means you would have to assume
an initial value for the components on the first page.
Here's the solution.
public void prerender() {
if(mySpecialCondition) {
setFields(this.getPage1());
}
}
private void setFields(UIComponent inComponent) {
/**
* If this component has children, set the properties then recurse through each child
* to see if they have children to be set.
*/
List allComponents = inComponent.getChildren();
if(null == allComponents) return;
Iterator listIterator = allComponents.iterator();
UIComponent currentComponent = null;
while(listIterator.hasNext()) {
currentComponent = (UIComponent)listIterator.next();
if(null != currentComponent) {
if(currentComponent instanceof TextField) {
((TextField)currentComponent).setReadOnly(true);
} else if(currentComponent instanceof TextArea) {
((TextArea)currentComponent).setReadOnly(true);
} else if(currentComponent instanceof Button) {
((Button)currentComponent).setVisible(false);
}
/**
* Recurse through all the components
*/
this.setFields(currentComponent);
}
}
}
Of course you would need to change the set of components and properties
to fit your needs. Also the scope of the components to be changed
could be controlled by using a container (Layout) such as a group panel.
Enjoy!
-David
Posted by David Botterill
( Jul 23 2006, 02:49:18 PM MDT )
Permalink

|

|
Thursday July 20, 2006
Changing the Java Studio Creator Backing Java File Template
Every time I delete my user directory in Java Studio Creator, I lose my
"
_USER_"
setting tag for new classes that are created. Creator uses
the NetBeans template facility to create a new Java file and puts
comments in the top of the file like this.
/*
* Page1.java
*
* Created on June 20, 2006, 9:36 AM
* Copyright david
*/
The template for this page looks like this at the top.
/*
* __NAME__.java
*
* Created on __DATE__, __TIME__
* Copyright __USER__
*/
So where do you change the "
_USER_"
tag. Basically this is defined in the "
tools->options(advanced)".
The node is "
Editing->Java
Sources". The dialog looks like this.
The "Strings Table" contains what's refered to as a MACRO. In
this case, the macro is "
_USER_".
If you click on the elipse next to the value, you can change
the value of "
_USER_".
The next time you create a page, the new value will be
inserted.
NetBeans
This will also work for NetBeans. The Java class template for
NetBeans looks like this.
/*
* NewClass.java
*
* Created on July 20, 2006, 2:23 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.sun;
/**
*
* @author david
*/
public class NewClass {
/** Creates a new instance of NewClass */
public NewClass() {
}
}
So changing the "_USER_" macro in this case would change the "@author"
tag value.
Changing the Creator Java
Page Template
If you would rather have "@author" instead of "Copyright" in the
comments for your Java Pages, you can change the template.
Caution! - Changing the
template incorrectly will break the Java Studio Creator application
model. Only change the non-functional pieces like the
comments.
Not that the warning is out of the way, open the
"Tools->Options" dialog and make sure you are in advanced mode.
Go the the "Source Creation and
Management->Templates->Web Pages node" and expand it.
Double-click on the "Backing Java File" node and you will see
the template in the Java Editor. You can then change
"Copyright" to "@author". You could even add your companies
copyright information.
Enjoy!
-David
Posted by David Botterill
( Jul 20 2006, 03:42:57 PM MDT )
Permalink

|

|
Friday June 23, 2006
Java Studio Creator 2 Portlets and Jetspeed-2
I finally had time to get a Java Studio Creator 2 Update 1 portlet
working on Apache Jetspeed-2. You have to make a couple of
modifications to the Creator portlet project to get things working
properly.
Modification 1 - Remove
the "tld" Folder
If you don't remove the "tld" folder from the Creator-produced WAR,
you'll get the following exception in the Jetspeed-2 log during the
deploy.
Attempting to add portlet.tld
to war...
Adding
portlet.tld to war...
ERROR:
java.util.zip.ZipException: duplicate entry: WEB-INF/tld/portlet.tld
org.apache.jetspeed.deployment.DeploymentException:
java.util.zip.ZipException:
duplicate entry:
WEB-INF/tld/portlet.tld at
org.apache.jetspeed.deployment.impl.DeployPortletAppEventListener.deployPortletApplication(DeployPortletAppEventListener.java:173)
at
org.apache.jetspeed.deployment.impl.DeployPortletAppEventListener.invokeDeploy(DeployPortletAppEventListener.java:158)
at
org.apache.jetspeed.deployment.impl.StandardDeploymentManager.dispatch(StandardDeploymentManager.java:257)
at
org.apache.jetspeed.deployment.impl.StandardDeploymentManager.deploy(StandardDeploymentManager.java:168)
at
org.apache.jetspeed.deployment.impl.StandardDeploymentManager.fireDeploymentEvent(StandardDeploymentManager.java:202)
at
org.apache.jetspeed.deployment.impl.StandardDeploymentManager$FileSystemScanner.run(StandardDeploymentManager.java:342)
Caused by:
java.util.zip.ZipException: duplicate entry: WEB-INF/tld/portlet.tld
at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:163)
at java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:90)
at
org.apache.jetspeed.tools.deploy.JetspeedDeploy.addFile(JetspeedDeploy.java:277)
at
org.apache.jetspeed.tools.deploy.JetspeedDeploy.<init>(JetspeedDeploy.java:170)
at
org.apache.jetspeed.deployment.impl.DeployPortletAppEventListener.deployPortletApplication(DeployPortletAppEventListener.java:168)
... 5 more
ERROR: Failure
deploying C:\Apache Jetspeed 2.0\webapps\jetspeed\WEB-INF\deploy\
Portlet3.war
|
First you'll need to remove the "tld" folder from the Creator project
because the Jetspeed-2 deployment process injects a "tld" folder.
Go to the "Files" window, select the "tld" folder, right-click and
select "Delete".

Modification
2 - Remove the "portlet.jar" from the Run Time Library
Next, you'll need to remove "portlet.jar" file from the "Sun Web UI
Components" library. If this is not removed, you'll get a
"ClassCastException" because the JetSpeed-2 container, in the
classloader hierarchy, already has a "portlet.jar" and specifically the
"Portlet" interface.
Open the Library manager by selecting the "Tools->Library
Manager" menu. Select the "Sun Web UI Components"
library on the left. You should see something like
this.
Remove the "jar:nbinst:///modules/ext/portlet.jar" entry and press the
"OK" button.
Next, export the WAR file by doing a right-click on the Project node
and choosing "Export War...". Choose the 1.4 J2EE container
and make the target directory the
"jetspeed-2_installdir/webapps/jetspeed/WEB-INF/deploy" directory.
When the WAR file is place here, Jetspeed-2 will pick up the
WAR file and deploy it to the app server and to the portal server.
Then you'll need to add it to a page by editing the
appropriate ".psml" file as directed in the Jetspeed-2
manual. I chose to put mine in the "jsf-demo.psml"
file so the portlet would show up with the other JSF portlets.
Working Proof
Here's a screen shot just so you believe me.

Posted by David Botterill
( Jun 23 2006, 06:40:38 PM MDT )
Permalink

|

|
Friday June 16, 2006
Article on Inter-Portlet Communication with Java Studio Creator Now Available
The article you've all been waiting for is finally here, "
Building IPC Portlets for Sun
Java System Portal Server 7 With Sun Java Studio Creator 2".
Ed Chen, a Sun Portal Server engineer does a great job
showing us how to do inter-portlet communication with Java Studio
Creator and Sun Portal Server 7.
Check it out!
-David
Posted by David Botterill
( Jun 16 2006, 02:00:16 AM MDT )
Permalink

|

|
Friday May 19, 2006
Memiors Of A JavaOne Junkie
I'm sitting in the San Francisco airport (SFO) waiting for the plane to
Colorado. You can spot all the JavaOne attendees by their
orange
backpacks and dazed looks. JavaOne 2006 is over for me as well.
I
very much enjoyed this year. I was actually quite relaxed
compared to most years. I usually go for lots of techno
bling-bling in the pavilion. This year I didn't. I
almost
went home without ONE T-shirt! Can you imagine it?
As it
turns out, I was wandering by a booth and the guy says, "Hey, you want
a
T-shirt?". Now for JavaOne veterans like myself, this is like hearing,
"Hey, you want this chunk of Gold?". I don't know
what it is about
us geeks and T-shirts and useless trinkets. But we go after
them
like the "Big 5" on an African safari. The part I love is
where
all the geeks display their trophies throughout the week.
Take
for instance the Sun Developers Network (SDN) party. I didn't
make it because I was too busy attending very interesting BOFs
(performance evaluations are soon so this should look good). Anyway, I
was in a BOF when a group of people walk in with balloons twisted on
their head. One dude had a hat with a figure of a woman
on a
bike in a bikini. I have many observations about that.
First, what the heck was the balloon twister thinking when he
did
that one? I was going to take a picture but a friend of mine
had
recently got in trouble for a blog picture so I didn't want to have the
same thing happen. Ok, so in walks this group of people with twisted
balloons with graphic depictions, on their heads and sit down in the
BOF like nothing's wrong. They obviously had a substance
besides
blood running in their veins because one of them immediately fell
asleep in the chair. That's JavaOne. That's what
makes it
so unique. The true geek comes out in all the attendees and
everyone seems to thrive on the geekiness of the people around them.
I remember the JavaOne days of old. Some unsuspecting woman
who
had volunteered to do collateral (marketing speak for geek junk) duty
would walk onto the pavilion floor with a box marked "Hanes".
Some geek in the crowd would yell, "T-Shrits!" and thousands
of
wild-eyed Java developers would converge on the T-Shirt box.
At
this point, the collateral specialist would drop the box and run for
her life. Now we had what my friend Anthony Earl and I like
to
call a "T-Shirt Scrum". Ant is English and a former Rugby
player
so he relates well with the term. The Scrum was a free-for
all
for a $5 T-Shirt that had "Java" on it somewhere. On one
occasion, I worked my way to the middle, got a T-Shirt then did a
fullback maneuver out of the scrum. Ant had a big smile on
his
face when I emerged from the scrum as I had apparently hooked a geek on
my backpack and drug him out of the scrum with me. I'm really
not
that big, 5'6" about 170 lbs. This gives you an idea of the
adrenaline rush that used to be involved in getting a T-Shirt.
So
if you contrast that with the guy handing me a T-Shirt this year, it's
just not the same. Now many of the vendors require a form of a
scavenger hunt before you can claim your T-Shirt. If you do
pod
duty, you can tell the geeks on the hunt because they'll walk up with a
stamped piece of paper and ask a question like, "What stamp do I get
here?". OK, so maybe I'm getting older and finally realizing
that I'll probably never where the 20 XXL T-shirts I have in my drawer
over the next year. I know my wife has been telling me that
for
years but you know how that is. My all-time favorite JavaOne
T-Shirt was from Segue software. On the back of the T-Shirt
was a
picture of a Sumo wrestler leaning way far forward flying
through
the air in the middle of an alpine ski jump. It was so cool!
I wish I remembered the tagline because it was very good as
well.
If anyone remembers this T-Shirt, please comment and help me
out
with the tagline. I wore that T-Shirt until it was almost
just a
ring around my neck! Oh yeah! I can't leave out the JavaOne
mints. Why do so many vendors insist on giving out mints?
Here are some theories.
- Mints are cheap and everyone likes to carry them
- They are easy collateral to transport to JavaOne
- Us geeks have bad breath
I tend to believe theory 3 is the truth. Here's an idea.
Why don't the vendors just give us toothbrushes instead.
That way we'll see their company name every time we brush our
teeth. OK, so that assumes we brush our teeth. I
think most
of us do.
JavaOne
2006 TakeAways
Two
T-Shirts
Yeah!
Java Studio
Creator Open Sourced
That's right! We announced this JavaOne that we
are
open-sourcing Java Studio Creator. You can hear the official
announcement during the
first
day's General Session.
Java Studio Creator
Delivering Features for the NetBeans IDE
This addresses the question, "Why do I have to install
NetBeans
and Creator if I want to create web services and do visual web
application development?".
Sandip Chitale
did a demonstration at
NetBeans Day showing Creator drag-n-drop, visual development in the
NetBeans 5.5 Beta IDE. While you can't download this yet,
we've
basically shown you the direction we're heading. We still
believe
there will, however, be customers who don't want the 747 cockpit and
would prefer the simplified, focused view of Java Studio Creator as a
stand alone IDE.
Building an
Application on the NetBeans Platform is Way Easier Than it Used to Be
Even though I work in Sun Tools as the Java Studio Creator
Evangelist, I'm very honest with people about my view of Sun tools 3
years ago. I wouldn't touch them. I had tried
"Forte for
Java", Netbeans 3.5, and 3.6 and quite frankly, I wouldn't ever use
them. That's a very different story today. I really
grew up
as a developer in IDEs. I even used Borland's early text
based
IDEs for pascal and C. I used Symantec's Visual Cafe for a
long
time, IBM's Visual Age, and Borland's JBuilder for a long time.
I
use an IDE because I want ot to make my job easier. If it
doesn't
do that, why use it. Not only has the NetBeans IDE become
very
usable and helpful, the NetBeans platform that it's built on has
recently become way easier to use. When I first started in
the
Creator engineering group almost 3 years ago, I had nothing
good
to say about NetBeans module development. I had to do it for
the
Web Service consumption feature. And unless you were a very
seasoned NetBeans developer, using the NetBeans platform for an
application was unthinkable. With NetBeans 5.0 the NetBeans
team
has finally nailed the module development. Now developing
modules
for NetBeans is extremely easy.
Geertjan Wielenga's
BOF opened my eyes about how easy it is now to use the NetBeans
platform for application development. Geertjan and Petr Pisl
have
created a Wicket IDE based on the NetBeans platform.
Visual Basic For The Java
Platform?
Yes you heard correclty. Tor Norbye, John Kline
(both
Creator engineers), and Herbert have been working on project
Semplice
for about 9 months. This project allows a Visual
Basic 6 or
earlier VB programmer to write VB code that runs on the Java Platform.
They demonstrated importing the Visual Basic calculator
program
and running it on the Java Platform FASTER than it runs as a windows
.EXE. The coolest demo was showing a VB program running on
Herbert's new
SavaJe
phone in the CDC VM.
Sun Portal Server 7
Making Big Steps
I talked with Paul Hinz, the Sun Portal Server
Product
Manager and he showed me a preview of the upcoming release.
They
were showing this at the Pod and I know this is tooting Sun's horn, but
it was very cool. They've implemented an AJAX window where
the
portlets run that allow for asynchronous portlet content updating.
This means if the content in one portlet changes only that
portion of the screen changes instead of refreshing the entire screen
with a postback. Also, you can drag portlets around and
reposition them in the portal. Watch for this to be released
soon. I'm really happy Sun's making the portal product better.
Open Source Portal Project
Sun has started an
open source portal
project.
The first part of the project is a portlet repository where people can
find open source portlets. So please contribute all your
Creator-produced portlets.
AJAX Is Here
To Stay
Duh! If you're a developer like I am, you can appreciate how
many
times a technology is hyped then quickly dies when people realize what
it really means. AJAX stormed JavaOne 2005 by surprise but
was
the definitely the planned focus of this year's JavaOne. The
best
thing I learned about AJAX at this JavaOne is how many companies like
Google and ICESoft really figured out the best way to leverage AJAX
technology. They've employed a lost art called "Software
Engineering" and created cohesive frameworks that encapsulate the
nightmarish AJAX programming pitfals like JavaScript and wire calls.
Now developers can use AJAX technology without doing the
low-level garbage necessary to make AJAX sing.
Jini Moving to Apache
"Jini?", you ask. Why do I care about Jini? I first came to
Sun
in 2000 to work on the Jiro Technology team. Jiro was a
management framework (the buzzword of the era) built on Jini
Technology. This was a very very fun job. Jini is a
great
technology. Jini services and the concept of "resilient
services"
is a very compelling service story. Jini service federations
existed way before the term "
Service
Oriented Architecture"
was coined. After attending the BOF on Jini and JavaSpaces,
I'm
compelled to take a fresh look at Jini 2.0. At the BOF, they
mentioned that they are trying to get Jini to be taken on by the Apache
Foundation. The amazing thing about Jini is that the user
community has liked it so much that they've basically been keeping it
going for the past 3-4 years.
Hope to see you all at next year's JavaOne!
-David
Posted by David Botterill
( May 19 2006, 11:29:58 PM MDT )
Permalink

|

|
Friday May 12, 2006
Want to Know What Sun's Doing With AJAX?
If you want to get an idea of what Sun is doing with AJAX technology,
check out the new
AJAX
site off of
developer.sun.com.
This site is an aggregation of lots of good content on what
Sun's doing with AJAX. The site includes information on
getting started, AJAX components, AJAX and portlets, and much more.
Check it out!
Cheers!
-David
Posted by David Botterill
( May 12 2006, 02:54:25 PM MDT )
Permalink

|

|
Thursday May 11, 2006
Using Netbeans 5.0 Web Service Clients in Java Studio Creator 2
I've recently had a Java Studio Creator 2 user come to me trying to
consume a web service but the WSDL for the web service was not exactly
WS-I compliant. In particular, this the WSDL had a problem
with the "-f:searchschema" option of the "
wscompile"
command. For those of you using Creator for web services, you
may or may not know that Creator uses the JAX-RPC toolkit.
The current version of the toolkit is called JAX-WS.
There is a tool called "
wscompile"
that generates web service client code from a WSDL. In
Creator, I had a difficult time deciding which
wscompile
options would work best in all cases. Up until this latest
problem, the options worked for most cases. I did externalize
the "WS-I" compliance and "Generate SOAP Headers" options at one point.
Apparently I need to externalize more options, in fact maybe
all of them. I really wanted to isolate the Creator user from
the details of
wscompile
to help with the ease-of-use story. In any case, if you have
a WSDL that won't compile correctly in Creator, you can use NetBeans
5.0 to generate the web service client and use the client in Creator.
Creating
the NetBeans 5.0 Web Service Client
The following steps are the
easiest way I found to generate a web service client in NetBeans 5.0.
1. Create a new "General->Java Class Library" project.
2. Right-click on the new project and select "new->web service
client".
3. Browse the the WSDL you want to use and enter a package name.
4. Build the project to create the Jar file under the "dist" directory.
5. If you have problems compiling the WSDL, look at the Project
properties "Web Service Clients" node. You'll see
the
features
for the
wscompile
command.
Here's the list of what these features do.
Feature
|
Description
|
datahandleronly
|
always map attachments to the
DataHandler type
|
donotoverride
|
do not regenerate classes
that already exist in the classpath
|
donotunwrap
|
disable unwrapping of
document/literal wrapper elements in WSI mode (default)
|
explicitcontext
|
turn on explicit service
context mapping ( generates SOAP headers)
|
|
jaxbenumtype
|
Map anonymous enumeration to
its base type
|
nodatabinding
|
turn off data binding for
literal encoding
|
norpcstructures
|
do not generate RPC
structures (-import only)
|
novalidation
|
turn off full validation of
imported WSDL documents
|
resolveidref
|
resolve xsd:IDREF
|
searchschema
|
search schema aggressively
for types
|
strict
|
generate code strictly
compliant with JAXRPC spec
|
unwrap
|
enable unwrapping of
document/literal wrapper elements in WSI mode
|
wsi
|
enable WSI-Basic Profile
features, to be used for document/literal and rpc/literal
|
Using
the NetBeans 5.0 Web Service Client in Creator
1. Create a web or portlet project
in Creator 2.
2. Right-click on the project node and select properties.
3. In the properties dialog, select "Libraries" from the
"Categories:" and do "Add JAR/Folder".
4. Now you have access to the web service client code from the Creator
backing bean actions. Here's an example with the
TravelWS.wsdl shipped with Creator.

Cheers!
-David
Posted by David Botterill
( May 11 2006, 05:04:30 PM MDT )
Permalink

|

|
New Java Studio Creator 2 Article: The Java Studio Creator 2 Application Model
If you want to get a better idea about what's really happening under
the covers in Java Studio Creator 2, you need to check out a new
article on the
Application
Model. Ok so I did author this article.
Basically the information was compiled from Craig
McClanahan's brain, the JavaServer Faces specification, and digging
through Java Studio Creator 2 source code. The
article,
The Java Studio Creator 2
Application Model goes into depth about what
happens on the server as far as JavaServer faces life cycle processing.
The article starts out with an overview of the JavaServer
Faces application model then covers the enhancements in Creator 2.
Most importantly, I want this article to be useful to Creator 2
developers. If you have questions or need clarifications
about the subject matter in the article. please leave comments.
Cheers!
-David
Posted by David Botterill
( May 11 2006, 10:23:05 AM MDT )
Permalink

|

|
Monday May 08, 2006
More on Sun Tech Days in JoBerg
I'm still on my way back from Johannesburg. I'm sitting in
Heathrow waiting for the connecting flight to Denver. I
recently
was able to download some pictures from the Tech Days and wanted to
share them with everyone.
Here's one of some developers crowded around the Sun Tools
booth
with Tom Gryder, Sun Product Manager, trying to keep up with the crowd.
The guy on the far right is named Brian (I think).
If your
are this person, I met you and we were always going to meet back up to
talk but it never happened. Please send me an email so I can
get
in touch with you.
The next shots were taken
during the
first morning with registration going on. If you see
yourself,
please add a comment describing which person you are, why you attended,
and what you got out of Tech Days.
I'd also like to thank the
local South
Africans who took the time to speak with me on Java and South African
life. I really enjoyed these conversations. Here
are some
of the people from whom I was able to get a business card or picture.
Leon Messerschmidt of
Psybergate
presented on Java Portals after I presented on Java Studio Creator.
I spoke with Leon and his colleagues after during lunch.
Sorry Leon's colleagues but I don't remember all your names
but I
really enjoyed the conversation. There are all a great bunch
of
"okes"!
I also spoke Mr. Salkinder from
e.Business
Solutions
about... Oops I'm not supposed to talk about it. Anyway,
watch
for "Salkinder" in the headlines. Thanks for the
thought-stimulating conversation.
I had the distinct pleasure to meet
Professor Judith
Bishop
of the University of Pretoria. Judith is the author of many
technical books one of which is "Java Gently". Judith was
truly
fascinating to talk with. Here we are. Thanks for
taking
the time to talk Judith.
I also met Rian Brand
(pronounced "ree-an" for you American okes) of
Kennedy Brand Consulting.
Rian was having issues getting Java Studio Creator to install
on
his machine. I spent some time trying to help him out but we
ran
out of time. Rian and I spoke about South African life and
such.
I thoroughly enjoyed our conversation. Rian later
emailed
me that he was able to get Creator installed. There was an
issue
with another version of the Sun Java Application Server on his machine
(I think). Thanks for following up Rian!
I spoke with this guy in the beard (Windows XP Home Guy) several times
but never got a card or a name. Please send me your info.
And last but certainly not least, I wanted to thank my two friends who
never gave me business cards. Here's a fuzzy picture of them
in
the front row. Thanks for not heckling me! They
gave me
lots of great joke material but unfortunately, I couldn't use any of
it. Please let us know your names again.
Cheers!
-David
Posted by David Botterill
( May 08 2006, 11:04:42 AM MDT )
Permalink

|

|
Thursday May 04, 2006
Java Studio Creator 2 at Sun Tech Days Johannesburg, South Africa
It's almost 4AM and I should really be in bed but my internal
clock is off because I'm in GMT+2 (Johannesburg, South Africa) instead
of GMT-7 (Colorado, USA). Yesterday, May 4th was
the end of the
Sun
Tech Days Johannesburg, South Africa. The first Day
I delivered a Java Studio Creator 2 AJAX hands-on lab with the famed
Sun Technology Evangelist Sang Shin. Sang is a really
dynamic, energetic speaker who is very knowledgeable in many Java
technologies. You can check Sang's wealth of information out
at
javapassion.com.
Yesterday I gave a "Rapid Web Application Development with
Java Studio Creator" talk. This was really my first
presentation to such a large crowd. I don't know the exact
numbers but I'm guessing around 400 showed up for the session.
Perhaps it was just my nerves and there were really only
about 5 people in the audience.

The demo gods where not
with me. I did a demo that I've literally done at least 50
times. Can you believe the demo crashed! Ugh!
I tried to pull a
Tor
Norbye demo save but failed so I couldn't do the Tor-Nixon
victory salute. As I sat watching the next presentation my
blunder came to mind. I really wanted to run on stage, push
the presenter out of the way and show the crowd how the demo worked.
In the end the demo went well as I was able to show all the
features I intended. For those of you reading this that wonder what I
did wrong, I didn't include the "Travel:prerender" codeclip which
affected the CachedRowset parameter the FIRST time the page is
show. I even got to throw out some shirts and squishy Dukes.
I always wanted to do that!
I've really enjoyed the people of South Africa. I met lots of
wonderful South Africans and Sun employees. I met Tom Gryder,
the Sun Studio Product Marketing Manager, who manned the Sun tools
booth. Tom and I've been going to dinner together and trying
not to be robbed. We had two men try to steal our ATM cards
while we were trying to take cash out. The one man told Tom
that Tom had to put his card back in the machine to "close" it so the
man could use the ATM. Tom was wise to him and told him to
talk to the bank if he had a problem. Then the man went after
me and I'm a naive small-town dude that didn't catch on right away.
I didn't give him my card in the end. We learned
that this is a scam where they switch your card or swipe it in a
palm-sized device stealing your info. I also met
Geertjan
Wielenga a NetBeans Evangelist who doubles as a tech writer
for Sun. Geertjan was mobbed by NetBeans CD seekers and gave lots of
great NetBeans demos.
I would gladly recommend a trip to South Africa to anyone.
The people speak a funny English.

Despite some difficulty
understanding them, they are truly wonderful!
Cheers!
-David
Posted by David Botterill
( May 04 2006, 07:55:33 PM MDT )
Permalink

|

|
Java Studio Creator 2 AJAX Class at JavaOne 2006
There will be an AJAX and JavaServer Faces class at the JavaOne
University highlighting Java Studio Creator. The class,
"Exploring
AJAX & JavaServer Faces Technology" will
be a FREE bonus class for JavaOne University attendees. From
the class description, the class looks like it will give the student an
overview of JavaServer Faces, an overview of AJAX technology, and then
dive into using Java Studio Creator2 for AJAX development.
This looks like a really good class to get people started.
So, if you're already signed up for Java University,
this is a must-take course. If you aren't going to
Java University on May 15th, you really need to attend NetBeans Day
2006 at the Argent hotel. The conference is free and you can
sign up at the
NetBeans
site.
I'll be hanging around the NetBeans day so please make sure to come
meet me and ask your impossible Creator question.
Cheers!
-David
Posted by David Botterill
( May 04 2006, 06:52:57 PM MDT )
Permalink

|

|
Java Studio Creator 2 Update 1 is Out!
Java Studio Creator 2 Update 1 is out!
This version can run side by side with Java Studio Creator 2.
This version includes:
Check it out at the Creator
downloads page.
Posted by David Botterill
( May 04 2006, 06:40:11 PM MDT )
Permalink

|

|
Wednesday April 19, 2006
Four New Java Studio Creator 2 AJAX Components
Yes I'm still alive. I've been very busy traveling and preparing to travel.
I wanted to make sure the news got out about the new Java Studio Creator 2 AJAX components. You can read all about them here.
Basically the new components are:
- Select Value Text Field – like the text completion component but lets you select the value
- Rich Textarea Editor – allows you to apply formatting to values in the text area
- Buy Now Button – initiates a single-order PayPal transaction
- Rating – a row of stars showing the rating of an item much like the ratings on Netflix.
You can get them quickly by simply going to the update center as described on the link above.
Posted by David Botterill
( Apr 19 2006, 04:04:03 PM MDT )
Permalink
|
|
Tuesday March 14, 2006
Searching For Java Studio Creator Information
The Creator content team has done a great job with the Creator
web site (http://developer.sun.com/jscreator).
They've been
struggling with the daunting task of trying to guess how people think
and how they approach the web site to look for information.
Recently a "Search Java Studio Creator"
search capability has been added to the Overview tab of the
Creator web site to help developers find information. As with
many site searches you can get too much information that in the
end makes finding what you want more difficult. Hopefully this blog
will help.
Does Google Do a Better
Job?
I
did some testing searching for the term "data provider".
Here's the Google advanced search criteria I used. You can see that I
specified "developer.sun.com" as the Domain.

The results where 26 hits. Only one of the hits was
actually on the Creator part of "developer.sun.com". So the
Google search really doesn't do what I want. I really just
want to search the Creator part of the "http://developer.sun.com" web
site which is really "http://developer.sun.com/jscreator".
Using the Search at
"http://developer.sun.com/jscreator"
The search on the Creator site is show below.

This search yields
112
hits and is spread across 5 pages of 10 hits per page. Here's
the results page.
I don't know about you, but I hate to page through search results.
Also, as you can see, many of the hits are on online help.
I would really like to see just articles that are written on
data
providers. I would also like to view at least 100 hits per
page.
Before we go any further, notice the phrase at the top of the
results.
112 Results found for "data provider, +url:http://developers.sun.com/prodtech/javatools/jscreator/" in the "Developer - Reference" tab
This phrase will be important for us to narrow down our search in the
advanced search settings. Next, click on the "
Advanced Search"
link on the right side bar of the results page.
You should immediately notice that you can change the hits per page by
choosing "100" from the "
Results
per page" drop down list. If you do this and
press the "
Search"
button, you'll see that you get
824
results. What? The results grew by about 700!
Now you
need to go back and change the text that was put into the "With
all the words"
entry. You'll need to make it look like the phrase I had you
look at above. So basically you need to put a
comma after "
data provider" and
put a "
+"
before the "
url:".
Now hitting search will yield the same 110 results with 100
showing per page.
Ok, so now you should be asking, "
Why
did the 10 results per page return 112 but the 100 results per page
returns 110?".
The answer is, "I don't know!".

I think this
must be a
defect in the results display. The actual result number is
110.
Next, we want to get rid of the "Online help" entries. To do
this, enter "
,-url:http://developers.sun.com/prodtech/javatools/jscreator/reference/docs/help"
at the end of the "With
all
the words" entry. You can get the information
about site areas to exclude by looking at the URLs in
green.
Of course these URLs will likely change from time to time.
Here's what we get.
As you can see, we've narrowed the search down from
110 to
23. This
is a much easier number of results to work with. Now I can
see that there is an article called, "
Data Provider Components in the Sun
Java Studio Creator 2 IDE".
Lastly, you can
always tweak the URL that
is used to do the search. If you look at the search URL for
what
we just produced, you'll see the following.
http://onesearch.sun.com/search/onesearch/index.jsp?charset=UTF-8
&qt=data+provider%2C%2Burl%3Ahttp%3A%2F%2Fdevelopers.sun.com%2Fprodtech%2Fjavatools%2Fjscreator%2F%2C+-url%3Ahttp%3A%2F%2Fdevelopers.sun.com%2Fprodtech%2Fjavatools%2Fjscreator%2Freference%2Fdocs%2Fhelp
&qp=language%3Aen%2C+%7C%7C+doctype%3Apdf%2Cdoctype%3Ahtml%2Cdoctype%3Axml%2Cdoctype%3Aplain
&rt=1
&cs=0
&nh=100
&rf=0
&col=developer-reference
I've
done the
line breaks to show the different "GET" parameters. You'll
recognize the "&nh=100" is the number of results per page.
The "&qt" is the query text. So conceivably
you could
bookmark this URL and simply change the "data+provider" to the phrase
you want to find. Again remember that the URL semantics could
change and this bookmark could break.
I hope that helps you find what you need for using Creator.
If
you don't find what you're looking for, please, please email
CreatorSiteFeedback@sun.com
for web site feedback and
CreatorDocsFeedback@Sun.Com
for tutorials you need or documentation you're looking for.
Cheers!
-David
Posted by David Botterill
( Mar 14 2006, 04:46:06 PM MST )
Permalink

|

|
Thursday February 02, 2006
Conditional Validation in Java Studio Creator 2
There have been some Creator forum posts lately about delaying validation on some fields when a drop down list selection is made if
“Auto-submit On Change” is selected.
Problem
Here's a typical scenario. You have a drop down list and one or more static text fields. You also have a text field and a button. You want the value of the static text field to changed based on the value selected on the drop down list. You also want the text field to be required when the user presses the button. So you select the drop down list “Auto-submit On Change” and the text field to required. The Creator 2 designer would look something like this.
The effect of this situation causes the text field validation to trigger the “required” when you select a new value for the drop down list. The figure below shows a snapshot of the results of selecting a value from the drop down list.
Solution
There are a couple of ways to address this problem. The overall term for what is being done is called “Conditional Validation”. Conditional Validation should be used when you need to do validation based on logic that goes beyond defining a validator for a field.
First, I need to give the credit for the following solutions to Jayashri Visvanathan and Matt Bohm. Jayashri is an engineer on the Creator 2 team. She has in-depth knowledge of JavaServer Faces since she worked on the JavaServer Faces team with Craig McClanahan. Matt is also a Creator engineer who was in on the ground work of the data providers and the inventor of the virtual forms. He also has in-depth knowledge of the JavaServer Faces life cycle.
Option 1 – Logic in the Action Method
”In your JSF application built using Creator, you might run into a scenario where you want to execute validators only upon button click and not when form submission happens via JavaScript (for example when turn on autosubmit on change on a drop down list). In this case you won't be able to attach any validators on your input components because once you attach them, they will always get executed during “ProcessValidations” phase irrespective of whether the postback happened via button click or form submission. So the work around is to do conditional validation upon button click. So in your button's action handler, you validate your input field and if it failed, return "null" as outcome from your action handler to tell the JSF framework to redisplay the same page instead of processing the navigation rules for the current view. Here is the sample code you can add to your action handler to ensure that textfield is not null when the page is submitted via button click.” - Jayashri
if (textField1.getValue() == null || textField1.getValue().equals("")) {
FacesMessage message = new FacesMessage("Textfield1 is required. Enter a value");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
getFacesContext().addMessage(textField1.getClientId(getFacesContext()), message);
return null;
}
return "success";
With Jayashri's solution, you need to make sure “required” is not selected for the component you are validating.
Option 2 – Logic in The Preprocess Method Before “ProcessValidations”
Matt's solution is implemented differently. Matt's solution will change the required attribute of a component in the “preprocess()” method of the page which happens before the JSF “ProcessValidations”. Here's the designer shot of Matt's layout.
In Matt's example, you don't want to validate the drop down list unless the user presses the “Next Page-->” button. If the user presses the “<--Previous Page” button, you don't want to validate the drop down list but rather allow the user to navigate back. Here's the code that will accomplish this.
public void preprocess() {
FacesContext context = FacesContext.getCurrentInstance();
Map map = context.getExternalContext().getRequestParameterMap();
if (map.containsKey(nextButton.getClientId(context))) {
shippingMethodDropDown.setRequired(true);
} else {
shippingMethodDropDown.setRequired(false);
}
}
The request parameter map is obtained and checked to see if it contains the “nextButton”. If it does, this means the button was pressed and the drop down list is set to “required”. Otherwise, the drop down list is set to NOT “required”.
Again, thanks go to Jayashri and Matt!
Cheers!
-David
Posted by David Botterill
( Feb 02 2006, 09:19:23 PM MST )
Permalink
|
|
Wednesday February 01, 2006
Java Studio Creator, Sun Java System Application Server Platform Edition(PE), and SQLServer
A few weeks ago I was working with Jerry Dunn who contracts for Redox TECH Federal (http://www.redoxfederal.com/). Jerry had installed Sun Java Server Application Server (SJSAS) Platform Edition (PE) and was trying to do a remote deploy from Creator 2. He was getting the following error message in the application server log.
java.sql.SQLException: [sunm][SQLServer JDBC Driver]This driver is locked for use with embedded applications
This exception is thrown from the “smsqlserver.jar” SQLServer JDBC driver. This driver is meant to be used within the SJSAS PE bundled with Creator 2.
There are a couple of options for getting around this.
Option 1 – Use Sun Java System Application Server Enterprise Edition 8.1 2005Q1
If you check out the “Features and Benefits” between Sun Java System Application Server Platform Edition (http://www.sun.com/software/products/appsrvr_pe/features.xml) and Enterprise Edition (http://www.sun.com/software/products/appsrvr_ee/features.xml), you'll notice the Enterprise Edition lists the following.
Integrated JDBC driver collection - Pre-integrated and certified - allowing you to quickly and easily connect your applications to corporate data sources.
So to fix the issue, you can always install SJSAS Enterprise Edition.
Option 2 – Use the jTDS SQLServer JDBC Driver
There is a sourceforge.net project called “jTDS” (http://jtds.sourceforge.net/). This is an open source JDBC driver for SQLServer. You can define a data source in Creator 2 for the jTDS driver and point the data source at your SQLServer database. To do this, follow the instructions in the tutorial “Creating Database Server Types and Data Sources”. When you setup the remote deploy to the SJSAS EE, you need to choose “Data Sources Configured Automatically by JSCreator”. The following diagram shows a snapshot of the dialog.
Creator will setup up the necessary data configurations on SJSAS PE so the Data Direct driver is used as the DataSource driver and the jTDS driver is used for the JDBC driver.
Lastly, you'll need to copy “Creator_install_dir/startup/samples/driveradapter.jar” into the “AppServer_install_dir/lib” directory.
There's a Creator forum discussion around this topic at http://swforum.sun.com/jive/thread.jspa?forumID=123&threadID=51299
Many thanks to Jerry Dunn for helping me work through this.
Cheers!
-David
Posted by David Botterill
( Feb 01 2006, 11:53:42 PM MST )
Permalink
|
|
Tuesday January 31, 2006
Java Studio Creator Portlets: Under the Hood #2 - PortletConfig
This is another in the series of looking under the hood of the portlet development feature for Java Studio Creator 2.
There were many enhancements between Creator 2 Early Access 2 and the final release in regard to portlet development. One such enhancement was to get closer to the goal of fully supporting JSR-168.
Background
In the first article in this series, I discussed how to get portlet preferences. This blog will show the portlet developer how to get “PortletConfig” and ultimately portlet initialization parameters (init-param). Again, let's refer to JSR-168 to see what it says about PortletConfig and portlet init-params. JSR-168 says,
“PLT.6.1 Initialization Parameters - The getInitParameterNames and getInitParameter methods of the PortletConfig interface return the initialization parameter names and values found in the portlet definition in the deployment descriptor.
”
According to JSR-168, the only way to get portlet initialization parameters is to go through the “PortletConfig” interface.
JSR-168 also states that the only way to get PortletConfig is through the “init” life cycle method.
”PLT.5.2.2 Initialization - The portlet container must initialize the portlet object by calling the init method of the Portlet interface with a unique (per portlet definition) object implementing the PortletConfig interface.”
Here's the major problem. Creator uses JavaServer Faces and thus the JavaServer Faces portlet adapter which implements the life cycle methods. This is a shortcoming in JSR-168 because the specification doesn't provide a standard way for a framework, like JavaServer Faces, to provide the PortletConfig to applications leveraging the framework. You'll see below how we decided to expose the PortletConfig through the JavaServer Faces portlet adapter.
I'd like to give a special thanks to Deepak Gothe, the Sun engineer responsible for implementing the PortletConfig exposure in the JavaServer Faces portlet adapter. Deepak accommodated this change just before we pushed out the final release of Creator 2.
One more background issue I should discuss. How does the JavaServer Faces portlet adapter compare with the open source version on java.net? The JavaServer Faces portlet adapter used in Creator 2 has many enhancements to support more of JSR-168 than the version on java.net like supporting modes, PortletConfig, etc. I'm not sure yet whether or not the version used by Creator 2 will be made available on java.net. Hopefully I'll have more info on that later.
Also, keep in mind that JSR-168 mentions two sets of initialization parameters, one set is at the portlet application scope and the other is at the portlet scope. The portlet application level init-params can be obtained through PortletContext. These are the init-params defined in the web.xml file. We will focus on the portlet init-params defined in the portlet.xml file.
Details
First, we must get to the JavaServer Faces ExternalContext. To do this you can either use the following code in the page bean.
FacesContext.getCurrentInstance().getExternalContext();
Or you can go through the session bean like the following.
getExternalContext();
Here's an example of how to access the portlet init-param “test” from the page-bean.
Map applicationMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
if(null != applicationMap) {
PortletConfig config = (PortletConfig)applicationMap.get("javax.portlet.PortletConfig");
this.txtParam1.setText(config.getInitParameter("test"));
}
You'll see that the key is the property name “javax.portlet.PortletConfig”. This property is stored in the application map of the external context.
To test this in Creator, from the project node, right-click and choose, “Edit Portlet Deployment Descriptor”. You'll see a dialog like the following.
Add an init-param with a name of “test” and a value of “Test Value”.
Add a static text field to a portlet page and a button. Double-click on the button and add the source above that goes in the action method of the page bean like this.
public String button1_action() {
/**
* Get the portlet init-param
*/
Map applicationMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
if(null != applicationMap) {
PortletConfig config = (PortletConfig)applicationMap.get("javax.portlet.PortletConfig");
this.txtParam1.setText(config.getInitParameter("test"));
}
return null;
}
When you run the portlet and press the button you should see the static text field with the value “Test Value”.
Cheers!
-David
Posted by David Botterill
( Jan 31 2006, 01:59:21 AM MST )
Permalink
|
|
Wednesday January 25, 2006
Sun Java Studio Creator 2 Available Now!
It's out! That's right, Creator 2 is officially available today. Creator 2 offers a rich new set of components, portlet development, theme support, CSS editing and much much more. Download your FREE copy today and give it a try.
Posted by David Botterill
( Jan 25 2006, 12:00:00 AM MST )
Permalink

|

|
Tuesday January 17, 2006
I'm Retired! Almost
After 23 years of service, I put the uniform on for the last time on January 8, 2006. I'll be officially retired military February 1, 2006. I will retire as a Chief Warrant Officer 3 (CW3) from the Army National Guard. I did four years active duty and the rest in the Army National Guard.
I want to personally thank the Utah Army National Guard for supporting me throughout the years. In particular, I want to thank CW3 Dave Lucero and the DPI section for being such a great team to work with. Here's a picture. I'm the shorter guy in the middle.
The Utah Army National Guard is a wonderful organization that takes great pride in serving the United States of America.
I really didn't have to go through as much hardship as many soldiers have in 20+ years of service. I did the normal service schools basic training, Warrant Officer Candidate School, etc. but I've never had to put my life on the line as many of our brave men and women have in recent years. Whether you agree with our efforts in the middle east or not, please support our men and women in uniform. They serve with great personal sacrifice. Their families serve by plodding along at life while their loved ones are off serving their country. I've never personally met or heard of any soldier an any service of the United States that regrets serving their country. They miss their families and fear for their lives but in the end, they get the mission done with great honor. Thanks to all you who have served and to the families as well. Thanks to the ones who have made the ultimate sacrifice by giving their life for their country. You will not be forgotten.
May God continue to bless the U.S.A!
CW3 David Botterill, Retired
Posted by David Botterill
( Jan 17 2006, 03:18:21 PM MST )
Permalink
|
|
Thursday January 05, 2006
About Me
Current Work:
I currently work for Sun Microsystems, Inc. as a Java Tools Evangelist. I'm fanatical about proper software engineering and loathe and despise hacking (of course unless completely necessary or if my paycheck is on the line.
).
Previous Work:
At Sun I've also worked on the Sun Java Studio Creator engineering team. I've done extensive work on the web service feature and lead the development effort of the portlet development feature. I've also worked on the Jiro Technology engineering team as a Jiro Consultant. My true passion is distributed computing on the Java platform. I really enjoyed working with the Jini Technology. Remote class loading is such an adventure!
I've also worked at Hewlett Packard, Storage Technology Corporation, Morton International, Thiokol Corporation, and the U.S. Army.
Personal:
I live in Greeley, Colorado. I'm very happily married and have four wonderful kids. I retired from the Army National Guard as a CW3 in February, 2006. I love serving God and spending time with my family.
Posted by David Botterill
( Jan 05 2006, 11:05:57 AM MST )
Permalink
|
|
Monday January 02, 2006
Working With Custom Objects as Options in a Drop Down List
I recently got involved helping a user with a problem concerning a “Drop Down List” component and a custom “OptionsList”. Vana, “yovana” on the Creator Forum created a custom “OptionsList” but had the problem where the selected item would not show up. I came up with a simplified example that showed the same problem and though I'd share the problem and solution with everyone knowing that sooner or later, someone else would stumble on this issue.
Problem Statement
You have a drop down list that you want to show items that don't come from a Creator data source. The items are of a custom type. When you select one of these items, you expect the selected item to show selected when it is selected in the drop down list.
Solution
First, lets start by setting up the web application. We do this by dropping a “Drop Down List” component on page1.
Next, we add an property to the session bean by right-clicking on “SessionBean1. Java” in the project navigator and choosing “add property”. In the property dialog, we set “name” to “options” and “Type” to “OptionsList”. Then we edit “SessionBean1.java” and add the following code to the constructor.
/**
* Construct a new session data bean instance.
*/
public SessionBean1() {
this.options = new MyOptionsList();
}
The class “MyOptionsList” looks like this:
package dropdownselect;
import com.sun.rave.web.ui.model.Option;
import com.sun.rave.web.ui.model.OptionsList;
/**
*
* @author David Botterill
*/
public class MyOptionsList extends OptionsList {
Option [] options = new Option[2];
/** Creates a new instance of MyOptionsList */
public MyOptionsList() {
Object [] values = new Object[2];
values[0] = "ID1";
values[1] = "David";
options[0] = new Option(new MyObject(values),"ID1");
values = new Object[2];
values[0] = "ID2";
values[1] = "Jim";
options[1] = new Option(new MyObject(values),"ID2");
this.setOptions(options);
}
}
If you're copy/pasting this code, be sure to change the package name accordingly.
Next, and most importantly, we need to define “MyObject”. Here is that class:
package dropdownselect;
/**
*
* @author David Botterill
*/
public class MyObject {
Object [] objArray;
/** Creates a new instance of MyObject */
public MyObject(Object [] inArray) {
objArray = inArray;
}
public String toString() {
String returnString = "";
for(int ii=0; null != objArray && ii < objArray.length; ii++) {
returnString += String.valueOf(objArray[ii]) + "\n";
}
return returnString;
}
public boolean equals(Object compareTo) {
String thisString = this.toString();
String compareToString = compareTo.toString();
if(thisString.equals(compareToString)) {
return true;
} else return false;
}
}
Two very important things to remember about “MyObject”.
- The “Drop Down List” plumbing will try to set the selected by comparing a “String” value to each item in the list. This means if your custom object is not of type “String” you MUST override “equals”.
- Since the “Drop Down List” plumbing only can use values in the list that are rendered for determining what's been selected, the values will always be the “toString” value of the custom object since the actual Object instance can not be used in a rendered HTML page by the browser. This means the “compareTo” value passed to “equals” will be the “toString” equivelant.
Lastly, we need to bind the “Drop Down List” to “sessionBean1” “options”. We do this by selecting the “Drop Down List” on design view of “page1”, right-clicking and selecting “Property Bindings...”. The following figure shows the dialog that will appear. We then select SessionBean1->options=>options.
I hope this helps those of you hoping do make custom OptionsLists and custom Object types for those lists.
Cheers!
-David
Posted by David Botterill
( Jan 02 2006, 02:51:43 PM MST )
Permalink
|
|
Wednesday November 30, 2005
JSR-286 Portlet Specification 2.0 Started
Yesterday
JSR-286: Portlet Specification 2.0 started. This will be a great opportunity to move the Portlet specification forward. Two areas I thought were lacking in JSR-168 were:
- Interportlet Communication
- Web Framework Support
Fortunately, both of these requirements seem to be addressed in JSR-286.
Cheers!
-David
I was just corrected on the number. The number is 286 and not 268. The number 268 would have been too good to be true!
Posted by David Botterill
( Nov 30 2005, 09:06:36 AM MST )
Permalink
|
|
Tuesday November 29, 2005
Installing Creator on Ubuntu Linux
My laptop hard drive recently went on the blink. I look at a hard disk failure as an opportunity rather than a panic attack. Replacing my hard drive usually gives me the opportunity to try out new Linux distributions. There has been lots of hype around
Ubuntu lately so I thought I would give it a try. I installed Kubuntu (KDE version of Ubuntu) 5.10. Since I had Knoppix on my disk before, I immediately had to get used to the fact that Ubuntu didn't install the world + the universe. This is goodness. One has to remember, however, that more packages will have to be added later. Since Ubuntu is based on Debian, updating and installing are very simple. Don't get me wrong. I really love Knoppix and still run it on two of my personal machines.
So to get to the topic, in setting up my machine for Java Studio Creator development, I ran into a problem installing the Sun Application Server Platform Edition (PE). Since Creator installs PE during its installation, you will see something during the installation complaining about missing libstdc++ libraries. Here's how to get around that.
- do dpkg -L libstdc++5 to see if you already have the libstdc++5 package installed. If you do, a list of the installed files will show up like this:
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libstdc++5
/usr/share/doc/libstdc++5/copyright
/usr/share/doc/libstdc++5/README.Debian
/usr/share/doc/libstdc++5/changelog.Debian.gz
/usr/lib
/usr/lib/libstdc++.so.5.0.7
/usr/lib/libstdc++.so.5
- If you don't see the list of files, you'll need to install the libstdc++5 package by running these commands as root.
apt-get update
apt-get install libstdc++5
- Next you need to create a symbolic link for the library in question by running this command as root.
ln -s /usr/lib/libstdc++.so.5.0.7 /usr/lib/libstdc++-libc6.2-2.so.3
A special thanks to my team mate and fellow Linux head Marco Walther for helping me with this problem. Marco has Suse installed and was able to work out what symbolic links where needed.
Posted by David Botterill
( Nov 29 2005, 08:09:16 PM MST )
Permalink
|
|