Implementing Your Drop Down List
Follow these steps to insert some Java code for implement the functionality of drop down list:
- Double-click on the drop down list component (now you should see the cursor in the dropDown1_processValueChange method)
- Paste this code into it:
Object categoryId = dropDown1.getSelected();
try {
categoriesDataProvider.setCursorRow
(categoriesDataProvider.
findFirst("CATEGORIES.CATEGORYID", categoryId));
getSessionBean1().getProductsRowSet().setObject(1, categoryId);
productsDataProvider.refresh();
form1.discardSubmittedValues("virtualProducts");
} catch (Exception e)
{
error("You can't select the " + categoryId + " category!");
log("You can't select the " + categoryId + " category!", e);
}
- Locate the
prerender method (in the upper part of the window) and paste this code into it:
if (dropDown1.getSelected() == null)
{
Object firstCategoryId = null;
try {
categoriesDataProvider.cursorFirst();
firstCategoryId =
categoriesDataProvider.getValue
("CATEGORIES.CATEGORYID");
dropDown1.setSelected(firstCategoryId);
getSessionBean1().getProductsRowSet().setObject
(1, firstCategoryId);
productsDataProvider.refresh();
} catch (Exception e)
{
error
("You can't select the " + firstCategoryId + " category!");
log
("You can't select the " + firstCategoryId + " category!", e);
}
}
Now, you should be able to run the application for the first time. Simply right-click on the project name in the Projects window and select the Run Project item (or, in the Run menu select Run Main Project item). Notice that the table displays the products from the first category. If you choose a different category, the table is automatically updated (see Figure 4).

Figure 4: Running the application.
Implementing insert
Following these steps:
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.