Flipkart Search

Monday, 31 March 2014

Custom Export to Excel in functionality in Oracle ADF

    public static void exportHtmlTableToExcel(DCIteratorBinding customVO1Iterator) throws IOException {

                String filename = "ExportedExcel.csv";

        customVO1Iterator.setRangeSize(4000);

        //Setup the output

        String contentType = "application/vnd.ms-excel";
        FacesContext fc = FacesContext.getCurrentInstance();
        HttpServletResponse response =
            (HttpServletResponse)fc.getExternalContext().getResponse();
        response.setHeader("Content-disposition",
                           "attachment; filename=" + filename);

        response.setContentType(contentType);
        PrintWriter out = response.getWriter();
        RowSetIterator rsi = customVO1Iterator.getRowSetIterator();
        //    Get the Headers
        String[] attNames = rsi.getRowAtRangeIndex(0).getAttributeNames();

        for (int i = 0; i < attNames.length; i++) {
            if (i > 0)
                out.print(",");
            out.print(attNames[i]);

        }
        out.println();
//Setting the first row data ,was creating problem in my application-- so called reset
                rsi.reset();
        Boolean isFirst = true;
        while (rsi.hasNext()) {
            Row currentRow = null;
            if (isFirst) {
                currentRow = rsi.first();
                isFirst = false;
            } else {
                currentRow = rsi.next();
            }
            if (currentRow != null) {
                Object[] attValues = currentRow.getAttributeValues();
                for (int j = 0; j < attValues.length; j++) {
                    if (j > 0)
                        out.print(",");
                    if (attValues[j] != null)
                        out.print("\"" + attValues[j] + "\"");
                }

            }
            out.println();
        }
        out.close();

        fc.responseComplete();

        customVO1Iterator.setRangeSize(30);

    }

Monday, 24 February 2014

Backing up Oracle VM

Backup is always required for the enterprise products, so is for Oracle VM.
let's start backing up one by one component of oracle VM.
1. Oracle VM manager:  Oracle VM manager is responsible for managing OVS and VMs.
Things need to be backup up for the manager are:
  1. /u01- if possible keep a backup of this folder. This is the folder in which all installers goes.
  2. /u01/app/oracle/ovm-manager-3/.config- This config file is Oracle VM Manager configuration file for database
  3. /etc/sysconfig/ovmm-Oracle VM Manager configuration file for backups-contains UUID for the manager. Incase of reinstall of VM manager it provides UUID of previous installation.
  4. OVS schema- this is the default schema created by the OVM.- if possible take full DB backup
2. Oracle VM Guests and Resources: We don't want to reinstall the VMs in case of any disaster. So need a proper strategies for the VM guests and resources. here are the important files need to be backed up.
  1. /OVS/Repositories/<UUID>/Assemblies-
  2. /OVS/Repositories/<UUID>/ISOs-
  3. /OVS/Repositories/<UUID>/Templates-
  4. /OVS/Repositories/<UUID>/VirtualDisks-
  5. /OVS/Repositories/<UUID>/VirtualMachines/<VirtualMachineUUID>/vm.cfg-

Wednesday, 5 February 2014

Controlling ADF loopback Script

This code controls the ADF loopback script to run on each new window opened, whether its a ADF popup or browser popup.




<context-param>
    <param-name>
        oracle.adf.view.rich.newWindowDetect.OPTIONS
   </param-name>
    <param-value>off</param-value>
  </context-param>

Monday, 3 February 2014

HTML Formatting / Styling in ADF outputText

HTML Formatting in outputText (Escape Attribute)


For applying styling to some of the content, outputText's escape attribute could be used. Example:-

<af:outputText value="&lt;h2>ADF Tips and Tricks&lt;/h2>"/>
<af:outputText value="&lt;h2>ADF Tips and Tricks&lt;/h2>"
               escape="false"/>

Output
<h2>ADF Tips and Tricks</h2>
ADF Tips and Tricks

Note: You should avoid setting the escape attribute to false unless absolutely necessary. outputFormatted  component is more recommended in such cases.


Thursday, 26 December 2013

Normal Pop up implementation in ADF

import org.apache.myfaces.trinidad.util.Service;


FacesContext fctx=FacesContext.getCurrentInstance();
       ExternalContext ectx=fctx.getExternalContext();
//      ectx.redirect("test1.jspx"); // to open in same tab
       ExtendedRenderKitService erks =
       Service.getService(fctx.getRenderKit(), ExtendedRenderKitService.class);
       String url = "window.open('" + "
reports.jspx" + "','\"_self\"','\"toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=600,height=500\"');";
       erks.addScript(FacesContext.getCurrentInstance(), url);
       ///code to open reports in pop up///

Friday, 6 September 2013

truncate output text or see more implementation - ADF output text tutorial-11

Some time we have requirement to show only a fix length of text in UI and show remaining text on demand.Oracle ADF provides this functionality out of box.
In the property of OutputText we can find truncate at
 truncateAt=10

It truncates the text at 10, or it can be decided by an EL or java method return


In the above example text is  truncated on 10th letter and then ... is appended to show there is more text.Hovering the mouse above text will show the whole content.