Showing posts with label ADF Essentials. Show all posts
Showing posts with label ADF Essentials. Show all posts

Wednesday, March 19, 2014

Using Transient Attribute on Business Components

This is very simple task, but could be useful for developers who are new to ADF. You can add a Transient attribute that is derived from other attributes or from some other data source. Here are simple steps on how to do this and how to make sure that value for Transient Attribute gets updated when other attributes are changed.

  • Create new attribute on Entity object.



  • It seems attribute is marked as persistent. So you will have to change it.



  • If you don't have Entity Java class and accessor methods, please generate it (see Java tab). Once you have get method for FullName, change as shown below.


  • Add same attribute to your View Object as well, so that you can run BC Tester.


  • As you navigate to rows, you will data change in FullName. But if you change FirstName of LastName, it is not reflected in FullName. You will need to specify Dependency on FirstName and LastName for FullName attribute as shown in next screenshot.



  •  Now as you change FirstName, you will see change in FullName immediately.

These same steps apply to View Object transient attributes also, except few minor differences.

Saturday, March 15, 2014

Creating Transient View Object

Transient View Objects are very useful to build data entry forms when you don't necessarily want to create instances of Entity based View Objects till later time. In my projects, i have always tried to use Transient View Objects instead of POJO Databeans to bind to UI components. I have also used such Transient View Objects to collect search terms, when not using Query component, then i create and apply View Criteria in my Application Module method based on data entered by User which is collected from Transient View object.

Here is how you can create  Transient View Object.
  • Create New View Object, make sure to create View object in default views package. We will re-factor into different package later. This is done as JDeveloper at times creates Java files in wrong package otherwise.
  • Use consistent suffix for View Object Name to indicate that it is Transient View Object.
  • Select Programmatic option for Data Source in View Object wizard.
  • Add attributes as needed.
  • Make sure all Attributes are always updatable and set to be persisted. Also, Make sure to define a Primary Key attribute (one or more) for View object.

  • Finish View Object creation wizard.
  • Go to general tab, expand Tuning and Make sure No Rows is selected for Retrieve from the Database section.
  • Save your work.
  • Refactor Transient View Object in to a different package of your choice. For example, views.trans package.
  • Open View Object's Java file, generate if you don't have it and implement beforeRollback and afterRollback methods as shown below.

Wednesday, December 11, 2013

Issue creating Connection Pool for Oracle on Glassfish3


As part of ADF Essentials setup on Glassfish, you need to create JDBC Pool. This is documented on http://docs.oracle.com/middleware/1212/adf/ADFAG/ap_glassfish.htm#ADFAG20931.

First make sure that you copy ojdbc6.jar to your Glassfish servers's domain-home\lib folder.

C:\glassfish3\bin>asadmin
Use "exit" to exit and "help" for online help.
asadmin> create-jdbc-connection-pool --datasourceclassname oracle.jdbc.pool.OracleDataSource --restype javax.sql.DataSource --property user=user1:password=welcome1:url=jdbc:oracle:thin:@localhost:1521:XE SampleDSPool
remote failure: Invalid property syntax, missing property value: oracleInvalid property syntax, missing property value: oracle
Usage: create-jdbc-connection-pool [--datasourceclassname=datasourceclassname] [--restype=restype] [--steadypoolsize=8] [--maxpoolsize=32] [--maxwait=60000] [--poolresize=2] [--idletimeout=300] [--initsql=initsql] [--isolationlevel=isolationlevel] [--isisolationguaranteed=true] [--isconnectvalidatereq=false] [--validationmethod=table] [--validationtable=validationtable] [--failconnection=false] [--allownoncomponentcallers=false] [--nontransactionalconnections=false] [--validateatmostonceperiod=0] [--leaktimeout=0] [--leakreclaim=false] [--creationretryattempts=0] [--creationretryinterval=10] [--sqltracelisteners=sqltracelisteners] [--statementtimeout=-1] [--statementleaktimeout=0] [--statementleakreclaim=false] [--lazyconnectionenlistment=false] [--lazyconnectionassociation=false] [--associatewiththread=false] [--driverclassname=driverclassname] [--matchconnections=false] [--maxconnectionusagecount=0][--ping=false] [--pooling=true] [--statementcachesize=0] [--validationclassname=validationclassname] [--wrapjdbcobjects=true] [--description=description] [--property=property] jdbc_connection_pool_id
Command create-jdbc-connection-pool failed.

This kept failing for me, as it seems to parse URL for properties as URL has : character. Modifying the command as shown below resolved the issue. Notice URL is not specified as URL="jdbc\:oracle\:thin\:@localhost\:1521\:XE".

C:\glassfish3\bin>asadmin create-jdbc-connection-pool --datasourceclassname oracle.jdbc.pool.OracleDataSource --restype javax.sql.DataSource --property user=user1:password=welcome1:URL="jdbc\:oracle\:thin\:@localhost\:1521\:XE" SampleDSPool
JDBC connection pool SampleDSPool created successfully.
Command create-jdbc-connection-pool executed successfully.