Hi,
Jdeveloper 11.1.1.7 & ADF BC
In our ADF application client have a requirement like :
User successfully login into portal.Let say the home page have multiple region(e.g : 3).
Now we want to interchange the region on click move up , move down icon. To achieved functionality we have used
<cust:panelCustomizable id="pc1">
<cust:showDetailFrame text="My Products" id="sdf1"/>
<cust:showDetailFrame text="My AutoSupport" id="sdf2"/>
<cust:showDetailFrame text="My AutoSupport" id="sdf3"/>
</cust:panelCustomizable>
This components.
At the same time client have a requirement like :
We have a link "Show/Hide Regions" . On click this like one pop up will open with along 'My Products','My AutoSupport','My AutoSupport' drop down items.
On click any of the drop down link that region we will be invisible and at the same time clicked region name colour will changed from
active state to inactive state.Once again click on inactive region link , that region will come again and clicked region name colour will changed from
inactive state to active state.Let say any of the region is invisible .Now after logout and login into portal user will see the rest of the region
and the position what was there before logout and at the same time inactive link will also shown.
To achieved position coordinate and visible,invisible functionality we are storing data in MDS.
Problem description :
We are able to achieved all the functionality(position coordinate , visible,invisible,link colour change).But the problem is coming
when we have deleted one region after that we want to interchange rest of the region ,after that click the "Show/Hide Regions" link.Here null pointer
exception is coming.What we have understood for particular this scenario is that when we delete the region and after that if will inter change the
position for other region, then MDS is not able to get deleted region information.
.jspx page
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
xmlns:pe="http://xmlns.oracle.com/adf/pageeditor"
xmlns:cust="http://xmlns.oracle.com/adf/faces/customizable">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document id="d1">
<af:popup id="p1">
<af:panelGroupLayout id="pgl15" layout="vertical"
styleClass="dsSettingFlyout">
<af:image source="/images/downloadArrow-up-ico.png" id="i2"
inlineStyle="position:absolute; margin-top:-15px; margin-left:90px; width:14px; height:10.0px;"/>
<af:panelGroupLayout id="pgl27" layout="vertical"
styleClass="dashboardSettingDiv">
<af:commandImageLink text="My Products" id="cl2"
partialSubmit="true"
binding="#{customizeBean.productWidgetLink}"
styleClass="#{customizeBean.productWidgetLinkStyleClass}"
actionListener="#{customizeBean.onProduct}"
icon="/images/preview-big-ico.png"/>
</af:panelGroupLayout>
<af:panelGroupLayout id="pgl24" styleClass="dashboardSettingDiv"
layout="vertical">
<af:commandImageLink text="ASE Corner" id="cl6" partialSubmit="true"
styleClass="#{customizeBean.aseCornerLinkStyleClass}"
icon="/images/preview-big-ico.png"
actionListener="#{customizeBean.onAseCorner}"
binding="#{customizeBean.aseCornerLink}"/>
</af:panelGroupLayout>
<af:panelGroupLayout id="pgl23" styleClass="dashboardSettingDiv"
layout="vertical">
<af:commandImageLink text="My AutoSupport" id="cl5"
partialSubmit="true"
styleClass="#{customizeBean.autoSupportLinkStyleClass}"
actionListener="#{customizeBean.onAutoSupport}"
binding="#{customizeBean.autoSupportLink}"
icon="/images/preview-big-ico.png"/>
</af:panelGroupLayout>
</af:panelGroupLayout>
</af:popup>
<af:form id="f1">
<af:pageTemplate viewId="/oracle/webcenter/portalapp/pagetemplates/pageTemplate_globe.jspx"
value="#{bindings.pageTemplateBinding}" id="pt1">
<f:facet name="content">
<pe:pageCustomizable id="pageCustomizable1">
<cust:panelCustomizable id="panelCustomizable1" layout="scroll">
<af:panelGroupLayout id="pgl5_customizeDashBoard"
layout="vertical"
styleClass="AFStretchWidth customizeDashboard">
<af:commandImageLink text="Hide/Show Widgets" id="cl1"
icon="/images/icon_lookup.png"
clientComponent="true">
<af:showPopupBehavior popupId="::p1" triggerType="click"
align="afterEnd" alignId="cl1"/>
</af:commandImageLink>
<af:spacer width="10" height="10" id="s2"/>
</af:panelGroupLayout>
<af:panelGroupLayout id="pgl1" inlineStyle="width:968px;">
<cust:panelCustomizable id="pc1">
<cust:showDetailFrame text="My Products" id="sdf1"
showMinimizeAction="none"
showMoveAction="menu"
showResizer="never" background="light"
binding="#{customizeBean.productWidget}"
styleClass="widgetHeaderText"
contentStyle="height:330px;">
</cust:showDetailFrame>
<cust:showDetailFrame text="ASE Corner" id="sdf2"
showMinimizeAction="none"
showMoveAction="menu"
showResizer="never" background="light"
binding="#{customizeBean.aseCornerWidget}"
styleClass="widgetHeaderText"
contentStyle="height:330px;">
<f:facet name="additionalActions">
<af:panelGroupLayout id="pgl2" layout="vertical"
halign="start" valign="baseline">
<af:commandImageLink text="Close" id="cil1"
inlineStyle="margin-right:30px;"
actionListener="#{customizeBean.onAseCorner}"
icon="/images/close-ico.png"/>
</af:panelGroupLayout>
</f:facet>
</cust:showDetailFrame>
<cust:showDetailFrame text="My AutoSupport" id="sdf3"
showMinimizeAction="none"
showMoveAction="menu"
showResizer="never" background="light"
binding="#{customizeBean.autoSupportWidget}"
styleClass="widgetHeaderText"
contentStyle="height:330px;">
<f:facet name="additionalActions">
<af:panelGroupLayout id="pgl3" layout="vertical"
halign="start" valign="baseline">
<af:commandImageLink text="Close" id="cil2"
inlineStyle="margin-right:30px;"
actionListener="#{customizeBean.onAutoSupport}"
icon="/images/close-ico.png"/>
</af:panelGroupLayout>
</f:facet>
</cust:showDetailFrame>
</cust:panelCustomizable>
</af:panelGroupLayout>
</cust:panelCustomizable>
<f:facet name="editor">
<pe:pageEditorPanel id="pep1"/>
</f:facet>
</pe:pageCustomizable>
</f:facet>
</af:pageTemplate>
</af:form>
</af:document>
</f:view>
</jsp:root>
Java file :
package test.com.bean;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import oracle.adf.view.rich.component.customizable.ShowDetailFrame;
import oracle.adf.view.rich.component.rich.nav.RichCommandImageLink;
import oracle.adf.view.rich.context.AdfFacesContext;
import org.apache.myfaces.trinidad.change.AttributeComponentChange;
public class CustomizeBean {
/** Component binding for all the widgets */
private ShowDetailFrame productWidget;
private ShowDetailFrame recentCaseWidget;
private ShowDetailFrame aseCornerWidget;
private ShowDetailFrame autoSupportWidget;
/** Component binding for all the links */
private RichCommandImageLink productWidgetLink;
private RichCommandImageLink recentCasesLink;
private RichCommandImageLink recentPartsLink;
private RichCommandImageLink aseCornerLink;
private RichCommandImageLink autoSupportLink;
/** Storing link style class value */
private String productWidgetLinkStyleClass;
private String recentCasesLinkStyleClass;
private String recentPartsLinkStyleClass;
private String aseCornerLinkStyleClass;
private String autoSupportLinkStyleClass;
/** Storing static value of image, font color, UI attribute and style class */
private static final String ACTIVE_IMAGE = "/images/preview-big-ico.png";
private static final String INACTIVE_IMAGE = "/images/inactive_preview_big.png";
private static final String ACTIVE_TEXT_COLOR = "color:#0067C5;";
private static final String INACTIVE_TEXT_COLOR = "color:#999;";
private static final String PROPERTY_RENDER = "rendered";
private static final String PROPERTY_INLINE_STYLE = "inlineStyle";
private static final String PROPERTY_ICON = "icon";
private static final String PROPERTY_VISIBLE = "visible";
private static final String ACTIVE_STYLE_CLASS = "activeCustNorLink";
private static final String INACTIVE_STYLE_CLASS = "inactiveCustNorLink";
public CustomizeBean() {
super();
}
public void onProduct(ActionEvent event) {
if (this.getProductWidget().isRendered()) {
this.getProductWidget().setRendered(false);
this.getProductWidgetLink().setIcon(INACTIVE_IMAGE);
this.getProductWidgetLink().setInlineStyle(INACTIVE_TEXT_COLOR);
} else {
this.getProductWidget().setRendered(true);
this.getProductWidgetLink().setIcon(ACTIVE_IMAGE);
this.getProductWidgetLink().setInlineStyle(ACTIVE_TEXT_COLOR);
}
AdfFacesContext.getCurrentInstance().addPartialTarget(this.getProductWidgetLink());
// Saving widget visibility state in Webcenter MDS
boolean renderFlag = (Boolean)this.getProductWidget().getAttributes().get(PROPERTY_RENDER);
this.getProductWidget().getAttributes().put(PROPERTY_RENDER, renderFlag);
this.persistAttributeChange(PROPERTY_RENDER, this.getProductWidget(), renderFlag);
// Saving link color and icon in Webcenter MDS
String inlineStyle = (String)this.getProductWidgetLink().getAttributes().get(PROPERTY_INLINE_STYLE);
String icon = (String)this.getProductWidgetLink().getAttributes().get(PROPERTY_ICON);
this.getProductWidgetLink().getAttributes().put(PROPERTY_INLINE_STYLE, inlineStyle);
this.getProductWidgetLink().getAttributes().put(PROPERTY_ICON, icon);
this.persistAttributeChange(PROPERTY_INLINE_STYLE, this.getProductWidgetLink(), inlineStyle);
this.persistAttributeChange(PROPERTY_ICON, this.getProductWidgetLink(), icon);
}
public void onAseCorner(ActionEvent event) {
if (this.getAseCornerWidget().isRendered()) {
this.getAseCornerWidget().setRendered(false);
this.getAseCornerLink().setIcon(INACTIVE_IMAGE);
this.getAseCornerLink().setInlineStyle(INACTIVE_TEXT_COLOR);
} else {
this.getAseCornerWidget().setRendered(true);
this.getAseCornerLink().setIcon(ACTIVE_IMAGE);
this.getAseCornerLink().setInlineStyle(ACTIVE_TEXT_COLOR);
}
AdfFacesContext.getCurrentInstance().addPartialTarget(this.getAseCornerLink());
// Saving widget visibility state in Webcenter MDS
boolean renderFlag = (Boolean)this.getAseCornerWidget().getAttributes().get(PROPERTY_RENDER);
this.getAseCornerWidget().getAttributes().put(PROPERTY_RENDER, renderFlag);
this.persistAttributeChange(PROPERTY_RENDER, this.getAseCornerWidget(), renderFlag);
// Saving link color and icon in Webcenter MDS
String inlineStyle = (String)this.getAseCornerLink().getAttributes().get(PROPERTY_INLINE_STYLE);
String icon = (String)this.getAseCornerLink().getAttributes().get(PROPERTY_ICON);
this.getAseCornerLink().getAttributes().put(PROPERTY_INLINE_STYLE, inlineStyle);
this.getAseCornerLink().getAttributes().put(PROPERTY_ICON, icon);
this.persistAttributeChange(PROPERTY_INLINE_STYLE, this.getAseCornerLink(), inlineStyle);
this.persistAttributeChange(PROPERTY_ICON, this.getAseCornerLink(), icon);
}
/**
* This method changes the visibility of My AutoSupport Widget
* @param event
*/
public void onAutoSupport(ActionEvent event) {
if (this.getAutoSupportWidget().isRendered()) {
this.getAutoSupportWidget().setRendered(false);
this.getAutoSupportLink().setIcon(INACTIVE_IMAGE);
this.getAutoSupportLink().setInlineStyle(INACTIVE_TEXT_COLOR);
} else {
this.getAutoSupportWidget().setRendered(true);
this.getAutoSupportLink().setIcon(ACTIVE_IMAGE);
this.getAutoSupportLink().setInlineStyle(ACTIVE_TEXT_COLOR);
}
AdfFacesContext.getCurrentInstance().addPartialTarget(this.getAutoSupportLink());
// Saving widget visibility state in Webcenter MDS
boolean renderFlag = (Boolean)this.getAutoSupportWidget().getAttributes().get(PROPERTY_RENDER);
this.getAutoSupportWidget().getAttributes().put(PROPERTY_RENDER, renderFlag);
this.persistAttributeChange(PROPERTY_RENDER, this.getAutoSupportWidget(), renderFlag);
// Saving link color and icon in Webcenter MDS
String inlineStyle = (String)this.getAutoSupportLink().getAttributes().get(PROPERTY_INLINE_STYLE);
String icon = (String)this.getAutoSupportLink().getAttributes().get(PROPERTY_ICON);
this.getAutoSupportLink().getAttributes().put(PROPERTY_INLINE_STYLE, inlineStyle);
this.getAutoSupportLink().getAttributes().put(PROPERTY_ICON, icon);
this.persistAttributeChange(PROPERTY_INLINE_STYLE, this.getAutoSupportLink(), inlineStyle);
this.persistAttributeChange(PROPERTY_ICON, this.getAutoSupportLink(), icon);
}
private void persistAttributeChange(String attribute, UIComponent component, Object value) {
AttributeComponentChange attributeChange = null;
attributeChange = new AttributeComponentChange(attribute, value);
FacesContext facesCtx = FacesContext.getCurrentInstance();
AdfFacesContext adfFacesCtx = null;
adfFacesCtx = AdfFacesContext.getCurrentInstance();
oracle.adf.view.rich.change.ChangeManager manager = adfFacesCtx.getChangeManager();
manager.addComponentChange(facesCtx, component, attributeChange);
}
public void setProductWidget(ShowDetailFrame productWidget) {
this.productWidget = productWidget;
}
public ShowDetailFrame getProductWidget() {
return productWidget;
}
public void setRecentCaseWidget(ShowDetailFrame recentCaseWidget) {
this.recentCaseWidget = recentCaseWidget;
}
public ShowDetailFrame getRecentCaseWidget() {
return recentCaseWidget;
}
public void setAseCornerWidget(ShowDetailFrame aseCornerWidget) {
this.aseCornerWidget = aseCornerWidget;
}
public ShowDetailFrame getAseCornerWidget() {
return aseCornerWidget;
}
public void setAutoSupportWidget(ShowDetailFrame autoSupportWidget) {
this.autoSupportWidget = autoSupportWidget;
}
public ShowDetailFrame getAutoSupportWidget() {
return autoSupportWidget;
}
public void setProductWidgetLink(RichCommandImageLink productWidgetLink) {
this.productWidgetLink = productWidgetLink;
}
public RichCommandImageLink getProductWidgetLink() {
return productWidgetLink;
}
public void setRecentCasesLink(RichCommandImageLink recentCasesLink) {
this.recentCasesLink = recentCasesLink;
}
public RichCommandImageLink getRecentCasesLink() {
return recentCasesLink;
}
public void setRecentPartsLink(RichCommandImageLink recentPartsLink) {
this.recentPartsLink = recentPartsLink;
}
public RichCommandImageLink getRecentPartsLink() {
return recentPartsLink;
}
public void setAseCornerLink(RichCommandImageLink aseCornerLink) {
this.aseCornerLink = aseCornerLink;
}
public RichCommandImageLink getAseCornerLink() {
return aseCornerLink;
}
public void setAutoSupportLink(RichCommandImageLink autoSupportLink) {
this.autoSupportLink = autoSupportLink;
}
public RichCommandImageLink getAutoSupportLink() {
return autoSupportLink;
}
public void setProductWidgetLinkStyleClass(String productWidgetLinkStyleClass) {
this.productWidgetLinkStyleClass = productWidgetLinkStyleClass;
}
public String getProductWidgetLinkStyleClass() {
return productWidgetLinkStyleClass;
}
public void setRecentCasesLinkStyleClass(String recentCasesLinkStyleClass) {
this.recentCasesLinkStyleClass = recentCasesLinkStyleClass;
}
public String getRecentCasesLinkStyleClass() {
return recentCasesLinkStyleClass;
}
public void setRecentPartsLinkStyleClass(String recentPartsLinkStyleClass) {
this.recentPartsLinkStyleClass = recentPartsLinkStyleClass;
}
public String getRecentPartsLinkStyleClass() {
return recentPartsLinkStyleClass;
}
public void setAseCornerLinkStyleClass(String aseCornerLinkStyleClass) {
this.aseCornerLinkStyleClass = aseCornerLinkStyleClass;
}
public String getAseCornerLinkStyleClass() {
return aseCornerLinkStyleClass;
}
public void setAutoSupportLinkStyleClass(String autoSupportLinkStyleClass) {
this.autoSupportLinkStyleClass = autoSupportLinkStyleClass;
}
public String getAutoSupportLinkStyleClass() {
return autoSupportLinkStyleClass;
}
}
face-config.xml
<managed-bean id="__7">
<managed-bean-name id="__8">customizeBean</managed-bean-name>
<managed-bean-class id="__5">test.com.bean.CustomizeBean</managed-bean-class>
<managed-bean-scope id="__6">request</managed-bean-scope>
</managed-bean>
For MDS configuration :
In adf-config.xml we have added :
<tag name="showDetailFrame">
<persist-operations>
all
</persist-operations>
<attribute name="expansionMode">
<persist-changes>
true
</persist-changes>
</attribute>
<attribute name="contentStyle">
<persist-changes>
true
</persist-changes>
</attribute>
<attribute name="rendered">
<persist-changes>true</persist-changes>
</attribute>
</tag>
Regards,
Abhijit Dutta