بتاريخ: 19 فبراير 20188 سنة comment_293829 السلام عليكم : استخدم الكود التالي لعرض تقرير في المتصفح ولكن التقرير يفتح في نفس ال 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); } } تقديم بلاغ
بتاريخ: 20 فبراير 20188 سنة كاتب الموضوع comment_293853 عندما أزلت الcomment عن الاسطر قام بتحميل الملف بدلا من عرضه في المتصفح تقديم بلاغ
بتاريخ: 21 فبراير 20188 سنة comment_293855 move button into h:form and add Target="_blank" this will solve your problem isa تقديم بلاغ
بتاريخ: 21 فبراير 20188 سنة كاتب الموضوع comment_293869 شكرا لك أخ درويش .... لم تنجح ظهرت رسالة خطأ Null Value مع العلم اني استخدم taskFlow واستدعيه ضمن صفحة jsf move button into h:form and add Target="_blank" this will solve your problem isa تقديم بلاغ
بتاريخ: 22 فبراير 20188 سنة comment_293876 null? يجب مراجعة الكود جيدا لمعرفة الخطأ .. ما أرسلته من حل ليس علاقه بالجافا من قريب أو من بعيد ..ما ارسلته يتم في الـ view لا يمكن أن ينتج عنه null هذا خطأ تنفيذ فضلا لا أمرا أرسل الكود jsf و الكود java حتي مكن المساعدة .. تقديم بلاغ
بتاريخ: 22 فبراير 20188 سنة كاتب الموضوع comment_293884 شكرا جزيلأ لك أخ درويش .. هذه هو كود ال JSFF تقديم بلاغ
بتاريخ: 22 فبراير 20188 سنة كاتب الموضوع comment_293885 <?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> تم تعديل 22 فبراير 20188 سنة بواسطة ali alshaa تقديم بلاغ
بتاريخ: 23 فبراير 20188 سنة comment_293905 <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> تقديم بلاغ
بتاريخ: 6 مايو 20187 سنة كاتب الموضوع comment_295218 شكرا جزيلا لك ... سأقوم بتجربتها واخبرك بالنتيجة <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> تقديم بلاغ
بتاريخ: 3 أغسطس 20187 سنة comment_296187 نفس مشكلة التقرير بيفتح فى نفس تابت المشروع مع العلم بأن استخدم 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); } } تقديم بلاغ
بتاريخ: 3 أغسطس 20187 سنة comment_296189 عزيزي الفاضل / عملية إنشاء تاب جديدة أو في نافذه منفصلة هلي عمليه تحدث من خلال render process و ليس لها الي علاقة بكود الجافا الموجود في managedBean فانت قد حصلت علي النتيجة المطلوبة و هو التقرير من خلال استدعاء القيام و البدء بال invoke application لذا فانت من خلال الكود الموجودة في صفحة JSF توجه الردresponse الي تاب جديدة من خلال _target ولكن يجب أن تحدد له التوجيه و هو غير محدد في الكود جيث يجب أن يكون response.setHeader("Content-Disposition", "attachment;filename= Report-" + outfilename ); و نقل زر الاستدعاء في فورم خاص <h:form> لحاااله و توجيهه _blank او _new و أخيرا من الجيد التمعن في framework life cycle لتحديد من أين تصدر المشكلة , تقديم بلاغ
بتاريخ: 5 أغسطس 20187 سنة comment_296198 اشكر خضرتك على هذه الاجابة وتم عمل ال 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 ); لان هذا السطر يحوله الى ملف تم تعديل 5 أغسطس 20187 سنة بواسطة rabie123 تقديم بلاغ
بتاريخ: 6 أغسطس 20187 سنة comment_296207 اشكر خضرتك على هذه الاجابة وتم عمل ال 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 .. تقديم بلاغ
انضم إلى المناقشة
يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.