الانتقال إلى المحتوى
View in the app

A better way to browse. Learn more.

مجموعة مستخدمي أوراكل العربية

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

عرض تقرير

Featured Replies

بتاريخ:

السلام عليكم :
استخدم الكود التالي لعرض تقرير في المتصفح ولكن التقرير يفتح في نفس ال tab  .
ماهي الطريقة لجعله يفتح في تاب جديد وشكرا .
 
    public void viewpdf(String repPath, java.util.Map param) throws Exception {
        Connection conn = null;
       
            HttpServletResponse response = getResponse();
            ServletOutputStream out = response.getOutputStream();
            // response.addHeader("Content-disposition",
            // "attachment; filename=UserReport.pdf");
            response.setHeader("Cache-Control", "max-age=0");
            response.setContentType("application/pdf");
 
            ServletContext context = getContext();
            InputStream fs =
                context.getResourceAsStream("/Reports/" + repPath);
            JasperReport template = (JasperReport)JRLoader.loadObject(fs);
            template.setWhenNoDataType(WhenNoDataTypeEnum.NO_DATA_SECTION);
            conn = getConnection();
            JasperPrint print =
                JasperFillManager.fillReport(template, param, conn);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            JasperExportManager.exportReportToPdfStream(print, baos);
            out.write(baos.toByteArray());
            out.flush();
            out.close();
         //   FacesContext.getCurrentInstance().responseComplete();
        } catch (Exception jex) {
            jex.printStackTrace();
        } finally {
            close(conn);
        }
    }

بتاريخ:

أنت قمت بعمل comment على السطر الذي يفعل ذلك

بتاريخ:
  • كاتب الموضوع

عندما أزلت الcomment عن الاسطر قام بتحميل الملف بدلا من عرضه في المتصفح

بتاريخ:

move button into h:form and add Target="_blank" this will solve your problem isa 

بتاريخ:
  • كاتب الموضوع

شكرا لك أخ درويش .... لم تنجح ظهرت رسالة خطأ Null Value 

مع العلم اني استخدم taskFlow واستدعيه ضمن صفحة jsf 

 

move button into h:form and add Target="_blank" this will solve your problem isa 

بتاريخ:

null? يجب مراجعة الكود جيدا لمعرفة الخطأ .. ما أرسلته من حل ليس علاقه بالجافا من قريب أو من بعيد ..ما ارسلته يتم في الـ view  لا يمكن أن ينتج عنه null هذا خطأ تنفيذ 

فضلا لا أمرا أرسل الكود jsf و الكود java  حتي مكن المساعدة .. 

بتاريخ:
  • كاتب الموضوع

شكرا جزيلأ لك أخ درويش ..

هذه هو كود ال JSFF

بتاريخ:
  • كاتب الموضوع

 


<?xml version='1.0' encoding='UTF-8'?>

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"

          xmlns:af="http://xmlns.oracle.com/adf/faces/rich"

          xmlns:f="http://java.sun.com/jsf/core"

          xmlns:h="http://java.sun.com/jsf/html">

  <af:panelBox text=" "

               binding="#{backingBeanScope.backing_allreporttf.pb1}" id="pb1"

               background="medium" showDisclosure="false">

    <f:facet name="toolbar"/>

    <af:panelGridLayout binding="#{backingBeanScope.backing_allreporttf.pgl1}"

                        id="pgl1">

      <af:gridRow marginTop="5px" marginBottom="5px" height="auto"

                  binding="#{backingBeanScope.backing_allreporttf.gr1}"

                  id="gr1">

        <af:gridCell marginStart="5px" marginEnd="5px" width="100%"

                     binding="#{backingBeanScope.backing_allreporttf.gc1}"

                     id="gc1" halign="center">

          <af:selectOneChoice

                              binding="#{backingBeanScope.backing_allreporttf.soc1}"

                              id="soc1"

                              valueChangeListener="#{backingBeanScope.backing_allreporttf.vv}"

                              autoSubmit="true"

                              contentStyle="font-size:medium; font-family:'Times New Roman'; font-weight:bold;"

                              inlineStyle="font-size:medium; font-family:'Times New Roman'; font-weight:bold;"

                              label="#{labelsrc['ReportNamelbl']} ">

            <af:selectItem label="التقرير الأول" value="TechnicalReport1"

                           binding="#{backingBeanScope.backing_allreporttf.si1}"

                           id="si1"/>

            <af:selectItem label="التقرير الثاني" value="2"

                           binding="#{backingBeanScope.backing_allreporttf.si2}"

                           id="si2"/>

            <af:selectItem label="التقرير الثالث" value="3"

                           binding="#{backingBeanScope.backing_allreporttf.si3}"

                           id="si3"/>

          </af:selectOneChoice>

          <af:inputText label="Label 1"

                        binding="#{backingBeanScope.backing_allreporttf.it1}"

                        id="it1" partialTriggers="soc1" visible="false"/>

        </af:gridCell>

      </af:gridRow>

    </af:panelGridLayout>

    <af:panelGridLayout binding="#{backingBeanScope.backing_allreporttf.pgl2}"

                        id="pgl2">

      <af:gridRow marginTop="5px" marginBottom="5px" height="auto"

                  binding="#{backingBeanScope.backing_allreporttf.gr2}"

                  id="gr2">

        <af:gridCell marginStart="5px" marginEnd="5px" width="100%"

                     binding="#{backingBeanScope.backing_allreporttf.gc2}"

                     id="gc2" halign="center">

          <af:commandButton binding="#{backingBeanScope.backing_allreporttf.cb1}"

                            id="cb1"

                            action="#{backingBeanScope.backing_allreporttf.GetWordReport}"

                            icon="/images/DOCX.png">

            <af:fileDownloadActionListener/>

          </af:commandButton>

          <af:commandButton text=" "

                            binding="#{backingBeanScope.backing_allreporttf.cb2}"

                            id="cb2"

                            action="#{backingBeanScope.backing_allreporttf.Getpdf}"

                            icon="/images/PDF.png">

            <af:fileDownloadActionListener/>

          </af:commandButton>

          <af:commandButton binding="#{backingBeanScope.backing_allreporttf.cb3}"

                            id="cb3"

                            action="#{backingBeanScope.backing_allreporttf.ViewReport}"

                            icon="/images/Print.png">

            <af:fileDownloadActionListener/>

          </af:commandButton>

          <af:commandButton binding="#{backingBeanScope.backing_allreporttf.cb4}"

                            id="cb4"

                            action="#{backingBeanScope.backing_allreporttf.getexcelreport}"

                            icon="/images/Excel.png">

            <af:fileDownloadActionListener/>

          </af:commandButton>

          <af:commandButton binding="#{backingBeanScope.backing_allreporttf.cb5}"

                            id="cb5"

                            action="#{backingBeanScope.backing_allreporttf.getcsvreport}"

                            icon="/images/csv.png">

            <af:fileDownloadActionListener/>

          </af:commandButton>

          <af:commandButton binding="#{backingBeanScope.backing_allreporttf.cb6}"

                            id="cb6"

                            action="#{backingBeanScope.backing_allreporttf.getodteport}"

                            icon="/images/odt.png">

            <af:fileDownloadActionListener/>

          </af:commandButton>

          <af:commandButton binding="#{backingBeanScope.backing_allreporttf.cb7}"

                            id="cb7"

                            action="#{backingBeanScope.backing_allreporttf.getpptreport}"

                            icon="/images/ppt.png" visible="false">

            <af:fileDownloadActionListener/>

          </af:commandButton>

        </af:gridCell>

      </af:gridRow>

    </af:panelGridLayout>

  </af:panelBox>

  <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_allreporttf-->

</jsp:root>

 

تم تعديل بواسطة ali alshaa

بتاريخ:

أي سطر يعطي الخطأ؟

بتاريخ:

<h:form target="_blank>
"{af:commandButton binding="#{backingBeanScope.backing_allreporttf.cb1>
"{id="cb1" action="#{backingBeanScope.backing_allreporttf.GetWordReport
"icon="/images/DOCX.png
<af:fileDownloadActionListener/>
</af:commandButton>
</h:form>
  • بعد 2 شهور...
بتاريخ:
  • كاتب الموضوع

شكرا جزيلا لك ... سأقوم بتجربتها واخبرك بالنتيجة 

 

<h:form target="_blank>
"{af:commandButton binding="#{backingBeanScope.backing_allreporttf.cb1>
	"{id="cb1" action="#{backingBeanScope.backing_allreporttf.GetWordReport
"icon="/images/DOCX.png 
 <af:fileDownloadActionListener/>
 </af:commandButton>
</h:form>
بتاريخ:

هل تستخدم JSF؟

  • بعد 2 شهور...
بتاريخ:

نفس مشكلة التقرير بيفتح فى نفس تابت المشروع   مع العلم بأن استخدم jsf

 

والكود كما يلى   

 

            public void runReport(String repPath, java.util.Map param) throws Exception {
        Connection conn = null;
        try {
            HttpServletResponse response = getResponse();
            ServletOutputStream out = response.getOutputStream();
            
            response.setHeader("Cache-Control", "max-age=0");
            response.setContentType("application/pdf");
            
            
            ServletContext context = getContext();
            InputStream fs = context.getResourceAsStream("/Reports/" + repPath);
            //InputStream fs = context.getResourceAsStream(repPath);
          
            JasperReport template = (JasperReport)JRLoader.loadObject(fs);
           // template.setWhenNoDataType(WhenNoDataTypeEnum.NO_DATA_SECTION);
          
             template.setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL);
            conn = getConnection();
          
            JasperPrint print = JasperFillManager.fillReport(template, param, conn);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            JasperExportManager.exportReportToPdfStream(print, baos);
            System.out.println("repPath= "+repPath);
            System.out.println("conn= "+conn);
            out.write(baos.toByteArray());
            out.flush();
            out.close();
            FacesContext.getCurrentInstance().responseComplete();
        } catch (Exception jex) {
            jex.printStackTrace();
        } finally {
            close(conn);
        }
        }
بتاريخ:

عزيزي الفاضل / 

عملية إنشاء تاب جديدة أو في نافذه منفصلة هلي عمليه تحدث من خلال render process  و ليس لها الي علاقة بكود الجافا الموجود في managedBean  فانت قد حصلت علي النتيجة المطلوبة و هو التقرير من خلال استدعاء القيام و البدء بال invoke application  

لذا فانت من خلال الكود الموجودة في صفحة JSF   توجه  الردresponse  الي تاب جديدة من خلال _target   ولكن يجب أن تحدد له التوجيه و هو غير محدد في الكود جيث يجب أن يكون 

response.setHeader("Content-Disposition", "attachment;filename= Report-" + outfilename );

 

و نقل زر الاستدعاء في فورم خاص <h:form>  لحاااله و توجيهه _blank  او _new 

 

و أخيرا من الجيد التمعن في framework life cycle  لتحديد من أين تصدر المشكلة  ,

بتاريخ:

اشكر خضرتك على هذه الاجابة  وتم عمل ال form  الخاص  

 

 <h:form id="f2" binding="#{backingBeanScope.backing_DEP_ADJ.f2}" target="_blank">
            <h:commandButton value="commandButton1" id="cb1" binding="#{backingBeanScope.backing_DEP_ADJ.cb1}"
                             action="#{backingBeanScope.backing_DEP_ADJ.report_action}"/>
        </h:form>
 
واشتغلت ولكن بدون اضافة هذا السطر   فى كود الجافا

response.setHeader("Content-Disposition", "attachment;filename= Report-" + outfilename );

 

لان هذا السطر يحوله الى ملف 

 

تم تعديل بواسطة rabie123

بتاريخ:

حسناً هل تم حل المشكلة أم ماذا؟

بتاريخ:

نعم تم حل المشكلة وجزاكم الله كل خير

بتاريخ:

وإياكم إن شاء الله

بتاريخ:

 

اشكر خضرتك على هذه الاجابة  وتم عمل ال form  الخاص  

 

 <h:form id="f2" binding="#{backingBeanScope.backing_DEP_ADJ.f2}" target="_blank">
            <h:commandButton value="commandButton1" id="cb1" binding="#{backingBeanScope.backing_DEP_ADJ.cb1}"
                             action="#{backingBeanScope.backing_DEP_ADJ.report_action}"/>
        </h:form>
 
واشتغلت ولكن بدون اضافة هذا السطر   فى كود الجافا

response.setHeader("Content-Disposition", "attachment;filename= Report-" + outfilename );

 

لان هذا السطر يحوله الى ملف 

 

 

i think scenario of opening new tab with required file as pdf  to only view is not logical business case ,

umm so why i am not offering new web page with the same required data with printable regime ? 

, if you have this business case  that is must be opening new tab with pdf file mention it so we can have a good business case discussion

 

thank you in advance ..  

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية

Account

Navigation

البحث

إعداد إشعارات المتصفح الفورية

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.