Monday 17 March 2014

Changing Date Fomat Conversion

Hi ,Use the below method to change the date format of expected date format..
\public class TimeFormat{
  
     public Calendar ConvertToCalenderFormat(String stringInstanceRepresentingDate,String Format){
               Calendar cal  = null;
           try{
               if(stringInstanceRepresentingDate!=null && !stringInstanceRepresentingDate.equalsIgnoreCase("")){
               DateFormat df = new SimpleDateFormat(Format);
                   cal  = Calendar.getInstance();
               cal.setTime(df.parse(stringInstanceRepresentingDate));
               System.out.println(cal.getTime());
               }
           }
               catch(Exception e){
                           
                              e.printStackTrace();
                              }
             
       return cal;

         
           }
     
       public String formatCalender(Calendar cal,String Formater){
          SimpleDateFormat format1 = new SimpleDateFormat(Formater);
          String formatted = format1.format(cal.getTime());
          return formatted;
       
       }
     
       public static String covnertToDateFormat(String date)
       {
         
           Calendar cal=this.ConvertToCalenderFormat(date, "yyyy-MM-dd");
           return this.formatCalender(cal, "dd/MM/yyyy");
         
         
        }
     
}
}

Saturday 15 March 2014

Query Panel Bind Variable Value Can be getting using a below process

        DCBindingContainer bindings;
                bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
                DCIteratorBinding dcIteratorBindings =
                    bindings.findIteratorBinding("IteratorName");
           date = "" + (dcIteratorBindings.getViewObject().getNamedWhereClauseParam("Bindingparametername"));

             

Batch scheduling in weblogic

Hi Every one today i have time to explain about BatchProcess in WebLogic we need to perform following steps
=>Create java class as follows....
public class SchedulerStartupServlet extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html; charset=UTF-8";

    public void init(ServletConfig config) throws ServletException {          
        super.init(config);
     
    }
   
    public void startScheduler(ServletConfig config) {

        try {
         
         String cronexp = "0 0 21 1/1 * ? *";    //this cron expression will be set at 9pm if any other timings go //www.cronmaker.com it will generate the cronexps.
         


            JobDetail job =
                JobBuilder.newJob(ADF.class).withIdentity("ADFJob", "ADFGroupOne").build();
         
            Trigger trigger =
                TriggerBuilder.newTrigger().withIdentity("ADFTrigger", "ADFTriggerGroupOne").withSchedule(CronScheduleBuilder.cronSchedule(cronexp)).build();
       
           
            Scheduler scheduler = new StdSchedulerFactory().getScheduler();
            scheduler.start();
            scheduler.scheduleJob(job, trigger);
              } catch (SchedulerException se) {
            se.printStackTrace();
        }
    }
}
==>create one more java class as follows.
import java.util.Date;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
public class ADF implements Job {
    public ADF() {
        super();
    }

    public void execute(JobExecutionContext context) throws JobExecutionException {
        try {
            this.JobSheetProcessing();
        } catch (Exceptions e) {
            e.printStackTrace();
        }
    }

    public void JobSheetProcessing() throws Exceptions{
       //write your logic to call or run  the batchjob
     
               }
}

==>The following jar are required
->c3p0-0.9.1.1.jar
->log4j-1.2.16.jar
->quartz-2.2.1.jar
->quartz-jobs-2.2.1.jar
->slf4j-api-1.6.6.jar
->slf4j-log4j12-1.6.6.jar
download add to libraries and class path of the view controller run the project.........


Wednesday 18 September 2013

Synchronizing problem with migrating the jdeveloper 11.1.1.7.0 to jdeveloper 11.1.2.3.0

i was migrating the jdeveloper 11.1.1.7.0 to 11.1.2.3.0 ...The synchronize with database option was disabled on all entities - migrated entities as well as new entities created in the project.

I found a solution which seems to work. we haven't found any drawbacks yet and the application runs just fine.


The problem with our project, was the type mapping value, which has been changed to "Java" during the migration. You can see your current value in project properties -> ADf Business Components -> Data Type Map. You cannot change this value in the project properties but you can change it manually in the Model.jpx. In this file changes the value of the attribute "_jbo.TypeMapEntries" to "OracleApps" (Java extended for oracle). I discovered that after this change, the "synchronize with database" context menu item was enabled again and the application ran without more changes. But, after the change, new entities are created with some other data type mappings (Long, Integer, Date, Timestamp) which in some cases were different than the existing ones. Thus we updated the complete entity model to use the
"OracleApps" data types and now we don't have to worry about the entity data types anymore. And the synchronization with the database works perfectly.

Sunday 9 June 2013

Enable the ADF Security

1)Declarative security support for ADF resources, such as the bounded task flow.

With Oracle ADF Security, you can control whether or not the user can enter a task flow. Thus, a single security policy for a task flow can control access to multiple web pages.


2)Simplified permission assignment using application roles that allow for the inheritance of permissions

While Java EE security roles that are used by Java EE security constraints are flat, JAAS permissions are granted to application roles, which can be nested and may be mapped to enterprise roles that the Oracle WebLogic Server domain defines.



3)Utility methods for use in EL expressions to access ADF resources in the security context

You can use the Oracle ADF Security EL expression utility methods to determine whether the user is allowed to perform a known operation. For example, you can determine whether the user is allowed to view a particular task flow.
Steps :
1.Enable Oracle ADF Security for the application:
(a)From the Application menu, choose Secure > Configure ADF Security.
(b)In the ADF Security page, leave the default ADF Authentication and Authorization option selected. Click Next.
(c)In the Authentication Type page> select the authentication type that you want your application to use when the user submits their login information. Click Next.
Select Form-based Authentication, you can also select Generate Default Pages to allow the wizard to generate a default login and error page.
(d)In the Automatic Policy Grants page, leave the default No Automatic Grants option selected. Click Next .

(e)In the Authenticated Welcome page, select Redirect Upon Successful Authentication to direct the user to a specific web page after they log in. Click Next. Then Finish.

2)Creating Application Roles
You create application roles to represent the policy requirements of the application and to define groups of users with the same view permission rights.
(a)Choose Secure > Application Roles from the Application menu in the JDeveloper.


b)Select Add New Role in the Application Roles tab. Provide the name for Role(eg: Admin)
When you add an application role to the policy store, JDeveloper updates the jazn-data.xml file located in the src/META-INF folder relative to the application workspace.

(c)Add users to the newly created Roles


Create the User and select the check box. Click OK.

3)Grant public access to ADF security-aware resources
In the Resource Grants overview editor, click one of the following Resource Type :
Task Flows when you want to make a bounded task flow public. The application displays the web pages under the permission you define for the task flow itself. Thus, all constituent web pages of the bounded task flow will become public.

Web Pages when you want to make individual web pages public. Typically, these pages are defined by an unbounded task flow and are top-level pages in the application, such as a home page.

Add required Application role or User to the TF or web page.

Use EL to specify viewable components on the Page. For Eg:
For login/logout Link:
Text: #{securityContext.authenticated ? "Logout" : "Login"}
Destination: #{securityContext.authenticated ? "/adfAuthentication?logout=true&end_url=/faces/IndexPage.jspx" : "/adfAuthentication?success_url=/faces/IndexPage.jspx"}

Use EL to configure rendered property of Button/Link for particular Role. For Eg:


#{securityContext.UserInRole['Admin']}
OR
#{securityContext.UserInRoles['Admin','Staff']}

4)Security can be bestowed upon Entity object attributes too.




Once security is enabled, you need to associate roles to it, or no one will be able to edit this attribute.


When 'Edit Authorization' is clicked jazn-data.xml is opened where you can configure the roles for the attributes to be modifiable.
On the starting Page of your Application , to enable view for all users(anonymous), configure the role as 'Anonymous User' for the landing page as follows:



#{securityContext.taskflowViewable['SomeTaskFlow']}:Returns true if the user has access to the specific SomeTaskFlow task flow

#{securityContext.regionViewable['SomePageDef']}:Returns true if the user has access to the specific SomePageDef page definition file associated with a page.

#{securityContext.userName}:
Returns the authenticated user's username.

#{securityContext.authenticated}:Returns true if the user has been authenticated.

#{securityContext.userInAllRoles['roleList']}:Returns true if user has roles in the comma seperated rolesList assigned.

Saturday 8 June 2013

Table Pagination with JDeveloper 11.1.1.7



One of the new features listed for JDeveloper 11.1.1.7 is pagination for tables, a frequently requested and long awaited feature (http://www.oracle.com/technetwork/developer-tools/jdev/index-088099.html). 
The tag documentation about this feature states that to switch pagination on you simply set the scrollPolicy property to page.Truth to be told, there is a little bit more for you to do.

1. You need to set the
autoHeightRows property to 0

2. You need to make sure the surrounding container provides a floating layout and doe not stretch (e.g. using a panelGroupLayout)

3. To bring the table into shape (full width) you then
set styleClass="AFStretchWidth"

All changes at a glance:

scrollPolicy="page" autoHeightRows="0" styleClass="AFStretchWidth"
Once you did this, the table renders as shown in the image below.

Friday 7 June 2013

commiting the record from bean

In many situation we need to get binding container from our backingbean to execute some of the operation as ( Commit - Rollback - Next - Last - Execute With Param - ............. ) or get your Iterator to get some information as (get Current Row - get View Object - get number of row count - refresh iterator - .............. ) There are two way to get your binding container from backingbean :

1-BindingContainer bindngs=BindingContext.getCurrent().getCurrentBindingsEntry();
then you can use bindings object to execute some of binding operation as commit operation as:


OperationBinding operationBinding = bindings.getOperationBinding("Commit");
operationBinding.execute();


2- The second way to get binding container is to define a method that return binding container as :

private BindingContainer bindings;
public BindingContainer getBindings() {
if (this.bindings == null) {
FacesContext fc=FacesContext.getCurrentInstance();
this.bindings = (BindingContainer)fc.getApplication().evaluateExpressionGet(fc,"#{bindings}",
BindingContainer.class);
}
return this.bindings;
}

to get binding and execute a commit operation :
BindingContainer bindings = getBindings();
OperationBinding operationBinding = bindings.getOperationBinding("Commit");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return null;
}

this is also use ful code when creating a button through managedbean


BindingContainer bindings = (BindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding operationBinding = (OperationBinding)bindings.getOperationBinding("CreateInsert");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty())
{
FacesMessage fm = new FacesMessage(operationBinding.getErrors().get(0).toString());
fm.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, fm);
}