بتاريخ: 10 يناير 20188 سنة comment_293021 هل يوجد مكتبه يجب ان اضيفها اقصد libarary مكتبة JSF تقديم بلاغ
بتاريخ: 10 يناير 20188 سنة comment_293022 السلام عليكم بعمل download ل file بالكود ده public String downloadFileListener() throws IOException { HttpServletResponse response = getResponse(); PrintWriter out = response.getWriter(); // ServletOutputStream out = response.getOutputStream(); // response.setContentType("image/jpeg"); response.setContentType("APPLICATION/OCTET-STREAM"); String filename = it2.getValue().toString()+".jpg"; String filepath = "\\\\server_ip\\Certificate\\"; response.setContentType("APPLICATION/OCTET-STREAM"); response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\""); FileInputStream fileInputStream = new FileInputStream(filepath + filename); int i; while ((i=fileInputStream.read()) != -1) { out.write(i); } fileInputStream.close(); out.close(); return null; } بيطلعلى الerror ده ومبيخلينش اعمل اى حاجة فى الصفحة ازاى احل المشكلة دى java.lang.IllegalStateException: Cannot forward a response that is already committed احذف السطر out.close(); حذفت السطر يا بشمهندس ومازال نفس الخطا java.lang.IllegalStateException: Cannot forward a response that is already committed at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:126) at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:546) at javax.faces.context.ExternalContextWrapper.dispatch(ExternalContextWrapper.java:93) at javax.faces.context.ExternalContextWrapper.dispatch(ExternalContextWrapper.java:93) at javax.faces.context.ExternalContextWrapper.dispatch(ExternalContextWrapper.java:93) at oracle.adfinternal.view.faces.config.rich.RecordRequestAttributesDuringDispatch.dispatch(RecordRequestAttributesDuringDispatch.java:44) at javax.faces.context.ExternalContextWrapper.dispatch(ExternalContextWrapper.java:93) at javax.faces.context.ExternalContextWrapper.dispatch(ExternalContextWrapper.java:93) at org.apache.myfaces.trinidadinternal.context.FacesContextFactoryImpl$OverrideDispatch.dispatch(FacesContextFactoryImpl.java:167) at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:364) at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:154) at org.apache.myfaces.trinidad.view.ViewDeclarationLanguageWrapper.buildView(ViewDeclarationLanguageWrapper.java:94) at org.apache.myfaces.trinidad.view.ViewDeclarationLanguageWrapper.buildView(ViewDeclarationLanguageWrapper.java:94) at org.apache.myfaces.trinidadinternal.application.ViewDeclarationLanguageFactoryImpl$ChangeApplyingVDLWrapper.buildView(ViewDeclarationLanguageFactoryImpl.java:322) at oracle.adfinternal.view.faces.lifecycle.ResponseRenderManager._processViewDefinitionLanguage(ResponseRenderManager.java:105) at oracle.adfinternal.view.faces.lifecycle.ResponseRenderManager.runRenderView(ResponseRenderManager.java:41) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._renderResponse(LifecycleImpl.java:1095) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:389) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:255) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280) أرجو تجربة fileDownloadActionListener تقديم بلاغ
بتاريخ: 10 يناير 20188 سنة comment_293030 هل يوجد مكتبه يجب ان اضيفها اقصد libarary مكتبة JSF[/quoteتمام اذن المكتبه اسمهاjsf وماهي علاقتها باظهار message تقديم بلاغ
بتاريخ: 10 يناير 20188 سنة comment_293036 اعتزر يوجد خطا بتعقيب الرساله اقصد اسم المكتبه بالكاملjsf .? تقديم بلاغ
بتاريخ: 12 يناير 20188 سنة comment_293051 المشكله انه في الكود المذكور انفا عند وضع الداله في الكلاس تظهر الرساله ولايرسل الملفعلما بان الكود يعمل بدون الرساله ماذا افعل تقديم بلاغ
بتاريخ: 13 يناير 20188 سنة comment_293056 view;import java.io.File;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import javax.faces.application.FacesMessage;import javax.faces.context.FacesContext;import oracle.adf.model.BindingContext;import oracle.binding.AttributeBinding;import oracle.binding.BindingContainer;import org.apache.myfaces.trinidad.model.UploadedFile;public class UploadClass { private UploadedFile _File; public UploadClass() { } public String UploadProcess() { // Add event code here... String imagesFolder = "C:\\upload_id\\"; File myFile = new File(imagesFolder); if ( !myFile.exists() ) { myFile.mkdir(); } String newImageFile = imagesFolder + this.getCurrentId()+".rar"; try { InputStream inputStream = getFile().getInputStream(); FileOutputStream outputStram = new FileOutputStream(newImageFile); byte[] buffer = new byte[8192]; int bytesRead = 0; while ((bytesRead = inputStream.read(buffer)) != -1) { outputStram.write(buffer, 0, bytesRead); } outputStram.flush(); outputStram.close(); inputStream.close(); getFile().dispose(); } catch (FileNotFoundException fnfe) { // TODO: Add catch code fnfe.printStackTrace(); } catch (IOException ioe) { // TODO: Add catch code ioe.printStackTrace(); } return null; } public void setFile(UploadedFile _File) { this._File = _File; } public UploadedFile getFile() { return _File; } public String getCurrentId() { BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry(); AttributeBinding attr = (AttributeBinding)bindings.getControlBinding("Id"); return attr.getInputValue().toString().trim(); }}اخي هذا الكود يعمل upload وشغال مظبوط اريد اظهار رساله بعد ان يتم ارسال الملف للطرف الاخر ..... حاولت كثير من المحاولات عن طريق facesmessage ولاجدوي 1/عند وضع الرساله في نهايه الكلاس لاتعمل 2/وضعتها في كذا مكان في الكلاس وتظهر الرساله ولكن لايرسل الملف.. ماذا افعل.؟ تقديم بلاغ
بتاريخ: 14 يناير 20188 سنة comment_293064 جزاك الله الف خير ياباشمهندس الف الف شكر اشتغلت معي مظبوط الحمدلله تقديم بلاغ
بتاريخ: 15 يناير 20188 سنة comment_293083 السلام عليكم عملت تطبيق يقوم بتحميل ملفات الى السيرفر بأستخدام الطريقة الموجود في المدونه التالية http://www.awasthiashish.com/2014/08/uploading-and-downloading-files-from.html في هذه الطريقة اكبر حجم يمكن رفعة هو 2MB المطلوب كيف يمكن زيادة حجم الملف عن 2MB وبأستخدام الكود التاليBean Method to Upload File /**Method to upload file to actual path on Server*/ private String uploadFile(UploadedFile file) { UploadedFile myfile = file; String path = null; if (myfile == null) { } else { // All uploaded files will be stored in below path path = "D://FileStore//" + myfile.getFilename(); InputStream inputStream = null; try { FileOutputStream out = new FileOutputStream(path); inputStream = myfile.getInputStream(); byte[] buffer = new byte[8192]; int bytesRead = 0; while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) { out.write(buffer, 0, bytesRead); } out.flush(); out.close(); } catch (Exception ex) { // handle exception ex.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { } } } //Returns the path where file is stored return path; } AMImpl method to insert record in table for Uploaded file /**Method to set file path and name * @param name * @param path */ public void setFileData(String name, String path,String contTyp) { ViewObject fileVo = this.getFileUpdDwn1(); Row newRow = fileVo.createRow(); newRow.setAttribute("FileName", name); newRow.setAttribute("Path", path); newRow.setAttribute("ContentType", contTyp); fileVo.insertRow(newRow); this.getDBTransaction().commit(); fileVo.executeQuery(); } ValueChangeListener to execute all methods /*****Generic Method to Get BindingContainer**/ public BindingContainer getBindingsCont() { return BindingContext.getCurrent().getCurrentBindingsEntry(); } /** * Generic Method to execute operation * */ public OperationBinding executeOperation(String operation) { OperationBinding createParam = getBindingsCont().getOperationBinding(operation); return createParam; } /**Method to Upload File ,called on ValueChangeEvent of inputFile * @param vce */ public void uploadFileVCE(ValueChangeEvent vce) { if (vce.getNewValue() != null) { //Get File Object from VC Event UploadedFile fileVal = (UploadedFile) vce.getNewValue(); //Upload File to path- Return actual server path String path = uploadFile(fileVal); System.out.println(fileVal.getContentType()); //Method to insert data in table to keep track of uploaded files OperationBinding ob = executeOperation("setFileData"); ob.getParamsMap().put("name", fileVal.getFilename()); ob.getParamsMap().put("path", path); ob.getParamsMap().put("contTyp", fileVal.getContentType()); ob.execute(); // Reset inputFile component after upload ResetUtils.reset(vce.getComponent()); } } سلام عليكم قمت بمحاولة تنفيذ خطوات upload كما موضوع في الاعلي ولكن بعض الاشياء لم توضح الي .حيث نفذت الاتي : Bean Method to Upload File/1 وقمت بتمريرها الي input file 2/AMImpl method وضعته في AM 3/ ValueChangeListener to execute all methods : لم اعلم اين اضع الكود وهل ساقوم باضفه value change listener لل in putfile ام ماذا؟ انا استخدم jdev 12c تقديم بلاغ
بتاريخ: 15 يناير 20188 سنة comment_293085 لم أفهم الرجاء السؤال بطريقة مباشرة عن المشكلة بالضبط تقديم بلاغ
انضم إلى المناقشة
يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.