Thursday Aug 17, 2006

"More Fun with AJAX




ferris wheel


http://developers.sun.com/ajax/

Get all the info you need to AJAX-enable your web applications on the newly redesigned AJAX website. You'll find more downloads, sample code, and documentation, and more info on surrounding technologies like jMaki, DynaFaces and Phobos. Sign up for free online classes, see demos, and get timely tips from our bloggers. Check out Sun's AJAX site !

Wednesday Jun 21, 2006

Just like to pass on this tidbit of info on Java EE 5:


  • FCS version of the Java EE 5 SDK, Sun's Application Server, a SOA Starter Kit Preview, and Tools Bundle. All of these binaries are free and do not require registration.

  • Additionally, there is a Java EE 5 tutorial available

  • Sun has released a new AJAX-enabled Java Pet Store that runs on the Java EE 5 SDK.

Wednesday Jun 07, 2006

Coming soon, expert Trainers, Gail and Paul Anderson will be holding a 3 day training on Sun Java Studio Creator in San Francisco, CA.

During JavaOne I proctored their Portlet and Web Services lab which was the best lab of the five labs I proctored. Gail and Paul are the authors of the Java Studio Creator Field Guide

Wednesday May 10, 2006

New article on Apple Computer's site for Mac OS X users. Using Java Studio Creator on Mac OS X.


Hope it's useful for users new to Creator
Comments welcome

Thursday May 04, 2006

Now available - Java Studio Creator Training

During JavaOne - Java University Monday, May 15

"Developing Rich Web Applications Visually using JavaTM technology

Java Studio Creator training is coming to a city near you! Learn to develop visual web applications and portlets in just three days. You'll use the tool's bundled JavaServer Faces components to build applications that access a database, EJB components, and Web services. The course also covers portlet design, internationalizing and localizing applications, and AJAX technology. In the hands-on lab you'll you'll build a multi-tiered e-commerce application."
Registration and more info


Cost



The cost for this special training is $1699 per student, which includes
the lab exercises and an early copy of the Java
Studio Creator Field Guide
.
There are a limited number of seats at each location, and registrations
are accepted on a first-come-first-served basis.




Friday Apr 14, 2006

Although I wasn't involved in the effort to produce these JSF-ied AJAX components, the least I can do is help get
the word out. Not a large palette, but some useful ones:


  • Progress Bar

  • Map Viewer

  • Select Value Text Field

  • Rich Textarea Editor

  • Buy Now Button

  • Rating component

  • Auto-Complete Text Field

To obtain these components, assuming you have installed Sun Java Studio Creator 2.0, connect to the Update Center by choosing the menu Tools->Update Center.

In the Update Center dialog, you'll see both HotFixes and Samples. If you haven't already, I highly recommend to get the patches first, then download the AJAX samples.


Now the installation isn't seamless for Creator 2.0 (will be improved in the near future)


1) In the Palette window, right click on one of the node labels (e.g. Basic, the topmost node)and choose Manage Component Libraries
2) Click the Import... button located at the bottom left pane.
3) Click the Browse button and in the open file dialog, go up a directory then open nb4.1 and samples and complib. Then select ui.complib and click the Open button.


Back in the Import Component Library dialog, I just chose the default settings and clicked OK.


Automagically, two new nodes are added to the Palette at the bottom "BluePrints AJAX Components" and "Blueprints AJAX Support Beans"


For tutorials and articles, check out Cool Samples page


Feel free to leave comments about the components or post a topic on our Forum.


If you're attending JavaOne, check out the JavaOne labs . I'll be helping out with the AJAX lab


Happy Easter !

Sunday Apr 09, 2006

It's been awhile, been busy making sure new Articles and Tutorials are tested and ready
for the web. Also, testing bug fixes and some changes, TBD. And developing new testcases
to help identify performance issues.

Since there hasn't been much documentation on Java Studio Creator's lifecycle, I'll mention
a couple of common questions about the lifecycle.


1) (For a Java Studio Creator Web Page) why is backing bean function like bean's constructor, init() ,prerender and others called twice for every page. First when loading the page(which is normal) and second time when leaving the page, e.g clicking a link?


Here's the order described:

Use case: Page1 processes a postback and navigates to Page2:
------------------------------------------------------------------------------- ----------
* JSF executes Restore View on Page1

* Framework calls Page1.init()

* If the application calls isPostBack() from here through destroy(), it will return true

* Framework calls Page1.preprocess()

* JSF executes Apply Request Values, Process Validations, Update Model Values, and Invoke Application on Page1

* NOTE - Update Model Values is when model data is updated through value bindings

* JSF creates new view for Page2

----------------------------------------------------------------


To resolve this for code not to be reexecuted when clicking a link (such as
executing database queries using the CachedRowSet DataProvider, place the code in prerender()

Here is the expected order of lifecycle methods called for a Page1 to Page2 navigation:


Page1:init() called
Page1::beforeApplyRequestValues() called
Page1::preprocess() called
Page1::afterApplyRequestValues() called
Page1::beforeProcessValidations() called
Page1::afterProcessValidations() called
Page1::beforeUpdateModelValues() called
Page1::afterUpdateModelValues() called
Page1::next button action called
Page1::beforeRenderResponse() called
Page2:init() called
Page2::beforeRenderResponse() called
Page2::prerender() called
Page1::afterRenderResponse() called
Page2::afterRenderResponse() called
Page1:destroy() called

2) Same question as #1 except in this case, the code not to execute twice is in a Page Fragment:


Note: in Creator 2, Page Fragments do not contain a prerender() method.


Answer from Craig :


Not having prerender() callbacks in a fragment is a current limitation. In the past, I have worked around this by defining a public method in the fragment's class, and then calling that method from the prerender() method of the surrounding page bean(s). The call would look something like this:


Fragment1 fragment1 = (Fragment1) getBean("Fragment1");
fragment1.fakePrerender();


There are several examples of this technique in the JumpStart Cycles sample application, where it is used to keep the calculations in the price table up to date.


For more examples and discussion on using the Java Studio Creator lifecycle, see the
recently revised Tutorial, Understanding Scope and Managed Beans and also see the
article, Understanding Event Processing Lifecyle

Thursday Mar 02, 2006

Well, the Sun Java Studio Creator Forum been brewing for over 2 years...

Today, March 1, there were 89 posts. Doesn't sound like much of a forum.

However, to this date, there have been nearly 18,000 posts. This number does include posts made by Sun employees, subtract 300 and counting for me.

The great thing about the Forum is that there are developers all over the world using our productand the Forum is a resource to help solve a programming puzzle or report defects and suggest usability enhancements for Java Studio Creator.

We're getting a lot of help from our Community so big pat on the back. I hope we can continue to improve Java Studio Creator and help the developer community produce productive real-world applications. I know of a few developers who have developed applications
which contain over 50 web pages. This leads to an issue, we are working on to improve - performance.

The more pages and components an application contains, unfortunately, the more weight on the IDE.

Back to the Forum, for the first release of Creator, I posted a survey,
"Survey: Top 3 Usability Issues I" This generated 19 replies and consequently we tried to implement these bugs/enhancements in update releases. I filed bug reports and enhancement requests and also make sure Customer bugs are included in Quality Dashboards. Moving on to the second release of Creator, I decided to
post the survey again "Survey: Top 3 Usability Issues II" If you check this out, you'll never guess what the issue is "Performance"

We're doing the best we can to identify areas to be improved. What really helps is if a Developer
has a project which exhibits performance problems then please email to my alias cfqa-testapps AT sun DOT com

Don't get me wrong, we do have a few projects, just not many large 50 page projects.

Thanks to the community again !

Thursday Feb 16, 2006

In previous blog entries, I've briefly discussed a Creator 1.0-built Dashboard architecture and showed some screenshots.

Today, I'll discuss the central point of a Dashboard - how to dynamically populate a Table with relevant data. The features of Creator used to develop such a Dashboard are the Table component, Java ArrayList, POJO (plain old Java object), ObjectArrayDataProvider and CachedRowSetDataProvider and a SessionBean.

First I need to determine the type of data to display. For this example, I want to display Criteria description, status text, status color, and the count (against the Criteria). Each data item will represent a column in a Table. Each column will be represented by a POJO, a Java class with fields and accessors, like a struct in C.

To start, create a new Java Class Library project. In Creator, choose File->New Project | General | Java Class Library. Name the project as QualityDashboardData. Next, from the Project Window, create a new Package by selecting "Source Packages" right-click and choose New Package and assign a name. If you so desire, you can create a extended package by separating each package with a '.' (dot) Next, still in the Projects window, expand the new package, and create a new File/Folder then select "Java Classes" - Java Class and give the new Java class a name, say CriteriaBean.

To use the CriteriaBean POJO, create a new Web Application (or Portlet) project. Next, import the Java Class Library. From the Projects window, expand the Web Application project one level, select Library References, right-click and choose Add Project. Navigate to the Java Class Library project path then add.

In your Web Application, again use the Project window, expand Source Packages then select Page1.java, right-click and choose Add Property. Name the property, qcdata and the type of the property will be an array of type CriteriaBean .

Message Bundles
To make modifcation of criteria easier, put the criteria data in property files. To create a new property file, in the same folder as Page1.java, right click on the package and create a new File/Folder | Java Classes - Property file.

Add some properties and value (note, the best way to edit a properties file is to choose the Open menuitem, not Edit):


criteria0=P1/S1-P2/S2 bugs addressed (incl P3/S2s)
criteria1=All Regressions addressed
criteria2=Customer reported bug count
num_criteria=3

If needed, create other property files for additional data , such as to hold SQL queries.

Next, in Page1.java, you'll need to load a properties file:
props.load(getClass().getResourceAsStream("/qualitycriteriadashboardweb/criteria.properties"));


To use the CriteriaBean POJO, you'll need to set the size of the array and instantiate each element. The reason for using an array is that an ObjectArrayDataProvider supports arrays. Each instantiation of an element of the array creates a row, just like a database row. DataProviders treat any data the same,whether the data comes from a JDBC rowset, Enterprise JavaBean or Web Service. Check out the Javadoc for DataProvider.


// ( number of quality criteria ) to track
this.qcdata = new CriteriaBean[cpm.getNumCriteria()];
for (int i =0; i< qcdata.length; i++) {
this.qcdata[i] = new CriteriaBean();
}

Notice the size of the POJO is obtained from the property file above.
Also, you will see a red squiggly line where CriteriaBean is used. To resolve this, right-click on the Page in the Java view and choose Fix Imports.

Next, since there are multiple rows, depending on the number of criteria. Notice in the property file above, the criteria are indexed. The number of criteria must match up for any other data. If you have property files for SQL queries then the number of SQL queries must be the same as the number of criteria. To hold data for multiple rows, hold data per column using ArrayLists.

Basically, retrieve the values from the property files and store in the corresponding ArrayList. For example, for SQL queries which return a count, store the count in an ArrayList named count.
Speaking of SQL queries, here is how to retrieve a count from a query using a CachedRowSetDataProvider. Create a new page, named criteria.jsp and add a Table component and drop a database table rowset onto the page (don't drop the rowset directly on the table). Instead use the Table layout customizer to bind the Table component to the CachedRowSetDataProvider

try {
change_requestsRowSet.setDataSourceName("java:comp/env/jdbc/bt2");
change_requestsRowSet.setCommand(query);
change_requestsRowSet.setTableName("CHANGE_REQUESTS");
change_requestsDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet)getValue("#{SessionBean1.change_requestsRowSet}"));
change_requestsDataProvider.refresh();
change_requestsDataProvider.cursorFirst();
count = (new Integer(((BigDecimal)change_requestsDataProvider.getValue("qcount")).toString())).intValue();
change_requestsRowSet.release();
change_requestsRowSet.close();
} catch (Exception ex) {
log("Error Description", ex);
}

Notice the setCommand statement. The query is generated dynamically based on the criteria item. The criteria item is obtained by using request parameters. The parameter passed to a page is the value of the corresponding criteria (no Priority 1 defects). This means the query has contraints on priority 1 defects and possibly other constraints. I'll explain more about how to setup the url with a request parameter a little later.

Here's how to get the request parameter.


HttpServletRequest request = (HttpServletRequest)getExternalContext().getRequest();
Integer item = new Integer(request.getParameter("criteria_item").substring(0));

Next to populate the ObjectArrayDataProvider, first populate the CriteriaBean array instances in Page1:


for (int i =0; i< qcdata.length; i++) {
qcdata[i].setCriteria_values((String)pm.getCriteria_values().get(i));
qcdata[i].setStatus((String)pm.getStatus_values().get(i));
qcdata[i].setStatusColor((String)pm.getStatusColor().get(i));
qcdata[i].setCount((Integer)pm.getCounts().get(i));
qcdata[i].setIndex(new Integer(i));

}

Notice the status value, well there are some conditions I set to determine the resulting color. Constraints may have differing status, such as Red/Green or Yellow/Green. Red indicates the criteria is not met and must be resolved. Yellow, indicates that criteria is not met, but may be acceptable at a particular stage of a release. An example of a yellow colored criteria is the evaluation of lower priority bugs.

Also, notice the status color. Actually, this field holds the url value of an image, where there are red, yellow and green ball images used. For the count the value is an Integer, however, this value is assigned to the value of a hyperlink component. The hyperlink component is used to navigate to a details page which shows the nitty gritty details of defects' status.

The final step is to bind the ObjectArrayDataProvider's array property to the CriteriaBean array instance. To do this switch to the Page1 design view and select the ObjectArrayDataProvider in the Outline, then in the Property sheet, there is an array property and a dropdown to select the value. Bind the array property to qcdata.

Also, for the Table, change the component type for the status color to be an Image and change the component type of count to be a hyperlink. Next, select the Table, right-click and bind the Table to the ObjectArrayDataProvider. The columns should automagically become defined. Next, select the hyperlink representing count and set the url property to http://myserver:28080/mydashboard/faces/criteria.jsp?criteria_item=#{currentRow.value['index']}

Notice the '?' This is the final piece for completing the setup of the request parameter. The page criteria.jsp just contains a table, setup for the request parameter and binding to a query, which is defined in a properties file.

Here's some jsp source showing the component bindings to the Bean properties (I removed the Table's Javascript to make it easier to read):


Running Creator 2.0 Dashboard
(Click image for full size)



Here's the final result, at runtime:

Running Creator 2.0 Dashboard

Running Creator 2.0 Dashboard

I tried to be fairly complete and concise. If there's questions, please post comments. I hope to write a technical article to explain Dashboard development, fully.

Glad to be back! I spent a few days in Capitola and Santa Cruz CA with my dog while my wife
was out of town. I found a great deal at a Best Western in Capitola - less than $100.00 including
my dog! Yes, they allow pets. Nice clean, motel and close to beaches.


First stop was Moran State Park Beach. A quaint beach, just a beach, nice place for a picnic.
The second beach was Twin Lakes Park / Harbor Beach. A couple of restaurants, but still has a local
flair, not too touristy. Pretty large beach, with a small harbor and a lighthouse.


Highly recommend if you're visiting the San Francisco Bay Area.



Twin Lakes Park, Santa Cruz
Twin Lakes Park, Santa Cruz



Twin Lakes Park
Twin Lakes Park, Santa Cruz



Jessie in Harbor Beach
My dog, Jessie at Harbor Beach



Harbor Beach scene
Harbor Beach scene



Harbor Beach 2


Harbor Beach lighthouse

Friday Jan 27, 2006

Using Sun Java Studio Creator , and executing an application, how could HTTP Status 500 error occur when the server is up and running ???

The bundled application server is still running, so what's wrong?

Well, here's a couple of reasons
1) Database or SQL syntax error
2) Null pointer exception in your application.

To find out exactly what went wrong, check the bunder Server log file

Open Servers window, select the Deployment Server node , right-click and
choose Server log

hope this helps

Update: To retrieve the server log file for Visual WebPack and NetBeans, click on the Runtime tab, select Tomcat, Sun Java System Application Server or JBoss and choose View Server Log. The server log file will appear in the Output window. In the Output window, type Ctrl-A to select all then Ctrl-C to copy. Then the contents can be pasted in an editor or email

Some of you may have heard of the Sun J2EE application, Adventure Builder Blueprint. To show the types of applications which can be built using Sun Java Studio Creator work was started just
before EA for JavaOne. Architecturely, the applications are different, but the look and feel is similar.


Originally AdventureBuilder was developed for Java One by
Chris Kutler (see the Divas blog) then somehow control of the application changed hands and ended up with another group.


I didn't hear about for awhile until I started attending the Creator Content meetings. Content is responsible for the Sun Java Studio Creator website, Tutorials, Technical Articles, ... I'm involved with Content since I was assigned the Quality Assurance rep just after the EA2 release of Creator.

Anyways, Adventure Builder development started in EA. Never never develop production quality software using Beta. Duh! Well lack of time/resources to redo from scratch, I tested, made some enhancements and fixes to the code.

Since just a couple of Engineers were working on this application and it wasn't a full-time job, the application is not perfect, but I think it's a decent example of how to build an application using Creator.

Please send me any feedback on this sample application. Thanks!



Note: if anyone has a Creator-built application which they started in EA, you'll need replace those Buttons with the final-release-version buttons. Best yet, to redevelop from scratch. Some components have really been improved since EA, such as Calendar, Tree and a few others.

Wednesday Jan 25, 2006

Top Ten List (new features plus) for Sun Java Studio Creator 2

It's about time - here it is -
an awesome, serious Web and Portlet Development Tool

Search Sun's blogs for lots of talk about the latest Development
Environment from Sun Microsystems, keyword = Creator

Taking a page from David Letterman ...

10. Improved platform - Updated Development Environment UI plus source code Version Control and Task Management

9. Data Provider

8. Content Not really a feature but helps users get up-to-speed

7. Improved Lifecycle

6. Portlet Support

5. Asynchronous JavaScript And XML (AJAX) Sample components

4. EJB client support

3. CSS Editor

2. Virtual Forms

1. New Useful Components

Sunday Nov 20, 2005

"Free" Product Defect Dashboard


Some call it a bug, metrics or quality dashboard or just plain quality report. It's immeasurably valuable for keeping the product cycle in check. When running on the company intranet, an entire product team can view and track product quality, such as the number of defects currently open, find and fix rates, the list of defects to fix by engineer, list of fixed defects to evaluate, ...


Creator is perfect for developing Quality Dashboards. For one, Creator is now free (please ignore the morbid looking header image). In this entry, I'll show how easy it is to produce a Dashboard using Creator 2 EA2. I'm presuming that the implementor has SQL access to the bug database. Creator supports the major databases, Oracle, Microsoft SQL Server, DB2, Sybase
and even MySQL using the MySQL JDBC 3.1 driver.

Predefined list of supported databases



Adding the MySQL driver


If you're proficient in SQL, write an SQL query. You can write and test a query using Creator.







In the Servers pane...
Add a datasource for your database. Select the datasource, expand to select the table to execute a queries against, right-click and choose View Data Here you can execute your query. The query can be pasted here with Ctrl-V


Once the query is returning the desired results, create a new Web Application. From the Palette window, drop a Basic Table onto the Designer white grid area.


Then expand your Datasource to find your table (or view)
Next, drag and drop the table onto the Designer (not the Table component). Next, in the Outline window, find the SessionBean1 node and select the rowset just added.
As the rowset is selected, the Properties window will show the rowset's properties. See the "command" property. Copy/Paste the query written above as the command property's value

Rowset Command


Next, select the Table component, right-click and choose Table Layout. Here you can bind the Table component to the database table (through the
CachedRowSetDataProvider)



Table (component) customizer


A CachedRowSetDataProvider, which represents the database table binds to the Table. The Table component's columns will get filled in with the identical name as the names of your
database table's columns.


If a binding error occurs, you may see the Component Error page. Then you should go back and test your query using View Data as mentioned above.


If all's well, click the Green arrow at the top.
Now this deploys to your local Sun Java Application Server.
To make your dashboard accessible by others, install Creator on a remote server. Then you can add this remote server to Creator through the Server window.


If there's an error, check the local Deployment Server's log file - there's a context menu in the Servers window for the local Deployment Server.

In the Add Remote Server dialog, I suggest to choose the "Data Sources Automatically Configured by JSCreator"
A driveradapter.jar file will be created and you'll have to copy this to the lib folder under
the Sun Java Application Server installation and restart Sun Java Application Server.



Adding a remote server



Next look in Projects and right-click on Project name and choose Deploy to Remote Server. Now you'll have the application running on http://remote_server:28080/qualitydashboard


Something like this (confidential stuff smudged)
Sample Dashboard
For Creator releases, I have one dashboard setup just the same way. The Personal edition is not a production server and there might be 10 users accessing simultaneously, but this App Server stands up.


If a dashboard requires multiple "reports" contained in Table components so multiple queries are executed then it will take awhile for the page to load. To get around this I use an open source test library called HttpUnit. The idea is to produce an html file which is produced only when needed, every couple of minutes or so, depending on how long it takes to execute a query. Basically your server requires a JDK installation, then write a simple HttpUnit program. Here's one below:




import com.meterware.httpunit.*;
import java.util.*;
import java.io.*;

public class QDBMain {

public static void main(String argv[]) {
String url = "http://server:28080/qualitydashboard";
String result = "";
WebRequest req = null;
WebResponse resp = null;
TableCell statusCell = null;
WebTable statusTable;
WebConversation wc = null;
Enumeration keys = null;
String pageContents;

try {

wc = new WebConversation();
req = new GetMethodWebRequest(url);
resp = wc.getResponse( req );
pageContents = resp.getText();

} catch (Exception e) {
pageContents = "Dashboard is down";
System.out.println("Site is down: " + e);

}

}

}



Next, assuming your server is running Linux or Solaris or other, write a shell script and create a cron job:


#/bin/bash
cd /usr/local/bin/dashboards/scripts/
CLASSPATH=.:/home/jbaker1/classes/httpunit/httpunit-1.6/lib/httpunit.jar:/home/jbaker1/classes/httpunit/httpunit-1.6/jars/Tidy.jar:/home/jbaker1/classes/httpunit/httpunit-1.6/jars/js.jar
export CLASSPATH
java QDBMain > QDBMain.html

# Only copy the resulting html file if expected html was produced
UP=$(grep Thresher QDBMain.html)
if [[ -n $UP ]]; then
cp QDBMain.html uptime
cp QDBMain.html /home/jbaker1/public_html/qcdb_fcs
fi




Next, create a cron job to execute this shell script as frequently as needed.


Now users only depend on the company web server. If you're using Linux, Soloris or other flavor of *NIX, The html file can be created in public_html of your user directory. Now there's no load on your Creator-installed Sun Java Application Server, PE.


If you'd like to learn more about HttpUnit, see http://httpunit.org. Also, I've written an article posted on the NetBeans site.

Friday Oct 14, 2005

Cool I received some feedback for my new blog ! As requested - here's some screenshots of Dashboards I've created using Sun Java Studio Creator (1.0 and 2.0 EA)

These applications are used by the Engineering team to help gauge progress. Most have been developed using Creator 1.0, but I have started moving and developing new applications in 2.0 pre-release, which also, in turn helps flush out bugs in 2.0.
I'll explain in detail later how to create these applications. At a high-level, in 1.0, I stuffed data into an ArrayList which I bound to a JSF Standard DataTable. In 2.0, I stuff data into an Option array which is bound to an ObjectArrayDataProvider and in turn is bound to a new Basic Table component. See the screenshot of the nice looking Table component in 2.0, below.



Quality Dashboard - dummy data which shows how close we are to meeting our Quality Criteria (fixing Priority 1 defects, Customer defects, etc.)


1.0 DataTable used to
show data against Quality Criteria


1.0 DataTable showing dummy defect data for a module of Creator

1.0 DataTable showing dummy defect data for a module of Creator


1.0 DataTable showing a Creator metrics scheme I came up with

1.0 DataTable showing a Creator metrics scheme I came up with


2.0 EA start page for retrieving Fix/Find defect data

2.0 EA start page for retrieving Fix/Find defect data


2.0 Table component showing Fix Find dummy data for the datacomponent module of Creator

2.0 Table component showing Fix Find dummy data for the datacomponent module of Creator


Here's a graph produced using JFreeChart from jfree.org produced from dummy data for the datacomponent module of Creator

Basically JFreeChart is a library added to the Web Application.

JFreeChart Graph produced from dummy data for the datacomponent module of Creator


Weekly Defect Fix / Find Rates

Weekly Defect Fix Find Rates