Wednesday Dec 06, 2006

Expanding Evangelism Role, NetBeans 5.5 Visual Web Pack

I'm used to writing more technical blogs and thought I would try, once again, to relay some personal, not-so-technical information.  As many of you know I've been the Java Studio Creator evangelist for almost one year now.  Thanks to all of you that have made that a very enjoyable job!  I'm now expanding my evangelism duties to cover more of NetBeans.  So probably a better title at this point would be "Java Tools Evangelist".  I guess I better order different business cards. :)  

"So what's with the new picture on the blog?"  This is a picture of me next to Juggy in the Czech Republic.  "What about the hat?"  The Czech Republic is very cold in November and I don't have any roofing (hair) so I needed some warmth.  A couple of my Sun co-workers/managers had hats like this so I just had to get one.  Yes it is very warm!  I was in the Czech Republic meeting NetBeans people.  Since I'll also be evangelizing the NetBeans 5.5 Visual Web Pack , I met up with the other NetBeans evangelists and NetBeans engineers.  While I was in Prague, Roman Strobl and Gregg Sporar recorded NetBeans Podcast Episode #17 live!  Roman dissed me trying to explain what wasn't in NetBeans 5.5 Visual Web Pack Technical Preview that was in Java Studio Creator. :) I'll get him back someday somehow. :)
Cheers for now!
-David

Saturday Oct 14, 2006

Java Studio Creator - Changing the Table Columns from A Dropped Web Service

I talked to a developer the other day that had some problems with the results of dropping a web service method on a table.  The table columns were the high level attributes of the returned values but he wanted different values to show up in the table.  This blog will show you how to dig into types returned from web services and display the pieces you want in the table columns..


First, a little about the sample web service.  I created a simple web service to return an array of type "Car".  Here is a class diagram of "Car" as well as the web service end point interface and the implementation.

uml diagram
If you add this web service to Java Studio Creator, you get something like this.

add web service


If you drag the web service method "getCars" onto a table, you'll get a table looking like this.

wrong table stuff

As you can see, the dataprovider was created from the high-level attributes of Car; body, engine, frame and model.  This is really all the code that does the data provider can do to guess at what to show.  But, suppose you really wanted to show the "engine" attributes in the table?  Here's how to do it.

First, drag and drop an "Object Array Data Provider" onto the designer.  This should create "objectArrayDataProvider1" in the Outline window.


object array data provider

At this point, we need to do some coding to fill the new dataprovider with the "engine" attributes.   Here's the code that goes in the "init" method.

public void init() {
...
 // Perform application initialization that must complete
 // \*after\* managed components are initialized
// TODO - add your own initialization code here
/\*\*
 \*  We need to build an Array from the subparts of the car to use in the dataprovider
 \*/
 ArrayList engines = new ArrayList();
 try {
boolean moreRows = myWebServiceGetCars1.cursorFirst();
RowKey currentRowKey = null;
FieldKey engineKey = myWebServiceGetCars1.getFieldKey("engine");
while(moreRows) {
currentRowKey = myWebServiceGetCars1.getCursorRow();
Engine currentEngine = (Engine)myWebServiceGetCars1.getValue(engineKey, currentRowKey);
engines.add(currentEngine);
moreRows = myWebServiceGetCars1.cursorNext();
}
} catch (DataProviderException dpe) {
error("DataProviderException=" + dpe);
}

this.objectArrayDataProvider1.setArray((Engine [])engines.toArray(new Engine [0]));
}

You could just call the web service to get the "Car" array and go through and build the Array.   You will, however, be making another call across the wire which can be expensive.  The web service data provider is created in the "_init" method called in the first part of "init".  When the web service data provider is created, it tries to make a call to the web service to fill in the data.

Now we need to add an "engine" property to the "Page1" of type Engine.  This will allow us to point our new Object Array Data Provider to it.  Add a property to Page1 by drilling down in the Project window

add property

Add a property, "engines" of type "Engine".  Now select the "objectArrayDataProvider1" form the Outline window and change the "array" property to be "engines"

change data provider


Next, select the table, right-click and select "Bind to Data".  From the "Get From Data:" dropdown, select "objectArrayDataProvider1" and press the "Apply" button.  You should see something like this.

changed table


That's it!  You've not successfully created a new data provider and used a different set of values in the web service return to populate the table.


Tuesday Oct 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.

sample textfields

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".

adding 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.

select all

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".

property binding

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.

web app

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

Friday Aug 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

Wednesday Aug 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.

Add web service

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.

server window


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
  1. Select a web service  from the "Web Services" node.
  2. Right-click on the web service and select "Add to page".
context menu
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
  1. Select a web service method from the "Web Services" node.
  2. Right-click on the web service method and select "Add to page".
add method
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
  1. Select a web service  from the "Web Services" node.
  2. 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
  1. Select a web service method  from the "Web Services" node.
  2. 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.

name change


Now isn't that refreshing! :)

Cheers!
-David

Tuesday Aug 15, 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.

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.

working directories

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.

conflict window

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.

jsp with conflict

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.

merged

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.

navigation conflicts


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.

conflict resolution1

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.

  1. 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".
  2. Select the "web/WEB-INF" folder and do a "paste".
  3. You will now have "navigation_1.xml".
  4. Edit "navigation_1.xml" by double-clicking on it and choosing the "Source" view.
  5. Manually change the navigation rules to only include the rules you will be adding/maintaining.
  6. Edit the "web.xml" file by double-clicking on it.
  7. Expand the "Context Parameters" node.
  8. Select the "javax.faces.CONFIG_FILES" line and select "Edit".
  9. In the "Param Value:", add ",/WEB-INF/navigation_1.xml" to the end of the string.  Don't forget the comma separating the entries.
editing web.xml

Wednesday Aug 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.

add META-INF

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.

Saturday Aug 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.

export war

Friday Aug 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.

  1. You should first create a directory called “projectlibs” within the project.  like the following.

    Library reference

  2. 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.  
  3. 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.

library reference

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.

Add Jar

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".

Adding Jars

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.

Regenerate

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.

Missed resources
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.

Sunday Jul 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

Thursday Jul 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.


Changing _USER_ dialog

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

Friday Jun 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".

delete tld folder


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.

library manager

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. :)

proof

Thursday Jun 15, 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

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

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.

NetBeans Web Service Client 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.

Looking for WSDL

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.

wscompile args

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".

Project properties

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.

Backing Code
Cheers!
-David

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

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.

Developers Booth

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.

Registration

More Registration

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.

Professor Judith Bishop

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.

XP Home Dude

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.


Joke Suppliers

Cheers!
-David

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

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 Technologywill 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

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.

Wednesday Apr 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.

Tuesday Mar 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.

Google Advanced Search

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.

Creator Search


This search yields 112 hits and is spread across 5 pages of 10 hits per page.  Here's the results page.


Creator Results


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.

Creator Refined Results

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

Thursday Feb 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

Wednesday Feb 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

Monday Jan 30, 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

Tuesday Jan 24, 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.

Available Free!
Sun Java Studio Creator 2 makes visual web application and portlet development easy. » Learn More

Monday Jan 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”.

  1. 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”.
  2. 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

Tuesday Nov 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.

  1. 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
    
  2. 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
    

  3. 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.

Friday Oct 07, 2005

Java Studio Creator Portlets: Under the Hood #1

So this is the first of hopefully several blogs on looking under the hood of portlet development in Java Studio Creator.

Background

Today I'll cover getting at portlet preferences. First, let's get some background information about preferences out of the way. JSR-168 says:

"Portlet preferences are intended to store basic configuration data for portlets. It is not the purpose of the portlet preferences to replace general purpose databases."

Most portal users would expect to click on the window decoration associated with "EDIT" to get to the settings for the portlet. JSR-168 also puts a restriction on when preferences can be changed. From JSR-168:

Portlets have access to the associated PortletPreferences object while they are processing requests. Portlets may only modify preferences attributes during a processAction invocation.

Details

Enough background, let's get to some code. As stated in JSR-168, you get to portlet preferences through a "PortletRequest". We can get to "PortletRequest" through "javax.faces.context.ExternalContext". Finally, we can get "javax.faces.context.ExternalContext" through the session bean created for each Creator portlet.

From the session bean, the code would look like this:


        ExternalContext externalContext = this.getExternalContext();
        PortletRequest request = (PortletRequest) externalContext.getRequest();
        PortletPreferences portletPreferences = request.getPreferences();

From the page bean, the code would look like this:

        ExternalContext externalContext = this.getSessionBean1().getExternalContext();
        PortletRequest request = (PortletRequest) externalContext.getRequest();
        PortletPreferences portletPreferences = request.getPreferences();

Gotchas

A logical approach would be to associate the portlet preferences with the session bean and let the session bean manage getting the preferences. This works fine for reading the preferences. If you want to save the preferences through "store", however, the Pluto implementation has a "gotcha". Pluto enforces the JSR-168 restriction Portlets may only modify preferences attributes during a processAction invocation. by checking what type of request you're in when you get the preferences. This means if you get the preferences from the session bean when you want to read values to fill in content, the Pluto implemented PortletPreferences record the fact that you got them through a render request. When you go to "store" the preferences, Pluto throws an IllegalStateException exception stating "store is only allowed inside a processAction call". One way around this would be to get the preferences just before you "store" and set the new preferences with values from the existing preferences. Please see the solution below.

Solution

Here's an example of how to manage preferences from a Creator portlet.

  1. Create your preferences page something like this.
  2. Modify SessionBean1.
    snip..
        
        private PortletPreferenceAdapter portletPreferenceAdapter;
    snip...
        public void init() {
    
            portletPreferenceAdapter = new PortletPreferenceAdapter(this);
        }
    snip...    
        
        public PortletPreferenceAdapter getPortletPreferenceAdapter() {
            return portletPreferenceAdapter;
        }    
        public ExternalContext getSessionContext() {
            return this.getExternalContext();
        }
        
    
  3. Create PortletPreferencesAdapter.
    import java.io.IOException;
    import javax.faces.context.ExternalContext;
    import javax.portlet.PortletPreferences;
    import javax.portlet.PortletRequest;
    import javax.portlet.ReadOnlyException;
    import javax.portlet.ValidatorException;
    
    /\*\*
     \*
     \* @author David Botterill
     \*/
    public class PortletPreferenceAdapter {
        
        private PortletPreferences portletPreferences;
        private SessionBean1 sessionBean;
        
        /\*\* Creates a new instance of MyPortletPreferences \*/
        public PortletPreferenceAdapter(SessionBean1 inSessionBean) {
            sessionBean = inSessionBean;
            ExternalContext context = sessionBean.getSessionContext();
            PortletRequest request = (PortletRequest) context.getRequest();
            this.portletPreferences = request.getPreferences();
        }
        
        
        /\*\*
         \* Getter for property name.
         \* @return Value of property name.
         \*/
        public String getName() {
            
            return (String) portletPreferences.getValue("name",null);
        }
        
        /\*\*
         \* Setter for property name.
         \* @param name New value of property name.
         \*/
        public void setName(String name) throws ReadOnlyException {
            
            portletPreferences.setValue("name", name);
        }
        
        
        /\*\*
         \* Getter for property phone.
         \* @return Value of property phone.
         \*/
        public String getPhone() {
            
            return (String) portletPreferences.getValue("phone",null);
        }
        
        /\*\*
         \* Setter for property phone.
         \* @param phone New value of property phone.
         \*/
        public void setPhone(String phone) throws ReadOnlyException  {
            
            portletPreferences.setValue("phone", phone);
            
        }
        
        public void save() throws ReadOnlyException, IOException, ValidatorException  {
            ExternalContext context = sessionBean.getSessionContext();
            PortletRequest request = (PortletRequest) context.getRequest();
            PortletPreferences storePreferences = request.getPreferences();
                    
            storePreferences.setValue("name", this.getName());
            storePreferences.setValue("phone", this.getPhone());
            storePreferences.store();   
        }   
    }
    
  4. Double-click your "save" button and input code something like this.
            try {
                this.getSessionBean1().getPortletPreferenceAdapter().setName((String)this.getTxtName().getText());
                this.getSessionBean1().getPortletPreferenceAdapter().setPhone((String)this.getTxtPhone().getText());
                this.getSessionBean1().getPortletPreferenceAdapter().save();
            } catch(ReadOnlyException proe) {
                log("Portlet ReadOnlyException=" + proe);
            } catch(IOException ioe) {
                log("IOException storing preferences=" + ioe);
            } catch(ValidatorException ve) {
                log("ValidatorException storing preferences=" + ve);
            }
    
  5. Bind your text fields on Page bean to the preferences. In the page bean add this code.
        public void prerender() {
            this.txtName.setValue(this.getSessionBean1().getPortletPreferenceAdapter().getName());
            this.txtPhone.setValue(this.getSessionBean1().getPortletPreferenceAdapter().getPhone());        
        }
    

Friday Sep 23, 2005

Creator 2 EA and Apache's Pluto Portlet Container: Part 2

In my last "blog":http://blogs.sun.com/roller/comments/david/Weblog/creator_2_ea_and_apache about Creator and Pluto, I briefly mentioned how erasing the “plutocontainer” directory in your user directory will reset Pluto.

Let me explain a little bit more about that. If for some reason, your portlet environment, Pluto, seems to be trashed and not working correctly when you deploy from Creator, you can delete the “plutocontainer” directory in your user directory to cause a refresh. The next time you deploy a portlet, the “plutocontainer” directory will be created again for you.

The “plutocontainer” directory is basically Pluto deployed. Now I know some of you will be tempted to experiment with changing things in this directory.

\*CAUTION\*: Please understand that when you do so, you're on your own. Also, I won't guarantee that this implementation will continue in the next release.

The great part is if you mess it up too bad, you simply have to rename it or delete it to get a fresh copy. When the “plutocontainer” directory is created, Creator basically extracts a jar from a jar then unjars it. That's why the “Initializing portlet container. Please wait...” period of a deploy can take so long.

About

David Botterill

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today