Modify or Extending the Shell Template in Oracle ADF – techartifact

Requirment – To modify the template that can be UI shell template or Dynamic Shell template or Any other template which in form of jar in your application

Solution- In one of the requirment i have to create binding for panelspiltter in the template.jspx which in template.jar . I have unjar it modify and implemented the changes and again made to jar.

XXX.jspx in oracle-page-templates-ext.jar. Below is the step by step procedure to do this:

Copy the oracle-page-templates-ext.jar from %MiddlewareHome%\jdeveloper\adfv\jlib\ folder
Create a new folder in drive C like C:\temp\jdev\ and paste the copied jar.
Extract the contents of the jar.Open command prompt and navigate to the C:\temp\jdev folder

You can change the folder by “cd” command
For going to parent folder you can use “cd ..” .
Enter the below command for unjar :

 
jar xf oracle-page-templates-ext.jar 

or 

jar xf JarName.jar 

 

If you that jar command cant recogzied then we need to add the java bin folder path into the “Path” system variables. Ex. “C:\Oracle\Middleware\jdk160_24\bin;”
You can do by right the my computer and go to properties ,go to advance tab .Seach path variable and edit and add this above path as well

If this command work well. then you need to delete the existing jar from temp folder you created. We do this so that we can easily repack a jar later.
Open the jdevloper and open that XXX.jspx . modify or whatever changes you want to make do it.save and close it.Repackage the file in a jar. Open a command prompt navigate to the temp folder we created earlier then run the following command:
Now you have to pack as a jar .Use this command

 
jar cfM0 oracle-page-templates-ext.jar *    
0 (Zero)

or
or 

jar cfM0 JarName.jar 

You can give the jar a different name if you like.Now you will Modify libraries and classpath. Open your application in JDeveloper.Right-click your ViewController project and click project properties.Remove the existing Templates in the classpath entries.Add the jar file that we created in the step above.

Happy Learning with Techartifact

getting binding of component from one managed bean to another

Today i got one of the requirment to get the binding of some component which is binding in another managed bean.
This is something tedious requirment i have.. Well in JSF 2.0 you can get very easily by using below code

 
        FacesContext context = FacesContext.getCurrentInstance();
        BEAN bean = (RegionNavigationListener)context.getApplication().evaluateExpressionGet(context, "#{BEAN}", BEAN.class);


You can write above code as below as well

FacesContext fctx = FacesContext.getCurrentInstance();
Application application = fctx.getApplication();
ExpressionFactory expressionFactory = application.getExpressionFactory();
ELContext context = fctx.getELContext();
ValueExpression createValueExpression = expressionFactory.createValueExpression(context, "#{pageFlowScope.PageFlowScopeBean}",PageFlowScopeClass.class);
PageFlowScopeClass pageFlowScopeInstance =(PageFlowScopeClass) createValueExpression.getValue(context);

get the current viewId or url in ADF using ControllerContext

ControllerContext – Context class for per request per web application Controller information. It have various method when you need to perform
action programmatically .It Provide per-request information about the controller state for a web application.

Use getInstance() method to get the context which includes:

1. ViewPortContext (current view rendered in a browser window, a modal dialog or a region).
2. Global ViewActivity URL (url of a view activity in an unbounded task flow).
3. Local view activity url.
4. Task flow url view activity view id.
5. Savepoint restore url.

getCurrentRootViewPort() -Returns a ViewPortContext corresponding to the current root view port. The root view port is the view port for the current browser window/tab.

getGlobalViewActivityURL(ViewId) – Generate a URL for a view activity in the unbounded task flow.
Note: the view activity being referenced must be in the unbounded task flow. URL access to view activities within bounded task flows is not supported. It is caller’s responsibility to ensure that the view activity exists.

Returns:
a properly encounded URL that will result in navigation to the specified view activity.

getSavePointRestoreURL(savePointId) -Generates a URL to a save point restore activity within the current web application.

getViewActivityViewID(localViewId) -Generate view ID for a view activity inside a task flow definition. The view ID can be used when creating a UIViewRoot representing this view activity so that it can be launched in a dialog window. It is caller’s responsibility to ensure that the view activity exists.

Get the current View Id

 
ControllerContext.getInstance().getCurrentViewPort().getViewId();

Get request URL of a view activity

 
String url = ControllerContext.getInstance().getGlobalViewActivityURL(viewId)

or 

String viewId = "/department"; 
String url = ControllerContext.getInstance().getGlobalViewActivityURL(viewId);

Navigate programmatically among view activities:

 
ControllerContext.getInstance().getCurrentViewPort().setViewId("Department");  //Ensure "Department" is a valid view id in current task flow