Skip to main content

Revisiting the topic : Programmatically disclosing a ShowDetailItem in a <af:panelTabbed>

Sometime back I blogged about Programmatically disclosing a ShowDetailItem in a <af:panelTabbed>. In today's post I'm revisiting this topic to address the same usecase for applications with customization(change persistence) ON. If the customization is enabled you may need to use appropriate ChangeManager APIs for persisting the changes that you do programmatically. Otherwise during rendering  ChangeManager will override your programmatic changes with the state for the component that is persisted in the change manger during the last user interaction. So the code snippet posted in my previous blog post needs to have following ChangeManager APIs as well to make this working for an application that use "Change Persistence/Customization". The precious post has the full code sample. For a complete working sample, you need to change displaySelectedItem(...) given in the last post's sample with the code snippet given below.

import org.apache.myfaces.trinidad.change.AttributeComponentChange;
import org.apache.myfaces.trinidad.change.ChangeManager;
import org.apache.myfaces.trinidad.change.ComponentChange;
import org.apache.myfaces.trinidad.context.RequestContext;
//Other imports...

public class TestBean {
public void displaySelectedItem(ActionEvent actionEvent) {
 RichPanelTabbed richPanelTabbed = getPanelTabbed();
 for (UIComponent child : richPanelTabbed.getChildren()) {
   RichShowDetailItem sdi = (RichShowDetailItem) child;
   boolean isDisclosed = isThisItemToBeDisclosed(sdi);
   if (isDisclosed) {
     ChangeManager cm = RequestContext.getCurrentInstance().
     ComponentChange cc = new AttributeComponentChange(
        sdi, cc);
   } else {
     ChangeManager cm = RequestContext.getCurrentInstance().
     ComponentChange cc = new AttributeComponentChange(
        "disclosed", false);
       sdi, cc);

//Other methods........


You can download the modified sample workspace from here.
[Runs with Oracle JDeveloper  12C ]

How to run this sample?

Run the test.jspx. This page displays drop down list displaying the tab names and a button close to it for disclosing  the selected tab programmatically.


Hitesh Patel said…
WOW...great post...thanks a lot. It has fixed my issue.
Anand Yerrapati said…
Jobinesh, thanks for the post. It helped me a lot to fix my issue.
Jobinesh, brilliant sample, which solved my tab refresh issue... Thanks and well done mate.

Popular posts from this blog

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…