Saturday Jan 14, 2006
Saturday Jan 14, 2006

The Table tutorial will not be available for awhile, so here is a mini-tutorial on putting links in tables. It is another quick and dirty tutorial that assumes you know how to do things like bind to database tables and add bean properties.
return hyperlink1.getText().toString();
Let's say that you do not want to show the product code in the table, but you instead want the descriptions to be links to the detail pages and the detail page for a product still be different depending on the product code. Here is how you would do that.
// Find out what row was clicked
RowKey rowkey = tableRowGroup1.getRowKey();
// Save product number so detail page knows what product to
// provide detail info for
getRequestBean1().setProductNum(
product_tblDataProvider.getValue(
"PRODUCT_TBL.PRODUCT_NUM", rowkey).toString());
// Go to the detail page for that product's type
return product_tblDataProvider.getValue(
"PRODUCT_TBL.PRODUCT_CODE",
rowkey).toString();
Right-click and choose Fix Imports. You might see a red squiggly line under the statement that calls getProductNum. This should go away after you build the application. Sometimes the synchronizer doesn't notice changes to the request bean until you compile all the files.
Run and test.
Now, let's say that you only want people to go to detail pages for HW and SW.
Here is how to disable the links for all other product codes.
private boolean linkDisabled;
public boolean isLinkDisabled() {
String productCode = product_tblDataProvider.getValue(
"PRODUCT_TBL.PRODUCT_CODE",
tableRowGroup1.getRowKey()).toString();
if (productCode.equals("HW") ||
productCode.equals("SW")) {
return false;
} else {
return true;
}
}
What if you only had two types of detail pages, one detail page for HW, SW, and FW and one detail page for all the other product codes. How would you do that? See if you can make it happen.
Thanks to Felix and Fredrik who motivated me to write this blog entry.
Friday Jan 06, 2006

We have received quite a few requests for a tab tutorial. We are working with the engineers to come up with a good sample application. It will be awhile before we publish that tutorial, so here is a quick bare-bones mini-tutorial of how to use a TabSet component to set up page navigation.
BannerPF.A and B.Page 1 and Page 2.Page 3 and Page 4.

immediate property to true (check the checkbox). Whether you do this or not depends on whether you want people to be able to tab to another page without validating the page that they are on. Setting the immediate property to true means that the pages won't go through validation when
the user clicks a tab. The pages will still go through validation
when the user submits the page by clicking a button or changing
a value in an Auto-Submit on Change component. tab1_action method.
public String tab1_action() {
tabSet1.setSelected("tab3");
return "case1";
}
tab1_action() method. Then, in the Outline
window, select tab3. In the Properties window, click the
ellipsis button (...) for the action property, choose
tab3_action from the drop-down list, and click ok.
Repeat for every tab and subtab. When you are done, the
action property for each tab must name its action handler.
public String tab2_action() {
tabSet1.setSelected("tab5");
return "case3";
}
public String tab3_action() {
return "case1";
}
public String tab4_action() {
return "case2";
}
public String tab5_action() {
return "case3";
}
public String tab6_action() {
return "case4";
}
<navigation-rule>
<from-view-id>/*</from-view-id>
<navigation-case>
<from-outcome>case1</from-outcome>
<to-view-id>/Page1.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/*</from-view-id>
<navigation-case>
<from-outcome>case2</from-outcome>
<to-view-id>/Page2.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/*</from-view-id>
<navigation-case>
<from-outcome>case3</from-outcome>
<to-view-id>/Page3.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/*</from-view-id>
<navigation-case>
<from-outcome>case4</from-outcome>
<to-view-id>/Page4.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<ui:tabSet binding="#{BannerPF.tabSet1}" id="tabSet1" selected="tab6" style="position: absolute; left: 0px; top: 0px">
Delete the selected="tabn" parameter. This is
important. If you don't do that, then the current tab doesn't
always highlight correctly because this JSP code is resetting
the current selected value.
selected parameter from the JSP code. The
IDE will keep sticking it in whenever you click on one of the
tabs in the Visual Designer. So, if your tabs look like they aren't
working, this is the first place to look (the selected
parameter in the JSP).As with any quick and dirty write-up, I am sure I left something out, wasn't detailed enough when I needed to be, or didn't take into consideration a common scenario that most people want to do. Post questions and frustrations to the comments.
Sept 2006 Update: SDN member MWH@Keystroke pointed out in the Sun
Java Studio Creator forum a common scenario that
this doesn't cover. I updated the tab1 and tab2 actions to better handle
switching back to the major tabs. MWH replied as follows with
some good points to remember:
"Of course there is still the issue that if you select tab 'B', then 'Page 4' within tab B; then select tab 'A'; then return to tab 'B' by selecting 'B' you return to 'Page 3' not 'Page 4'. The developer must maintain the state of each level 1 tab, say via a session bean and restore the proper state when the level 1 tab is selected. When tab 'B' 'Page 4' is selected, set the value in the session. When tab 'B' is selected, retrieve the last level 2 sub tab selected and set it via the tabset1.setSelected('xxx') method. That way the system returns the user to the proper state relative to tab 'B'. Of course the same holds for tab 'A'.
The key is that developers need to understand they are explicitly responsible for keeping the tab state and navigation state in synch if they are using tabsets for navigation from within a page fragment. Which is quite different from using the tabset object from within a single page."
Thursday Dec 15, 2005
I just finished upgrading the
Using Databound Components to Access Databases
for the final release of the product. Because this upgraded tutorial won't be published until after the final Creator 2 release comes out, I thought I would share the following piece of information that I added to the tutorial. I have seen several posts on the EA forum where people are asking how to reposition the cursor to a different table row. The answer is to call tableRowGroup1.setFirst(zero-based-index-value);.
If you use the table paging feature on a master detail page that is like the one in the tutorial (a drop-down list for the master data and a table for the detail data), you will see that when the user selects a different choice from the dropdown list, the table displays new data, but stays on the current page. For example, if the user switches to page 2 and then chooses a new item from the dropdown list, the table shows the second page of data for the new selection. To fix the problem, add the following code after the tripDataProvider.refresh() statement in the master component's value change event handler: tableRowGroup1.setFirst(0);. This ensures that the first page is always displayed when a new name is selected from the drop-down list.
A new tutorial, GoogleSearch Web Service Portlet, will be added to the EA tutorials page, hopefully today or tomorrow.
The upgrading of the Referencing Class Libraries tutorial from Creator 1 to Creator 2 was low on our priority list. However, several people sent a request for this tutorial to the CreatorDocsFeedback@Sun.Com alias. So, we have upgraded this tutorial and it is going through the engineering review process. Your input matters to us, so please continue to submit tutorial suggestions.