Dynamically showing a URL is something you will need to do when you have to show it on the basis of some condition which has to be decided at run time. Or in some cases to show it at places where OAF personalization is not allowing you to do so. In this post we will take the example of adding an external URL on Supplier page.
Navigation and Standard Page
Navigation of the page is: PO Buyer –> Buyer Work Center –> Suppliers –> Search for the supplier –> Click on Update button. Below is the screenshot how does the page look like in standard form:
To dynamically add the URL, we need to find out the bean in which we need to show it. Lets say that we want to show it in the layout which contains fields like “Supplier Name”, “Supplier Number”. So we click on link “Personalize Table Layout: (SuppDetailsRN). And structure of the table layout opens which look something like this:
From this image above it is clear that we need to do the add the icon in “Message Component Layout: (LeftMCL)”. so now that we know the place we need to show it, we need to create a custom controller and add this code in the “Process Request” method of it. Below is the code which you can use.
Key points are:
- Find out the bean in which you want to add the icon
- Create the Link bean dynamically
- Set the ID of the newly created bean
- Set the text of the field. this will be the value visible on which user can click and the destination page will open
- Set the Destination. This is the URL which you want to open
- Set the Target Frame. Using this you can control the behavior of the browser like opening in new tab or same tab.
- Attach the newly created bean to parent Bean.
Code Snippet
// Find out the bean where you need to add the URL
OAMessageComponentLayoutBean LeftMCLBean = (OAMessageComponentLayoutBean)webBean.findChildRecursive ("LeftMCL");
pageContext.writeDiagnostics(this,"LeftMCLBean: "+LeftMCLBean,6);
//Create a Link Bean dynamically
OALinkBean UrlBean = (OALinkBean)pageContext.getWebBeanFactory().createWebBean(pageContext, OAWebBeanConstants.LINK_BEAN, null,"UrlBean");
//Set the ID of the bean
UrlBean.setID("xxLinkBean");
//Set the text of the field. This is the value that will show up on which one can click and the URL will open.
UrlBean.setText("URL_TEXT");
//Set the URL which you want to open
UrlBean.setDestination("https://google.com");
//Set the target frame. This value _blank will ensure that the URL will open in a new tab.
UrlBean.setTargetFrame("_blank");
// Add the newly created bean in parent bean. here 0 shows that it will be the first child. using this value you can shift the link up and down. Just count the items you want above the URL and subtract 1 from it,. and this is the value you want to use here.
LeftMCLBean.addIndexedChild(0,UrlBean);
And this is how the outcome looks like..
Related Posts
Dynamically Adding Update Icon
Reference:
support.oracle.com
Feedback:
Hope the article helped you. If it did, please rate the post. In case it didn’t, do leave a comment to let us know what did we miss.