Sunday, December 12, 2010

Display validation messages on top of the page instead of popup

Validation messages can be displayed either as popup or on top of the page. 
To diplay the messages on top of the page. Add below tag at start of the page.
<af:messages id="m1" inline="true"/>

Monday, November 15, 2010

ADF Memory Scopes

Scopes in the context of pages(jspx)


Scopes in the context of fragments(jsff)



Sunday, November 14, 2010

Building ADF Jar using maven

You can build ADF jar using maven.
Steps:
In order to build ADF application using maven you need to add 2 plug-ins to the POM file
1. compiler plugin
2. ant plugin.
    Ant plugin is used to run the ojdeploy build xml file.
    ojdeploy build xml should have the deployment profile information.

Declarative way to allow an action to set value before navigation

On Actions like CommandButton, CommandLink,.. you can allow them to set value before navigating to another page by using <af:setActionListener>

Example:
<af:commandLink text="#{row.formattedName}" id="cl1" action="toSavePage">
 <af:setActionListener from="phoneNumber" to="#{pageFlowScope.phoneNum}"/>
 <af:setActionListener from="#{row.empId}" to="#{pageFlowScope.selectedEmployeeId}"/>
 </af:commandLink>

Default jsff/jspx page in Source Mode rather than WYSIWYG design editor

[picFileTypes.png]

To change default setting of opening jsff/jspx page in WYSIWYG editor to source mode:
Tools --> Preferences -->File Types --> select Default Editors --> select jsff page --> select default editor to source.

Displaying html code on a ADF Fragment/Page

2 ways you can display html code on a page in ADF

<af:outputText id="ot1" escape="false" value="html code value goes here.."/>
or
<af:richTextEditor label="htmlContent" id="rte1" columns="50" readOnly="true"
             value="html code value goes here.."
             simple="true" editMode="source" rows="25"/>

Disable autocomplete fields on the Form using javascript in ADF

Add below lines at the end of each jsff page.
 <trh:script id="trh1">
function disableAutoCompleteFormData()
{
   for(i=0; i!=document.getElementByTagName('FORM').length;i++){
 document.getElementsByTagName("FORM")[i].setAttribute('autocomplete','off');
   }
}
 </trh:script>

Show pop up from manage bean

 public static void showPopup(String clientId)
{
   FacesContext context = FacesContext.getCurrentInstance();
   StringBuilder script = new StringBuilder();
   script.append("var popup = AdfPage.PAGE.findComponent('")
            .append(clientId)
            .append("'); ")
            .append("if (!popup.isPopupVisible()) { ")
            .append("popup.show();}");
  ExtendedRenderKitService erks = Service.getService(context.getRenderKit(),
                                                       ExtendedRenderKitService.class);
  erks.addScript(context, script.toString());
}

clientId - The component id of the pop up.

Evaluating EL expression in Manage Bean

    public static Object evaluateEL(String el) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ELContext elContext = facesContext.getELContext();
    ExpressionFactory expressionFactory =
    facesContext.getApplication().getExpressionFactory();
    ValueExpression exp =
    expressionFactory.createValueExpression(elContext, el,
    Object.class);
    return exp.getValue(elContext);
    }

Get/Set pageFlowScope variable from manage bean

Set pageFlowScope variable:

AdfFacesContext.getCurrentInstance().getPageFlowScope().put("key", "value");

Get pageFlowScope:

Map map = AdfFacesContext.getCurrentInstance().getPageFlowScope();

Saturday, September 4, 2010

Refreshing a task flow in ADF

Add the following code to refresh a taskflow from a managed bean.

BindingContext bctx = BindingContext.getCurrent();
BindingContainer bindings = bctx.getCurrentBindingsEntry();
DCTaskFlowBinding taskflowBinding = null;
taskflowBinding = (DCTaskFlowBinding) bindings.get("--taskflow id here");
taskflowBinding.refresh();

CSV file displays on IE instead of Excel

In order to display the CSV file in excel, add the following MIME mapping to web.xml.
<mime-mapping>
     <extension>csv</extension>
    <mime-type>application/octet-stream</mime-type>
 <mime-mapping>
<mime-mapping>

<extension>CSV</extension>
<mime-type>application/octet-stream</mime-type>
<mime-mapping>

Activating Taskflow in ADF

Taskflow can be activated by setting the following properties.

activation = conditional
active = EL expression which returns true.

If there are multiple taskflows dropped as regions in the same jsff page as tabs. The page needs to be refreshed for every tab click.

Refresh Taskflow

protected void refreshPage(){
  FacesContext fc = FacesContext.getCurrentInstance();
  String refreshPage = fc.getViewRoot().getViewId();
  ViewHandler ViewH = fc.getApplication().getViewHandler();
  UIViewRoot UIV = ViewH.createView(fc,refreshPage);
   UIV.setViewId(refreshPage);
  fc.setViewRoot(UIV);
}

Thursday, July 15, 2010

af:input file configuration in oracle adf

File upload processing requires the installation of the ADF Faces Filter. This filter is required for all ADF Faces applications. One of its features is handling file uploads. To install the filter, first add the following entry to your WEB-INF/web.xml file:




<filter>

<filter-name>adfFaces</filter-name>

<filter-class>oracle.adf.view.faces.webapp.AdfFacesFilter</filter-class>

</filter>



Second, map that filter to process all FacesServlet requests. For example, if you've named the FacesServlet "faces":



<servlet>

<servlet-name>faces</servlet-name>

<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

</servlet>



...then use the following filter-mapping:



<filter-mapping>

<filter-name>adfFaces</filter-name>

<servlet-name>faces</servlet-name>

</filter-mapping>



inputFile

To support uploading a file on your page, use the < af:inputFile > component . Like all other input components, < af:inputFile > sends ValueChangeEvents . And like all ADF Faces input components, it has built-in support for accessibility, labels, and messages.



<af:inputFile label="Upload:"

valueChangeListener="#{backingBean.fileUploaded}"/>







< af:inputFile > can be placed in either an < h:form > tag or an < af:form > tag, but in either case you have to set it to support file upload. For the JSF Basic HTML form, that involves setting the "enctype" to the correct magic value; for the ADF Faces form, just set "usesUpload" to true:



<af:form usesUpload="true">

<af:inputFile label="Upload:"

valueChangeListener="#{backingBean.fileUploaded}"/>

</af:form>

<!-- or -->

<h:form enctype="multipart/form-data">

<af:inputFile label="Upload:"

valueChangeListener="#{backingBean.fileUploaded}"/>

</h:form>



web.xml
<context-param>


<!-- Maximum memory per request (in bytes) -->

<param-name>oracle.adf.view.faces.UPLOAD_MAX_MEMORY</param-name>

<!-- Use 500K -->

<param-value>512000</param-value>

</context-param>

<context-param>

<!-- Maximum disk space per request (in bytes) -->

<param-name>oracle.adf.view.faces.UPLOAD_MAX_DISK_SPACE</param-name>

<!-- Use 5,000K -->

<param-value>5120000</param-value>

</context-param>

<context-param>

<!-- directory to store temporary files -->

<param-name>oracle.adf.view.faces.UPLOAD_TEMP_DIR</param-name>

<!-- Use an ADFUploads subdirectory of /tmp -->

<param-value>/tmp/ADFUploads/</param-value>

</context-param>

Wednesday, July 14, 2010

dynamic regions with adf taskflows

When ADF taskflow dropped as a dynamic region, it prompts for managed bean. Default it creates the manage bean in backing bean scope, according to andrejaus it must be created in pageflow scope.
http://andrejusb.blogspot.com/2010/02/integration-in-oracle-adf-with-adf-task.html

Tuesday, April 6, 2010

Fckeditor oracle ADF

http://fusion-orcl.blogspot.com/


http://cksource.com/forums/viewtopic.php?f=11&t=17570


Monday, April 5, 2010

Wednesday, March 24, 2010

Browser Back Button Mishaps

set EnableTokenValidation=true for page definition.

<pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel"


version="11.1.1.55.36" id="testPageDef" Package="view.pageDefs"

EnableTokenValidation="true">
 

Wednesday, March 10, 2010

Hot Deployment after compiling in your application to weblogic server

This can be done only to web project.

1. Add below tag to the weblogic.xml
<fast-swap>
<enabled>true</enabled>
</fast-swap>
2. Modify the target classes under project properties to the exploded deploy directory, which will be located under c:\documents and setttings/application data/jdeveloper/o.j2ee/drs/<appname>/web-inf/classes.

refresh the browser should take java class changes.


Wednesday, February 10, 2010

Maven2 Plug-in for JDeveloper 11.1.1.2

Note: Maven plugin provided by jdeveloper is a preview version. Its not supporting all the features of maven. I would suggest wait till they release final version of it.


Installing the Maven plug-in

JDeveloper11g --> help --> Check for Updates --> search for maven --> select Developer Preview: Maven for JDeveloper or download the zip from the below link.
http://www.oracle.com/technology/products/jdev/101/update/exchange.xml#oracle.jdeveloper.maven

Running maven commands from jdeveloper :
Right click pom and select maven goals.

Project Structure :

Model project:


Project Source Paths -
Java Source Paths: remove existing and add path to [ApplicationHome]\Model\src\main\java
Output Directory: [ApplicationHome]\Model\target\classes
Default Package: com.mycompany.appname.model
Modelers - Model Path: [ApplicationHome]\jdeveloper\diagramMetaData
Database - Database Path: [ApplicationHome]\database\diagrams
Technology Scope: ADF Business Components (and Java)

ModelTest project:
Project Source Paths -
Java Source Paths: remove existing and add path to [ApplicationHome]\Model\src\test\java
Output Directory: [ApplicationHome]\Model\target\test-classes
Default Package: com.mycompany.appname.model

ViewController project:

Project Source Paths -
Java Source Paths: remove existing and add path to [ApplicationHome]\ViewController\src\main\java
Output Directory: [ApplicationHome]\ViewController\target\classes
Default Package: com.mycompany.appname.view
ADFmSource directory: remove existing and add path to [ApplicationHome]\ViewController\src\main\java
Modelers - Model Path: [ApplicationHome]\jdeveloper\diagramMetaData
Web Application - HTML Root Folder: [ApplicationHome]\ViewController\src\main\webapp

ViewControllerTest project:

Project Source Paths -
Java Source Paths: remove existing and add path to [ApplicationHome]\ViewController\src\test\java
Output Directory: [ApplicationHome]\ViewController\target\test-classes
Default Package: com.mycompany.appname.view

Tuesday, February 9, 2010

How to package a project to be a shared library in WebLogic Server

How to package a project to be a shared library in WebLogic Server


If you are packaging a project and want to deploy it as a shared library in a WebLogic Server, you must wrap the ADF Library JAR with a WAR or EAR file and then install the WAR or EAR as a shared library into the Oracle WebLogic Server.



For design time usage, producers of the ADF library JAR can create a .library file that contains the paths to the ADF Library JAR files. The consuming project can add this Library file to the project's libraries and classpath. When the Library file is created, the Deploy by Default option must be deselected, otherwise the JAR paths in the Library file will be included in the user's deployment, thereby creating a runtime conflict with the same JARs in the shared library.



When the consuming application is being deployed, the dependent ADF Library JAR wrapped inside a WAR or EAR must already have been deployed to the Oracle WebLogic Server as as shared library.



Create an ADF Library JAR file.

Right-click the project and select Project Properties > Libraries and Classpath and add the ADF Library JAR file created in step 1.

Create a WAR deployment profile for the project.

Create the WAR or EAR file. If you do not have ADF Faces components in your project, add the ADF Faces technology scope to your project before you create the WAR or EAR file.

Deploy the WAR or EAR file to the WebLogic Server as a shared library using tools such as the Oracle Fusion Middleware Configuration Wizard, Enterprise Manager, or WLST scripts.

From the main menu, choose Tools > Manage Libraries.

In the Manage Libraries dialog, click Load Dir.

In the Load Directory dialog, select the directory where you want to place the Library files. This folder should be in a location next to the corresponding folder of ADF Library JAR files to simplify the process of locating files. It can even be the same folder.

In the Manage Libraries dialog, click New.

In the Create Library dialog, enter a library name and click Add Entry.

In the Select Path Entry dialog, select the libraries you want to add and click Select.

In the Create Library dialog, be sure that Deployed by Default is not selected, click OK and click OK again.

Open the Library file you created in Step 10 in a text editor and set the locked property to true and save the file.

At design time, any consuming project can reference this shared library by adding the Library file to the project using the Project Properties window.

In the Application Navigator of the consuming project, from the main menu, choose Tools > Manage Libraries.

In the Manage Libraries dialog, click Load Dir.

In the Load Directory dialog, select the directory where the Library files were created in Step 7.

In the Application Navigator of the consuming project, right-click a project and select Project Properties.

In the Project Properties window, select Libraries and Classpath and click Add Library.

In the Add Library dialog, select the Library file and click OK.

click OK.

You must edit either the WEB-INF/weblogic.xml for a WAR or the META-INF/weblogic-application.xml for an EAR to include a library-ref entry that specifies the name and version of the shared library that was produced in Step 4.

Post-deployment application configuration using ADF MBeans

If you plan to configure ADF connection information or adf-config.xml using ADF MBeans after the application has been deployed, make sure that the application is configured with MDS. The adf-config.xml file must include MDS entries, as shown in the following example. If it does not, edit the file to include them.



<adf-mds-config xmlns="http://xmlns.oracle.com/adf/mds/config">

<mds-config xmlns="http://xmlns.oracle.com/mds/config"

version="11.1.1.000">

<persistence-config>

<metadata-store-usages>

<metadata-store-usage default-cust-store="true"

deploy-target="true" id="myRepos">

</metadata-store-usage>

</metadata-store-usages>

</persistence-config>

</mds-config>

</adf-mds-config>



The web.xml file must also contain entries for each ADF MBean. The following example shows entries for three ADF MBeans.



<listener>

<listener-class>oracle.adf.mbean.share.connection.ADFConnectionLifeCycleCallBack

</listener-class>

</listener>

<listener>

<listener-class>oracle.adf.mbean.share.config.ADFConfigRuntimeLifeCycleCallBack

</listener-class>

</listener>

<listener>

<listener-class>oracle.bc4j.mbean.BC4JConfigLifeCycleCallBack

</listener-class>

</listener>



11.1.1.0 Known Issues

http://www.oracle.com/technology/products/jdev/htdocs/11/11.1.1.1/knownissues.html

Saturday, January 30, 2010

Weblogic Deployment Plan

In weblogic for an application a plan can be setup using plan.xml

How to create plan.xml
1. Open application that was deployed using weblogic console
2. Open configuration tab and make changes. Any changes made to configuration of the application will create plan.xml.
3. It will prompt the location of the Plan.xml.

How does it look like and how does it work ?
Here is a sample of a plan.xml :
<?xml version='1.0' encoding='UTF-8'?>
<deployment-plan xmlns="http://xmlns.oracle.com/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd">
<application-name>app</application-name>

<variable-definition>

<variable>

<name>SessionDescriptor_invalidationIntervalSecs_12648285993120</name>

<value>59</value>

</variable>

<variable>

<name>mypath</name>

<value>C:\Documents and Settings\ram\My Documents</value>

</variable>

</variable-definition>

<module-override>

<module-name>TestWeblogicPlan_application1.ear</module-name>

<module-type>ear</module-type>

<module-descriptor external="false">

<root-element>weblogic-application</root-element>

<uri>META-INF/weblogic-application.xml</uri>

<variable-assignment>

<name>SessionDescriptor_invalidationIntervalSecs_12648285993120</name>

<xpath>/weblogic-application/session-descriptor/invalidation-interval-secs</xpath>

</variable-assignment>

</module-descriptor>

<module-descriptor external="false">

<root-element>application</root-element>

<uri>META-INF/application.xml</uri>

</module-descriptor>

<module-descriptor external="true">

<root-element>wldf-resource</root-element>

<uri>META-INF/weblogic-diagnostics.xml</uri>

</module-descriptor>

</module-override>

<module-override>

<module-name>TestWeblogicPlan_ViewController_webapp1.war</module-name>

<module-type>war</module-type>

<module-descriptor external="true">

<root-element>weblogic-web-app</root-element>

<uri>WEB-INF/weblogic.xml</uri>

<variable-assignment>

<name>mypath</name>

<xpath>/weblogic-web-app/virtual-directory-mapping/local-path</xpath>

</variable-assignment>

</module-descriptor>

<module-descriptor external="false">

<root-element>web-app</root-element>

<uri>WEB-INF/web.xml</uri>

</module-descriptor>

</module-override>

<config-root>C:\TGDev\Products\Oracle\Middleware\user_projects\domains\OWCS_domain\servers\AdminServer\upload\TestWeblogicPlan_application1</config-root>

</deployment-plan>



As you can see XPath is used to qualify the path of the attribute to update. For instance, here it's "/weblogic-web-app/session-descriptor/timeout-secs".

You will notice that the XPath indicated is simply the path to that attribute in the following weblogic.xml deployment descriptor.


The changes in Plan.xml will take effect only after update of the application and restart of the domain.



Note: specify your changes in the overide tag of plan.xml. With the plan.xml you can set values to weblogic.xml and weblogic-application.xml

Tuesday, January 26, 2010

11g virtual dir url pattern is not identified correctly

<virtual-directory-mapping>

<local-path>x:/test/vdir</local-path>

<url-pattern>/test/*</url-pattern>

</virtual-directory-mapping>

Solution
1. Create directory name test and put ur file in that directory

The directory should be created at this path x:/test/vdir. But do not specify the test directory in your local-path.

<virtual-directory-mapping>

<local-path>x:/test/vdir</local-path>

<url-pattern>/test/*</url-pattern>

</virtual-directory-mapping>

Test URL : http://hostname:port/testapp/test/mypage.pdf





Thursday, January 21, 2010

Deploying ADF application to weblogic

http://jonathantcone.wordpress.com/2010/01/08/deploying-adf-11-to-wls-10/

http://www.freewebalbum.com/blogs/faces/bjanko/blogs.jsp?blog=bjanko20090127130431


Mapping URLs to file location in weblogic

You can map your URL to file location by specifying the file location in configuration file.

Weblogic.xml
<virtual-directory-mapping>
<local-path> path to file</local-path>
<url-pattern>/*</url-pattern>
</virtual-directory-mapping>