| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Apr | ||||||
| 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 | |||
Working with JDEV 10.13 and JSF is a lot better than the old version and UIX. One of the new features that I have found useful is the ShowOneTab and ShowDetailItem components of ADF Faces. One area that that I could not find built into the ShowDetailItem was the ability to have it automatically store the state of what detail item was being shown. Any time you navigated off the page and came back it would reset to the default first detail item. This article will show you a way to store the state and make the pages sticky.
7. Open your new class and enter your code for storing and getting the page state:
package demo.view;
public class pageStatus
{
private String _stickyActiveTab;
public pageStatus()
{
_stickyActiveTab = “”;
}
public String getStickyActiveTab()
{
return (String) _stickyActiveTab;
}
public void setStickyActiveTab(String Value)
{
_stickyActiveTab =Value;
}
}
8. Select the first ShowDetailItem in the structure panel, right click and select Create method binding for disclosurelistener:
9. In the disclosure listener you place your code to set the bean value for the page. There are probably better ways to handle this then the way I worked it. However, I needed to get this done in a hurry and my way is working just fine in my app. For those of you that have a better method please drop me a note. In face using the disclosure event date would probably be the best way to work it.
public void showDetailItem1_disclosureListener(DisclosureEvent disclosureEvent)
{
if (this.showDetailItem1.isDisclosed() )
setManagedBeanValue(”pageStatus.stickyActiveTab”, “TAB1″);
if (this.showDetailItem2.isDisclosed() )
setManagedBeanValue(”pageStatus.stickyActiveTab”, “TAB2″);
}
10. The setManagedBeanValue is from the SRDEMO that the oracle guys put together. You can place that file in your project or use the snippets from this article.
public static void setExpressionValue(String expression,
Object newValue) {
FacesContext ctx = FacesContext.getCurrentInstance();
Application app = ctx.getApplication();
ValueBinding bind = app.createValueBinding(expression);
Class bindClass = bind.getType(ctx);
if (bindClass.isPrimitive() || bindClass.isInstance(newValue)) {
bind.setValue(ctx, newValue);
}
}
public static void setManagedBeanValue(String beanName,
Object newValue) {
StringBuffer buff = new StringBuffer(”#{”);
buff.append(beanName);
buff.append(”}”);
setExpressionValue(buff.toString(), newValue);
}
Figure 1 - Selected Second Tab then moved to next Page
Figure 2 - On Second page
Figure 3 - Navigate back to the first page and our tab is still set.