Friday Jan 06, 2006
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."
"Important: Every time you edit the page fragment, you have to remember to remove the 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. "
This seems more like a bug. a cute idea to update the selected property based on the last tab designed but ...
I would have preferred that it went by the value set by the user in the properties of the tabset.
Do you know what's the behavior in 6.0?
apologize if this is the wrong forum to raise this issue.
Thanks,
Posted by jares on September 28, 2007 at 01:21 PM PDT #
Jares,
I thought they were fixing this, but I am not seeing it yet.
Here is one bug submitted about this issue (they seem to imply that something is fixed in Woodstock -- the next gen visual web components)
http://www.netbeans.org/issues/show_bug.cgi?id=94007
One workaround is to add a String property (e.g., String whichTab, void setWhichTab, String getWhichTab) to the page and bind the TabSet component's selected property to this String property. Call the property's setter method from the prerender method.
Posted by Diva #2 on September 30, 2007 at 04:42 PM PDT #