11 Replies Latest reply: May 5, 2013 7:37 AM by SasiKasyap RSS

    query region issue

    1005875
      Hi,

      i create on query region in my search page and i want to add export button in to that page can i do it?
      give me reply asap

      Thanks.
        • 1. Re: query region issue
          User406236
          You need to add the export button to the table. Yes you can do this.
          • 2. Re: query region issue
            SasiKasyap
            In Your results Table from under the footer region , take a flow layout region .

            under this flow layout region , take a n item style of export button


            regards
            Sasikasyap .
            • 3. Re: query region issue
              1005875
              Thank for the reply

              Yes i am done search page using resultbasesearch and i want check box for each row in result set and i want to export to excel sheet

              pls help me what procedure i can follow

              reply asap
              • 4. Re: query region issue
                1005875
                Thank for the reply

                Yes i am done search page using resultbasesearch and i want check box for each row in result set and i want to export to excel sheet

                pls help me what procedure i can follow

                reply asap
                • 5. Re: query region issue
                  SasiKasyap
                  Is the results table a normal table or advanced table ??
                  • 6. Re: query region issue
                    SasiKasyap
                    If it is advanced table , then take a "messageCheckBox" as your first column item
                    In the VO take a Transient Attribute "SelectFlag" of type String map the view attribute as "SelectFlag" .
                    In the VORowImpl for this particular Attribute it would be by default as
                    public void setSelectFlag(String value)
                    {
                    setAttributeInternal(SelectFlag, value);
                    }

                    change it to
                    public void setSelectFlag(String value)
                    {
                    populateAttribute(SelectFlag, value);
                    }

                    Thanks
                    Sasikasyap .

                    Edited by: SasiKasyap on 4 May, 2013 4:01 PM

                    Edited by: SasiKasyap on 4 May, 2013 4:02 PM
                    • 7. Re: query region issue
                      1005875
                      Sorry i am not respond to ur reply

                      it is a simple search page and i want to display simple result set having check box and i want to export to excel sheet

                      i followd as

                      i create one search page using query region and i used resultbase search and i am trying to add check box and exportbutton

                      if i am wrong pls currect me what proceduer should follow.........


                      thanks.
                      • 8. Re: query region issue
                        SasiKasyap
                        Hi

                        I understand its a simple search page .
                        1. make it autocustomization instead of result based
                        2. The results table that you are displaying is it a normal table or Advanced Table ??
                        • 9. Re: query region issue
                          SasiKasyap
                          Please make it clear do you want to export all the data in excel sheet or only selected values ?

                          Thanks
                          Sasikasyap .
                          • 10. Re: query region issue
                            1005875
                            thanks for the reply

                            I am displying is simple table and i want to export only selected rows to excel sheet....
                            • 11. Re: query region issue
                              SasiKasyap
                              HI


                              If you want to implement export button functionality programmatically which is specially used when you want not to have some columns in the excel file. You can refer below link

                              http://mukx.blogspot.com/2010/01/implementing-export-button.html

                              However if you are referring it on Jdev 9i for 11.5.10, You might face "java.lang.IllegalStateException: OutputStream already retrieved" error.

                              If this is the case, Please refer below modified code

                              import oracle.apps.fnd.framework.OAViewObject;
                              import oracle.apps.fnd.framework.server.OAViewRowImpl;
                              import java.util.ArrayList;
                              import javax.servlet.http.HttpServletResponse;
                              import oracle.jbo.AttributeDef;
                              import javax.servlet.ServletOutputStream;
                              import java.io.IOException;

                              public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
                                        {
                                             super.processFormRequest(pageContext, webBean);
                                             if(pageContext.getParameter("Export")!=null)
                                             {
                                             //array of Vo attr names which need not be written in csv file
                                             String ss[]={"RecordNumber","BatchId"};//Here RecordNumber and BatchId are the attributes of VO that you donot want in your output file
                                             downloadCsvFile(pageContext, "XxescTcInterfaceStageEOVO1",null, "MAX",ss); //XxescTcInterfaceStageEOVO1 is the VO instance Name
                                             }
                                        }

                              public void downloadCsvFile(OAPageContext pageContext,String view_inst_name,String file_name_without_ext,String max_size,String[] hidden_attrib_list)
                              {
                              OAViewObject v = (OAViewObject) pageContext.getRootApplicationModule().findViewObject(view_inst_name);
                                        if (v == null)
                                        {
                                        throw new OAException("Could not find View object instance " +
                                        view_inst_name + " in root AM.");
                                        }
                              if (v.getFetchedRowCount() == 0)
                              {
                              throw new OAException("There is no data to export.");
                              }
                              String file_name = "Export";
                              if (!((file_name_without_ext == null) || ("".equals(file_name_without_ext))))
                              {
                              file_name = file_name_without_ext;
                              }
                              HttpServletResponse response = (HttpServletResponse) pageContext.getRenderingContext().getServletResponse();
                              response.setContentType("application/text");
                              response.setHeader("Content-Disposition","attachment; filename=" + file_name + ".csv");
                              ServletOutputStream pw = null;
                              try
                              {
                              pw = response.getOutputStream();

                              int j = 0;
                              int k = 0;
                              boolean bb = true;
                              System.out.println("inside try block");
                              if ((max_size == null) || ("".equals(max_size)))
                              {
                              k = Integer.parseInt(pageContext.getProfile("VO_MAX_FETCH_SIZE"));
                              bb = false;
                              }
                              else if ("MAX".equals(max_size))
                              {
                              bb = true;
                              }
                              else
                              {
                              k = Integer.parseInt(max_size);
                              bb = false;
                              }
                              //Making header
                              AttributeDef[] a = v.getAttributeDefs();
                              StringBuffer cc = new StringBuffer();
                              ArrayList exist_list = new ArrayList();
                              for (int l = 0; l < a.length; l++)
                              {
                              boolean zx = true;
                              if (hidden_attrib_list != null)
                              {
                              for (int z = 0; z < hidden_attrib_list.length; z++)
                              {
                              if (a[l].getName().equals(hidden_attrib_list[z]))
                              {
                              zx = false;
                              exist_list.add(String.valueOf(a[l].getIndex()));
                              }
                              }
                              }
                              if (zx)
                              {
                              cc.append("\"" + a[l].getName() + "\"");
                              cc.append(",");
                              }
                              }
                              String header_row = cc.toString() ;//+ "\n";
                              pw.println(header_row);
                              for (OAViewRowImpl row = (OAViewRowImpl) v.first(); row != null;row = (OAViewRowImpl) v.next())
                              {
                              j++;
                              StringBuffer b = new StringBuffer();
                              for (int i = 0; i < v.getAttributeCount(); i++)
                              {
                              boolean cv = true;
                              for (int u = 0; u < exist_list.size(); u++)
                              {
                              if (String.valueOf(i).equals(exist_list.get(u).toString()))
                              {
                              cv = false;
                              }
                              }

                              if (cv)
                              {
                              Object o = row.getAttribute(i);

                              if (!(o == null))
                              {
                              if (o.getClass().equals(Class.forName("oracle.jbo.domain.Date")))
                              {
                              //formatting of date
                              oracle.jbo.domain.Date dt = (oracle.jbo.domain.Date) o;
                              java.sql.Date ts = (java.sql.Date) dt.dateValue();
                              java.text.SimpleDateFormat displayDateFormat =
                              new java.text.SimpleDateFormat("dd-MMM-yyyy");
                              String convertedDateString = displayDateFormat.format(ts);
                              b.append("\"" + convertedDateString + "\"");
                              }
                              else
                              {
                              b.append("\"" + o.toString() + "\"");
                              }
                              }
                              else
                              {
                              b.append("\"\"");
                              }
                              b.append(",");
                              }
                              }
                              String final_row = b.toString() ;//+ "\n";
                              pw.println(final_row);
                              if (!bb)
                              {
                              if (j == k)
                              {
                              break;
                              }
                              }
                              }
                              }
                              catch (Exception e)
                              {
                              // TODO
                              e.printStackTrace();
                              throw new OAException("Unexpected Exception occured.Exception Details :" +
                              e.toString());
                              }
                              finally
                              {
                              pageContext.setDocumentRendered(false);
                              try
                              {
                              pw.flush();
                              pw.close();
                              }
                              catch(IOException e)
                              {
                              e.printStackTrace();
                              throw new OAException("Unexpected Exception occured.Exception Details :" +
                              e.toString());
                              }
                              }
                              }


                              Thanks
                              SasiKasyap .