In this blog we will discuss, how to use same OAF page for update the record and view the record. (in view mode all the fields will be read only and save and canel button will be hidden).
I am taking example of advanced table.
In adavanced table, we have two columns one for update and another for detail.
When user click on update icon, page should open in update mode (all fields will be updateable and user will be able to save the changes).
When user click on detail icon, page should open in view mode (all fields will be read only and OraDataText CSS should be applied on the page). Save and canel button will be hidden and return navigator link will be visible to navigate back to the previous page.
First of all we will pass one parameter say pageMode to next page through both the column using parameter property of bean item OR you can pass pageMode parameter using hashMap in event handling method.
params.put("pageMode", "Update");
pageContext.setForwardURL("OA.jsp?page=/xx/oracle/apps/xxapp/webui/recordPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null, params, true,
OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
OAWebBeanConstants.IGNORE_MESSAGES);
Now in recordPG we will check this parameter and decide what to do
// for update page
String pageMode = pageContext.getParameter("pageMode");
if ("Update".equals(pageMode))
{
OAWebBean returnNavigation =
webBean.findChildRecursive("ReturnNavigation");
if (returnNavigation != null) {
returnNavigation.setRendered(false);
}
}
// for detail page
if ("Detail".equals(pageMode))
{
// now we will set read only property for entire page and set CSS style
// first of all hide page button bar
OAWebBean pageBtnBar = webBean.findChildRecursive("PageBtnBarRn");
if (pageBtnBar != null) {
pageBtnBar.setRendered(false);
}
makePageReadOnly(pageContext,
webBean,
excludeBean, // HashMap -- provide bean name which do not want to make read only
"OraDataText");
}
public static void makePageReadOnly(OAPageContext pageContext,
UINode childNode,
HashMap excludeBean,
String cssClass) {
if (!excludeBean.containsValue(childNode)) {
if (childNode instanceof OAMessageStyledTextBean) {
((OAMessageStyledTextBean)childNode).setCSSClass(cssClass);
((OAMessageStyledTextBean)childNode).setReadOnly(true);
} else if (childNode instanceof OAMessageTextInputBean) {
((OAMessageTextInputBean)childNode).setCSSClass(cssClass);
((OAMessageTextInputBean)childNode).setReadOnly(true);
} else if (childNode instanceof OAMessageLovInputBean) {
((OAMessageLovInputBean)childNode).setCSSClass(cssClass);
((OAMessageLovInputBean)childNode).setReadOnly(true);
} else if (childNode instanceof OAMessageDateFieldBean) {
((OAMessageDateFieldBean)childNode).setCSSClass(cssClass);
((OAMessageDateFieldBean)childNode).setReadOnly(true);
} else if (childNode instanceof OAMessageChoiceBean) {
((OAMessageChoiceBean)childNode).setCSSClass(cssClass);
((OAMessageChoiceBean)childNode).setReadOnly(true);
} else if (childNode instanceof OAMessageCheckBoxBean) {
((OAMessageCheckBoxBean)childNode).setCSSClass(cssClass);
((OAMessageCheckBoxBean)childNode).setReadOnly(true);
}
int indexedChildCount =
childNode.getIndexedChildCount(pageContext.getRenderingContext());
for (int recursiveChildCounter = 0;
recursiveChildCounter < indexedChildCount;
recursiveChildCounter++) {
if (!excludeBean.containsValue(childNode.getIndexedChild(pageContext.getRenderingContext(),
recursiveChildCounter))) {
setCSSOnChildBeans(pageContext,
childNode.getIndexedChild(pageContext.getRenderingContext(),
recursiveChildCounter),
excludeBean, cssClass);
}
}
}
}
Thats all folks for making same page updatable and read only. Hope it will help you....
I am taking example of advanced table.
In adavanced table, we have two columns one for update and another for detail.
When user click on update icon, page should open in update mode (all fields will be updateable and user will be able to save the changes).
When user click on detail icon, page should open in view mode (all fields will be read only and OraDataText CSS should be applied on the page). Save and canel button will be hidden and return navigator link will be visible to navigate back to the previous page.
First of all we will pass one parameter say pageMode to next page through both the column using parameter property of bean item OR you can pass pageMode parameter using hashMap in event handling method.
params.put("pageMode", "Update");
pageContext.setForwardURL("OA.jsp?page=/xx/oracle/apps/xxapp/webui/recordPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null, params, true,
OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
OAWebBeanConstants.IGNORE_MESSAGES);
Now in recordPG we will check this parameter and decide what to do
// for update page
String pageMode = pageContext.getParameter("pageMode");
if ("Update".equals(pageMode))
{
OAWebBean returnNavigation =
webBean.findChildRecursive("ReturnNavigation");
if (returnNavigation != null) {
returnNavigation.setRendered(false);
}
}
// for detail page
if ("Detail".equals(pageMode))
{
// now we will set read only property for entire page and set CSS style
// first of all hide page button bar
OAWebBean pageBtnBar = webBean.findChildRecursive("PageBtnBarRn");
if (pageBtnBar != null) {
pageBtnBar.setRendered(false);
}
makePageReadOnly(pageContext,
webBean,
excludeBean, // HashMap -- provide bean name which do not want to make read only
"OraDataText");
}
public static void makePageReadOnly(OAPageContext pageContext,
UINode childNode,
HashMap excludeBean,
String cssClass) {
if (!excludeBean.containsValue(childNode)) {
if (childNode instanceof OAMessageStyledTextBean) {
((OAMessageStyledTextBean)childNode).setCSSClass(cssClass);
((OAMessageStyledTextBean)childNode).setReadOnly(true);
} else if (childNode instanceof OAMessageTextInputBean) {
((OAMessageTextInputBean)childNode).setCSSClass(cssClass);
((OAMessageTextInputBean)childNode).setReadOnly(true);
} else if (childNode instanceof OAMessageLovInputBean) {
((OAMessageLovInputBean)childNode).setCSSClass(cssClass);
((OAMessageLovInputBean)childNode).setReadOnly(true);
} else if (childNode instanceof OAMessageDateFieldBean) {
((OAMessageDateFieldBean)childNode).setCSSClass(cssClass);
((OAMessageDateFieldBean)childNode).setReadOnly(true);
} else if (childNode instanceof OAMessageChoiceBean) {
((OAMessageChoiceBean)childNode).setCSSClass(cssClass);
((OAMessageChoiceBean)childNode).setReadOnly(true);
} else if (childNode instanceof OAMessageCheckBoxBean) {
((OAMessageCheckBoxBean)childNode).setCSSClass(cssClass);
((OAMessageCheckBoxBean)childNode).setReadOnly(true);
}
int indexedChildCount =
childNode.getIndexedChildCount(pageContext.getRenderingContext());
for (int recursiveChildCounter = 0;
recursiveChildCounter < indexedChildCount;
recursiveChildCounter++) {
if (!excludeBean.containsValue(childNode.getIndexedChild(pageContext.getRenderingContext(),
recursiveChildCounter))) {
setCSSOnChildBeans(pageContext,
childNode.getIndexedChild(pageContext.getRenderingContext(),
recursiveChildCounter),
excludeBean, cssClass);
}
}
}
}
Thats all folks for making same page updatable and read only. Hope it will help you....

