Thursday, October 29, 2009

Deploy ADF application on weblogic server (10.3)

(prerequisite) Create JNDI on weblogic server
In JDeveloper in
Model-> Rt clk your ApplicationModule file-> Configuration
- Edit both the setting (AppLocal & AppShared)
- Select Connection type to JDBC datasource (default is JDBC URL)
- Give proper DS name e.g java:comp/env/jdbc/MyDS (Note: Same DS name should be thr in weblogic server)
- Follow this for AppShared
- Now, Right clk ur application -> Deploy to EAR file
you can deploy EAR file on WEBLOGIC

Sunday, October 18, 2009

ADF 11g : Failed to lock the record, another user holds the lock.

Change the jbo.lockingmode property to optimistic

Select application module-> rt clik -> Configurations -> Edit -> (Properties tab)
Property: jbo.locking.mode replace pessimistic with optimistic

Sunday, October 4, 2009

1) Programmatically accessing values from managed bean & Programmatically executing view with parameters

UserDetailsPersist obj1 = (UserDetailsPersist)JSFUtils.getFromSession("UserDetailsPersistent");
String startDayNo="";

ApplicationModule am = ADFUtils.getApplicationModuleForDataControl("RotaAppDataControl");
ViewObject vo = am.findViewObject("StartDay");
vo.setNamedWhereClauseParam("locId",obj1.getLocationId());
vo.executeQuery();

while (vo.hasNext())
{
StartDayRowImpl currRecd = (StartDayRowImpl) vo.next();
System.out.println("Now accessing department " + currRecd.getWeekDesc());
startDayNo = currRecd.getWeekDesc().toString();
}

System.out.println("Start day no"+startDayNo);

Wednesday, September 23, 2009

Thursday, September 17, 2009

ADF 11g: SelectOneChoice to display values based upon bind variable view criteria

*) When we have one of the attribute as LOV to other view's column, and we need to define a record based upon some criteria and also our LOV should display values based upon this criteria or BIND VARIABLE do the following.

Whe you create a view delatively,and creating an LOV on one of the attr in 1) overview tab, click on green + sign
2)In edit list of value, against List Data Source click green + sign to open view accessor
3) Shuffle required view object on the right, now this view object has bind variable associated with it so,
4)In View accessor click the Edit button and give the parameter value.

Give the value of this bind variable name of the current attribute to which it is binded so that both the parent and lov values a syncronized.


\

Wednesday, September 16, 2009

ADF 11g: Rowcount from Execute with parameter query programmatically

//Requirement: ADFUtils class,OnPageLoadBackingBeanBase class backing bean extending this(OnPage...) class, override onPageLoad method as below


public void onPageLoad() {
BindingContainer bindings = getBindings();
try
{
OperationBinding operationBinding = bindings.getOperationBinding("ExecuteWithParams");
Object result = operationBinding.execute();
System.out.println("Result"+result);
BindingContainer bindings1 = ADFUtils.getBindingContainer();
DCIteratorBinding dcitr =
(DCIteratorBinding)bindings1.get("Storetimings1View2Iterator");
//Fetch the number of rows returned
long count = dcitr.getDeferredEstimatedRowCount();
System.out.println("Rows returned:: "+count);
if(count == 0) {
OperationBinding operationBinding1 = bindings.getOperationBinding("Createwithparameters");
Object result1 = operationBinding1.execute();
}


}
catch(Exception e) {
System.out.println("The exception");

}

}

Wednesday, September 9, 2009

ADF 11g - Assign default value to attribute(from managed bean) while creating new record at runtime OR Execute with parameter ON PAGE LOAD

To assign default value to entity attribute at runtime:

At run time we want to assign value from a managed bean to an entity attribute while creating a new record

1) You need 3 files for this

1.1) ADFUtils.java

1.2) JSFUtiles.java

1.3) OnPageLoadBackingBeanBase.java

These can be downloaded from steve's undocumented list of application at (sample no. 58)



2) In backing bean (e.g NewShift.java) change it to extent OnPageLoadBackingBeanBase

public class NewShift extends OnPageLoadBackingBeanBase {


3) Now, goto NewShiftPageDef file, and in property section change the "Controller Class" property to the backing bean as in diag


(logic: whenever this page is called the backing bean will refer to the methods in parent class for on load functionality)
4) now you can modify beforePhase metod of OnPageLoadBackingBeanBase to set values of view objects using the JSFUtils class e.g
public void beforePhase(PagePhaseEvent event) { FacesPageLifecycleContext ctx = (FacesPageLifecycleContext)event.getLifecycleContext(); if (event.getPhaseId() == Lifecycle.PREPARE_MODEL_ID) { bc = ctx.getBindingContainer(); System.out.println("ON PAGE LOAD"); //JSFUtils.setExpressionValue("#{bindings.Locationid.inputValue}","20041");
JSFUtils.setExpressionValue("#{bindings.Locationid.inputValue}",UserDetailsPersist.pLocationId); onPageLoad(); bc = null; } }
thats it when your page is called the value from managed bean userdetailspersist is set into the location id attribute on your page
:-)

2) To execute query "execute with parameters" programmatically on page load
- Extend OnPageLoadBackingBeanBase in your page's backing bean
- override onPageLoad method as below.
- go to page definition and change controller class property to have value of this backing bean
(e.g Controller class= view.backing.StaffDetails)

public void onPageLoad(){


BindingContainer bindings = getBindings();

OperationBinding operationBinding = bindings.getOperationBinding("ExecuteWithParams");

Object result = operationBinding.execute();

JSFUtils.setExpressionValue("#{bindings.Location.inputValue}","1024");

if (!operationBinding.getErrors().isEmpty()) {

}

}

ADF 11g - CreateInsert to display a blank form

Create two forms

1) Master form to call create new record form

2) New Record form


1) In adf-config.xml you need to drop a method call activity between these two pages

2) From Data Control pallette drag and drop Create Insert operation on this method activity

3) Set navigation parameters i.e for these pages and you will get the required output.


Sunday, August 23, 2009

Oracle ADF 11g- Generate values from sequence for a given table.




When creating a database table using JDeveloper 11g (11.1.1.10), select column sequence from left context menu and select the check box for sequence and trigger. (as in given figure)








Generate Business Component for this table and then double click this entity, to view the xml file, click on the attributes link and the select the attribute which generates values from sequence(EmployeeId), make its datatype to be DBSequence (See below image)



Note initially for display the value will be shown as negative but once you commit the record the values will be automatically taken from the sequence.

Monday, August 10, 2009

Restarting Oracle Application Server

telnet myserver
uname/password
opmnctl stopall
su –u [infra tier uname/passwd]
opmnctl stopall
sqlplus /nolog
conn /as sysdba
shutdown immediate [database shutdown]
startup [database start]
quit
opmnctl startall [infra tier restart]
exit
opmnctl startall [mid tier restart]

Monday, August 3, 2009

PrinteWriter in jsp while returning ajax call

Printwriter in JSP during ajax call

out.write(xmlData);
pw =new PrintWriter(out, true);

Create new domains in BPEL

open bpel console in your browser
eg.
....com:7777/BPELConsole
just replace "Console" with Admin i.e. BPELAdmin

Sunday, August 2, 2009

Create a datasource






Login oracle entireprise manager-> oc4j instance-> administration tab-> Datasource



How to hide the url of ur application

eg. www.tanveer.com/MyPayrollContext/jsp/index.jsp to display only till "www.tanveer.com/MyPayrollContext" do the following your web.xml should have the following entry
"<"welcome-file-list">"
"<"welcome-file">"index.jsp"<"/welcome-file">"
" <"/welcome-file-list">"
//ignore double codes

and your index.jsp should be placed in the main project directory, you can have your other jsp's inside your jsp folder.

Thursday, July 16, 2009

SSO- External Application

Q) When password changes in external application, how can we reflect this in SSO?
A) When we register an external application and when user access it for the first time, he has to enter userid and password for this application these details get stored in orasso schema.
Details: use toad and login using system user into oracle application server infrasturcture.
switch to orasso schema, the entry is made in WWSEC_ENABLER_CONFIG_INFO$ table
, If you remove the entry for a specific user the user will again be prompted to enter his user name and password.

SSO: Customize Login Page

Way 1:
Edit the default SSO login page available at the following location,
$ORACLE_HOME/j2ee/OC4J_SECURITY/applications/sso/web/login.jsp
Way 2:
To install your own login and change password pages, provide the following parameters in $ORACLE_HOME/sso/conf/policy.properties
#Custom login page link
loginPageUrl=login_page_URL
#Custom change password page link
chgPasswordPageUrl=change_password_page_URL

Tuesday, July 7, 2009

Wednesday, May 27, 2009

Important Sites and Links

Link to upload large size documents and send via mail
www.youSENDit.com

Proxy links
kproxy
http://www.publicproxyservers.com/page1.html
http://www.terj.info
http://aflu.info
http://www.anonymoususer.biz
http://deeproxy.com
http://www.rosc.info

Monday, May 25, 2009

Java- Searching a matching countrycode column from database, exception code

String myNumber = destNumber.substring(1);
if(myNumber.startsWith("00")){
myNumber = myNumber.substring(2);
} else if(myNumber.startsWith("0")) {
myNumber = myNumber.substring(1);
} else if(myNumber.startsWith("+")){
myNumber = myNumber.substring(1);
}
try
{
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection (dbUrl);
s = conn.createStatement();
s.executeQuery("SELECT CountryCode, CountryName, CallRate FROM ratestable");
rs = s.getResultSet();
boolean myMatch = false;
while(rs.next())
{
String myLocalNumber = "";
String myCountryCode = rs.getString(1);
if(myNumber.startsWith(myCountryCode)){
myMatch = true;
myLocalNumber = myNumber.substring(myCountryCode.length());
System.out.println("Country Code:"+myCountryCode+"Local no="+myLocalNumber);
myArrayList.add(myCountryCode);
myArrayList.add(rs.getString(2));
myArrayList.add(rs.getString(3));
myArrayList.add(myConnectionType);
myArrayList.add(myLocalNumber);
return myArrayList;
}
}

Date Query (Records between fromdate and to date) in MYSQL DB

SELECT calldate FROM dateTable WHERE calldate between STR_TO_DATE('05/01/2009','%m/%d/%Y') and STR_TO_DATE('05/25/2009','%m/%d/%Y')

Friday, May 22, 2009

Sampel Date Example in JAVA

package mysamplesprj;import java.util.*;
public class DateSample2
{
public static void main(String[] args)
{
Calendar c1 = Calendar.getInstance();
System.out.println(c1.get(Calendar.YEAR));
int month = Integer.parseInt(String.valueOf(c1.get(Calendar.MONTH))) ;
month = month + 1;
System.out.println(month);
System.out.println(c1.get(Calendar.DATE));
}
}

Java Code to use SSO login

Q) How to bind java application to SSO i.e whenever someone tries to access application he is prompted for oracle SSO
A) Add the following code to first page of you application, and deploy you application to oas, your job is done.
String portalUser = request.getRemoteUser();
try
{
portalUser = request.getRemoteUser();
System.out.println(portalUser);
}
catch(Exception e)
{
portalUser = null;
}
if ((portalUser == null) (portalUser.length() <= 0))
{
response.sendError(499, "Oracle SSO");
}

Wednesday, May 20, 2009

Deploying java application from jdeveloper to oracle application server

Q) you want to deploy a java application on oracle application server from jdeveloper
A) once u hav created a java application in jdeveloper
1) Create a war file( right clk project->new->deployment profile->war file)
2) once the war file is created, right click the war file and deploy the war file ( rt clk war file->deploy to war)
3) In the deployment window you will see the path where the war file got deployed, copy this path.
4) Go to oracle application server, oc4j instance and application tab,
5) you will see deploy war option there , now give the copied path and the two values.. eg
application name: mytestapplication
mapping: /mytestapplication
ur application is ready , now check ur application on port 7777

eg http://myserver.com:7777/mytestapplication/index.jsp

Run Java Application Deployed on oracle application Server

assume ur application name is sample and deployed on myserver (oracle app server)
you need to execute ur application on port 7777
eg
http://myserver:7777/sample/index.jsp

Java Application On Oracle Application Server & accessible only to priviledged users

Q> Java application deployed on oracle app server, need to make it accessible only to group of users?
A>
1) Login oracle portal
2) Create a dynamic page
3) In region of this page, create an item- u may use an image or link item
4) Assign java application url to this item
5) While creating this item u will see access option, grant access to specific group or user
6) when ever these users will login they will see this link/image on clicking this the will be able to see the java application