EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
Expand all | Collapse all

file upload (use)

Discussion Topic

Discussion TopicSun September 27, 2009 06:50 AM

Discussion Topic

Discussion TopicMon September 28, 2009 12:29 PM

Discussion Topic

Discussion TopicTue September 29, 2009 06:27 PM

Discussion Topic

Discussion TopicWed September 30, 2009 05:01 AM

Discussion Topic

Discussion TopicWed September 30, 2009 07:36 AM

Discussion Topic

Discussion TopicWed September 30, 2009 02:47 PM

Discussion Topic

Discussion TopicMon October 05, 2009 12:26 PM

Discussion Topic

Discussion TopicMon October 05, 2009 07:09 PM

Discussion Topic

Discussion TopicThu October 08, 2009 09:30 AM

Discussion Topic

Discussion TopicThu October 15, 2009 10:37 AM

Discussion Topic

Discussion TopicThu October 15, 2009 11:40 AM

Discussion Topic

Discussion TopicFri October 16, 2009 04:12 AM

Discussion Topic

Discussion TopicTue October 20, 2009 02:04 PM

Discussion Topic

Discussion TopicFri October 23, 2009 11:36 AM

Discussion Topic

Discussion TopicTue October 27, 2009 08:21 PM

Discussion Topic

Discussion TopicWed October 28, 2009 03:22 AM

Discussion Topic

Discussion TopicThu October 29, 2009 09:33 PM

Discussion Topic

Discussion TopicSat October 31, 2009 06:53 AM

Discussion Topic

Discussion TopicTue November 10, 2009 04:41 AM

Discussion Topic

Discussion TopicTue November 10, 2009 11:58 PM

Discussion Topic

Discussion TopicWed November 11, 2009 03:42 AM

Discussion Topic

Discussion TopicWed November 11, 2009 10:12 PM

Discussion Topic

Discussion TopicThu November 12, 2009 04:17 AM

Discussion Topic

Discussion TopicThu November 12, 2009 10:34 PM

Discussion Topic

Discussion TopicFri November 13, 2009 02:24 AM

Discussion Topic

Discussion TopicFri July 29, 2016 03:18 PM

Discussion Topic

Discussion TopicMon August 01, 2016 09:38 AM

  • 1.  file upload (use)

    Posted Wed September 09, 2009 11:50 AM

    Hi,
    I must upload/dowload files to/from between server and client.
    In the documentation the function is used only with images. My problem is to up/dowlod documents (PDF,TXT,CVS,ODT....).
    I have undestend that i must have another field unlike image to load the document but what? Maybe an Input text Area or Rich text area or........what?
    greetings
    paoloc


  • 2.  Re: file upload (use)

    Posted Wed September 09, 2009 04:14 PM

    Hi Paoloc,
    You can follow the following link which I used when using the upload control for ascii files:
    http://www-949.ibm.com/software/rational/cafe/thread/1310?tstart=0
    A little more than halfway down the message thread you'll notice a link to an IBM technote, found here: http://www-01.ibm.com/support/docview.wss?rs=0&q1=jsf%3aupload+egl&uid=swg21318912&loc=fr_BE&cs=utf-8&lang=
    this will instruct you to create an EGL External type to a java class wrapper for the Base64 Decoder.
    Good luck,
    Daron
    canutri


  • 3.  Re: file upload (use)

    Posted Thu September 10, 2009 03:02 AM

    Thanks canutri,
    when imported the bulddescriptor has the error:
    IWN.VAL.9994.i 1/1 Generating part a37189JSFUpload with build descriptor a37189JSFUploadWebBuildOptions from file \37189JSFUpload\EGLSource\a37189JSFUpload.eglbld.
    IWN.VAL.9998.e 0/0 Exception occurred: Deployment Descriptor:a37189JSFUpload ERROR - The genProject: 37189JSFUpload has J2EELevel 1.4 and the build descriptor J2EELevel is 1.3, either explicitly set or derived from the serverType. Change the build descriptor option J2EELevel to match the genProject's J2EELevel.
    IWN.VAL.9997.e 0/0 Generation failed for a37189JSFUpload.
    I cannot remember how to correct.
    greetings paolo
    paoloc


  • 4.  Re: file upload (use)

    Posted Thu September 10, 2009 04:04 AM

    You use "writeToFile" to write the file.That is OK.
    But if I will "readFromFile" which command?
    paolo
    paoloc


  • 5.  Re: file upload (use)

    Posted Thu September 10, 2009 11:49 AM

    Hi Paolo,
    This is a frustrating one for me also. I typically get this when I bring an older project into a newer workspace. Eventually I get through it but not without much frustration.
    I'll leave it for others more knowledgeable to explain this as I would not do it justice. In fact, I'd like to see what others have to say on the matter to complete my understanding.
    Daron
    canutri


  • 6.  Re: file upload (use)

    Posted Thu September 10, 2009 12:16 PM

    Paolo,
    After the writeToFile is complete, you now have the file in ascii format. Depending on the file, you may open it as a text file or use a url to open the document in a client-side program such as excel or adobe.
    I've used it to upload fixed, comma and tab delimited files. Look for "Sequential File I/O" and "CSVRecord stereotype" in the powerpoint tutorials for examples.
    Daron
    canutri


  • 7.  Re: file upload (use)

    Posted Thu September 10, 2009 02:42 PM

    Thanks canutri,
    I are new to EGK,Java,...I have worked with RPG and all is difficult in this new world.
    To acomplish my work I need another answer from you.
    1) how to write a URL that access, from the client-side,the document that resides in the server and then use an client-side program to view or modify the document. In the sample the document resides on the server in c:\<folderName>\<docName>. I need that a client-side program access the document (PDF,TXT,CVS....and so on) in the server and then the client can modify the document whit the appropriate program(notepad,excel,......and so on).
    How to do this?How to write the URL? Can you send to me an exemple from Yours applications?
    greetings paolo
    paoloc


  • 8.  Re: file upload (use)

    Posted Sat September 12, 2009 06:44 PM

    Hello Paolo,
    My apologies for not getting back to you sooner. I was without a computer for a day while our tech folks fixed a corrupted registry hive from me. Phew, thankfully it wasn't a drive failure!
    Once your file has been uploaded and saved, you can provide the link faces component on your page and bind the document filename to it using the Select Page Date Object button in the Properties view. Assuming the client has the proper client-side software loaded for the file type being selected, the file will be transferred and loaded.
    Depending on your project, you may have to dynamically name the file each time the user performs an upload. We have such a situation where one of our partner distributors uploads inventory files which we append a timestamp on the end of our pre-defined file name. In full disclosure, we have yet to create an application which provides the use access to a file which they just uploaded. Most of our uploads which provide feedback (results) back to the user does so with a BIRT document.
    It may be helpful for me is you describe your application in more detail so I may gather a better understanding and provide more useful feedback.
    Daron
    canutri


  • 9.  Re: file upload (use)

    Posted Mon September 14, 2009 12:09 PM
    Hi Daron,
    Thanks for the help. excuse me my bad english.I are 64 age old and when i got in the school i learned french and never english in all my life.
    The application i developp is like a Social forum for an industry.The employees write,read and exchange documents with other employees and customers.All documents resides on the server.Each user,depending on permissions,has the capacity to create,read,change or delete documents. I have solved all path problems to access documents and now i cannot how to show these documents in the client-side.Documents are from various types (PDF,TXT,RTF,CVS and so on).I have created one jsp page for every document type but i can't undestend what you mean with Base64decoder. I know what this is and think that the inverse function is "Base64encoder" must exist and be used in the egl code. What i can't undestend is how to use these functions to show documents in an client-side jsp page.
    Your sample JSPUpload was very useful for me.Whit this I have solved the problem with up/dowload files between server and client for offline processing,but the online processing is still unkow.I have tried to move the readed file to an input field , to an input text area and to an input rich text area uselessly.
    What I need is a sample (jsp+egl) that read a document from the server and show in the jsp.
    That is all and that is my big,big problem.
    paoloc


  • 10.  Re: file upload (use)

    Posted Thu September 17, 2009 05:43 AM

    Hi Daron,
    have you any good news to me?
    I cannot understend what "Select Page Data Object" is.
    paolo
    paoloc


  • 11.  Re: file upload (use)

    Posted Thu September 17, 2009 03:25 PM
    Paolo,

    Your English is fine. And may I add it it much better than my French since I cannot speak your language.
    I'm lacking a complete understanding of Base64decoder (maybe others can help in this area). It is my understanding that when the user uploads a file using the JSF Upload component, the file is converted into Base64 encoding to send the file contents over the internet wire. You do not have to encoded again to send it back to a client. If after decoding it with the supplied java interface Base64decoder and storing the file onto your server, you can then provide a link int the form of http://myserver:9080/myApp/myFolder/myDocument.pdf. If you provide a page of anchor tags or JSF link components, the user can click the link to download the document and let their local operating system determine which application to load to render the document (MS Word, MS Excel, Acrobat Reader, Notepad, etc.)
    To use the JSF Link component - From the Enhanced Faces Component draw in the Palette view, drag a Link control onto your page. With the Link component still selected on the page descigner, open the Properties view and select the Browse button next to the URL: property. This will open the Select Page Data Object dialog box which I mention in an earlier post. From here you can select a variable from your jsfHandler which you've saved the file path & name from the file uploaded and decoded and saved onto the server. You have have to look into other examples to resolve absolute path names (I believe Scott Pecnik covers this here: http://www-949.ibm.com/software/rational/cafe/docs/DOC-2330)
    You can also set the Link's display value by clicking "link label" from the Page Designer area and in Properties view select Browse. This once again opens the Select Page Data Object which you can then select a variable from the jsfHandler. See the attached screenshots.
    I will try to put together a sample project and upload it over the weekend if you are unsucessful in your attempts. Hopefully someone will also contribute to this thread and provide more information for you or alternate techniques.
    Good Luck,
    Daron
    ps. I may be asking you questions in the future regarding how you solved path problems. So far my project has been simple with only one folder. When it gets more complicated I expecting paht problems of my own. Especially when and if I need to save documents outside of the web container.
    Attachments:
    JSF Link label.JPG
    JSF Link control.JPG
    canutri


  • 12.  Re: file upload (use)

    Posted Mon September 21, 2009 03:20 AM
    Hi Daron
    thanks for the help.
    Unfortunately your solution cannot solve my problem.This is because i can't describe my application rigth.
    To free me to have users documents in the WebContent folder (in the WebContent I have only applications immutable cryptogramic files like protection, copyrigt,and so on) I have created an DB2 table with the following content:

    CREATE TABLE "X "."DOCUM" (
    "DOCCOD" VARCHAR(20) NOT NULL ,
    .............
    .............
    "DOCPATH" VARCHAR(100) NOT NULL )

    where DOCCOD is the assigned (by the user) code for the document and DOCPATH is the location on the net assigned by the program when the user first create the document.With this definition I can have the documents in various folders depending on users an applications need. The location is not static but dinamic over the system.When an user clicks the button "Wiev (or create or change) document",the program first read the documents DB and then ,whit the information find in DOCPATH,retrive the documenti in the correct folder.I don't need any resource association instruction. All works well but i can't use the Link control because in the URL properties from the Palette view i must write a URL for the document that allredy exist on the system: if I change the position for the document,I must change the JSP. What I can't undestand is how to dynamic,depending on DOCPATH properties, access the document without change the JSP.
    I hope that the description of the problem ,with my poor english, is comprehensible now.
    I think that exist instructions in EGL to retrive this dynamic location but i can't find this instruction.
    paolo
    paoloc


  • 13.  Re: file upload (use)

    Posted Mon September 21, 2009 10:52 PM

    Hi Paolo,
    I am getting a better picture of you application needs. Unfortunately, I am only familiar with accessing files that are saved within the WebContent folder. However, I believe the server can be configured to allow access to other folders outside of the web context, but again I'm afraid I must disappoint you as I am unfamiliar with how this is done. Although I'm curious if you have already made the necessary configurations to make this happen as you descibe in an earlier message and, if so, you can help me in the future.
    You can find an attached simple project (DynamicFileLinks.zip) which I have created in hopes to demonstrate how you can build a dataTable with dynamic links to documents in your application. For your purposes, you will get your document names and document paths from your database whereas I created a simple library function to return an array.
    Once the array variable "documents" has been dropped onto the jsp page, I then dragged a Link Component from the Enhanced Faces Components Palette draw into the second column of the dataTable. Following the earlier post with screenshot examples, click the link and from Properties select the URL browse button; then select documents.documentLink. Then, again from Page Designer, select the Link label and from Properties select the Value browse button; then select documents.documentName.
    I hope this helps better explain how to set dynamic properties for the Link component,
    Daron
    Attachments:
    DynamicFileLinks.zip
    canutri


  • 14.  Re: file upload (use)

    Posted Tue September 22, 2009 01:04 PM

    Thanks Daron,
    I am very,very near the solution.
    I have created a folder Prove outside the WebContent with some documents (pdf,xls,rtf,txt,ppt and odt).This is my situation in the real word.
    Maybe this is the last help that i demand to you: rtf and pdf works well,the others do nothing!
    can you undestend why?
    (running on Was6.0)
    paolo
    Attachments:
    testDinamico.zip
    Prove.zip
    paoloc


  • 15.  Re: file upload (use)

    Posted Wed September 23, 2009 12:16 AM

    Hi paolo,
    I am pleased you have made progress.
    I have copied your documents into c:\Prove folder and tested on both my local test WAS and WAS on a remote server. In both cases I am able to open all documents. To be honest, I was quite surprised that I was able to open the documents when deployed on the remote server as I thought - without special server configurations - the files not found under WebContent would not be viewable from the cleint. I am running WAS v6.1, but I don't think the WAS version is contributing to the problem.
    With the jsp page running in a browser and hovering over the link, do you see "file///C:/Prove/TXT.txt", "file///C:/Prove/RTF.rtf", "file///C:/Prove/XLS.xls", etc. for each of the links? This is what I see running Windows XP and Internet Explorer 7. Once I do click the link, I'm prompted to open the file as seen in the attached screen shot. Might you have the same File Download dialog but hidden behind the browser window?
    For the files you are able to open (rtf and pdf), do they open in the browser or does the client software load as a seperate process? For me, txt and pdf open in the browser while all others loads in a seperate client window (MS-Word, MS-Exce, ect.)
    Have you tried placing the same documents in a folder withing the projects WebContent folder as I did in my sample project? I know this doesn't work for you real-world project, but it might help understand the root of the problem.
    Daron
    Attachments:
    File Download dialog.JPG
    canutri


  • 16.  Re: file upload (use)

    Posted Wed September 23, 2009 05:19 AM
    Hi Daron,
    I begin to understand nothing!!!
    I have partially changed the jsp to add both access (to folder "Documents" inside WebContent and "Test" outside WebContent).
    I not have any resorceAssociation in testDinamico.eglbld.I have istalled both MicrosoftOffice and OpenOfffcieOrg 3.1
    Following hapens:
    1) C:/Test/TXT.txt do nothing and Documents/TXT.txt show the text file but I cannot change
    2) Both C:/Test/RTF.rtf and Documents/RTF.rtf works well
    3) C:/Test/XLS.xls do nothing and Documents/XLS.xls works well
    4) C:/Test/PPT.ppt do nothing and Documents/PPT.ppt works well
    5) Both C:/Test/PDF.pdf and Documents/PDF.pdf works well
    6) C:/Test/ODT.odt do nothing and Documents/ODT.odt opens the document with .zip extension (!!!!!! see atthaced screeshot)
    7) C:/Test/DOC.doc do nothing and Documents/DOC.doc works well

    The general EGL's theory says that only files inside the WebContent are accessible by the server.This sample reject this theorem.
    I work with Was6.0 and Explorer7.
    Another strangeness is that if generate the doclib.documentLib.egl or the documentLib.egl the corresponding doclib.documentLib_Lib.java don't change.The only thing to do is to delete the whole doclib java package and generate. Oh God! This is because the EGL instability that my project is near still!
    What to do? My RDB version is 7.5.1.3,the latest. Have you a way of speaking with Sayles?What is wrong?
    paolo
    Attachments:
    testDinamico.zip
    Test.zip
    ImageODT.bmp
    paoloc


  • 17.  Re: file upload (use)

    Posted Wed September 23, 2009 02:27 PM

    Hi Paolo,
    I share your frustration and wish I knew the answer to this problem. I just realized why I'm able to load the documents. Even though I have deployed the project EAR onto a target server, I'm actually loading a local copy of the file from my own pc folder C:\Prove. When I remove the folder I can no longer open the files resulting in the same effect you have: Nothing happens.
    I don't believe the culprit here is resourceAssociation. I believe WAS needs to be configured to allow access to folders outside of WebContent. And this I do not know how to do. Can you contact IBM Customer Support for this? If I'm correct, this issue is not RBD but WAS and the fine folks here may not have much to offer for help. I can only reach Jon Sayles via email much like you can as I am an IBM customer providing help on the EGL Cafe to support others as they have help me. I'm surprised no one else has added any suggestions or alternatives to you issue.
    If configuring WAS to allow access to the desired folders, it may come down to having to interface with a java class that can copy the file into a temporary folder within the WebContent folder. This is only a concept which I'm not sure how to implement and I'm not sure if a java class running withing a web application can have access beyond the Web context. Scan the internet for "copy file in java" for examples. Having a working java class example will then require the creation of an EGL ExternalType JavaObject interface. Or using the EGL javaLib.invoke() system function. Look up "Calling Java from EGL" in the RBD help.
    Hopefully someone more experiences will contribute as I've reached the limit of my knowledge. If time permits, I may explore the java class further but this I won't have results for for several weeks.
    Daron
    canutri


  • 18.  Re: file upload (use)

    Posted Wed September 23, 2009 03:38 PM

    If using a java class technique: Maybe the java.nio.file.path class may work with the copyTo method.
    canutri


  • 19.  Re: file upload (use)

    Posted Wed September 23, 2009 05:36 PM
    Hi folks,

    as you've found it is not generally possible to directly access files outside WebContent. This is by design otherwise anyone with a browser would in theory be able to access any file on your server.

    From what I can see, you have found that you can successfully open RTF and PDF files located in WebContent but not others.

    What is happening here is that when you reference the file by an HTTP URL you are transferring its content over the network back to your browser. The browser can identify whether this is a "text" or "binary" file but it needs some extra help to work out what the actual format of the content is. This is done using an HTTP header that describes the content of the file and is known as the MIME (Multipurpose Internet Mail Extensions) type. The browser can use this information to render the content itself or invoke some sort of helper application such as a plugin or an external application.

    You can use features in Websphere or Tomcat or any other application server or HTTP server to map file extensions to MIME types. You will find there are a bunch of default mappings already including .html mapped to text/html, .css mapped to text/css and so on. It's likely that PDF and RTF are also mapped to application/pdf and application/rtf respectively, which is why they seem to be opening OK.

    Remember the helper applications must be present on the client PC i.e. the one with the browser, having them installed on the server is of no use.

    So what you are going to need to do is to configure the MIME type mappings on your server and then make sure that you have mappings in your browser from MIME type to helper application (in Firefox 3.x look at Tools -> Options... -> Applications.

    If you do not want to store your documents in WebContent but somewhere else on the server disk then it gets a little more complicated and there are several options open to you. It's probably worth making sure you understand the idea of MIME types before going to the next stage; there are plenty of resources on the Internet that can explain this further.

    Hope that helps clarify things a little bit.
    Andy
    SystemAdmin


  • 20.  Re: file upload (use)

    Posted Thu September 24, 2009 12:04 PM
    Thanks Andy,
    folk are wayting this clarify.Browsing the MIME types in the server console and with google serach I have found many answers to may probems.
    For example i have registred MIME types for OpenOffice and now i can access all documents of thys type.
    To have folders outside WebContent is too much dificult to implement due to my custom (30 years) iSeries use.
    I have only one other thing to clarify and perheps you can help me.
    My application lets clients to access documents thet reside on the server.To view the documents all is ok.
    But if must change the documents in the client (trought the web page) and then save on the server because all others users with access rigth can access these documents.
    Well, when i try to save (in the server) the documents from the application thar runs on the client (word,excel and so on) I cannot save in the server.The only option accessible is "save as" and the option "save" is not accessible. With "save as" the user can't know the destination folder because is transparent for the user.
    My demand is:how to code the egl program to make the desiderable behavoir? What istructions or keywords to use?
    paolo
    paoloc


  • 21.  Re: file upload (use)

    Posted Sun September 27, 2009 06:50 AM

    Hi Andy,
    haveYou any answer to my problem?
    paolo
    paoloc


  • 22.  Re: file upload (use)

    Posted Mon September 28, 2009 05:17 AM

    Hi Andy,
    excuse me if I am nagging,but this problem is central in my project. I want a solution nut i can't find without your help. If I not lose this problem the project cannot be used (and many months job will be lose).
    One partially solution is to use RichTextArea. In the documentation the exemple works well if both input and output text are string. I need a field that is bygger than 16,000 bytes,I must use clob to read documents that resides in a folder in WebContent .
    What clob is, is not defined in the documentation and in help.So when I try to execute the followin program:

    *
    package jsfhandlers;

    *

    import com.ibm.egl.jsf.;*

    *
    handler richText type JSFHandler{onConstructionFunction = onConstruction, view = "richText.jsp",viewRootVar = viewRoot}

    *

    viewRoot UIViewRoot;
    // textIn string = "This is initial input to the rich text control";
    textIn clob; textOut clob; //Variable bound to output control
    function onConstruction()
    end
    function moveStrings()
    textOut = textIn;

    end *
    end

    *

    The error is:SRVE0068E: Impossibile richiamare il metodo service() per il servlet /richText.jsp. Eccezione generata : javax.faces.el.EvaluationException: javax.faces.el.EvaluationException: Error getting property 'textIn' from bean of type jsfhandlers.richText: com.ibm.javart.resources.PageBeanException: egl.core.NullValueException: EGL0106E È stato utilizzato un riferimento null.
    If i use the istrucion lobLib.setClobFromString(textIn CLOB inOut, text STRING in); the error is IWN.SYN.2112.e Syntax error.Input is not recognized as "function parameter". I can't find any description for this error (due to EGL instability?)
    Please tell me how to write this instruction correct and,if you are kind,write the instructions to move a document from an folder in WebContent to the clob field textln.
    This is a temporary solution.The final solution is to manage all documents through Office/Internet
    paolo
    paoloc


  • 23.  Re: file upload (use)

    Posted Mon September 28, 2009 09:27 AM
    Paolo,

    it's going to be a bit difficult to do what you're asking. I would say that the best option for managing edited documents is to provide the user with the facility to overwrite a document they've changed i.e. if they open document A, change it and save it to their local disk, you can then provide them with the facility to upload the new document and replace the one that's already there. You will probably want to have some kind of version control on this so you can track who is changing documents and when.

    If you want to change documents directly on the server via the web interface, you need to settle on some standard formats. So for example OpenOffice and Word documents can be uploaded. You would then need to convert these into a common format on your server, maybe RTF to preserve some formatting, and save the RTF version in your database as a binary or text field. Subsequent views and edits would then be against the RTF version, the OpenOffice and Word versions would no longer be available. You could provide an option to output as OpenOffice, PDF or Word, but these would be snapshots of the current state of the document and not changeable. You will need the correct tools on the server to do these conversions.

    If you have a look around at the various commercial and open source document management systems you will see that they tend to go down one of these routes.

    I think the simplest option for you is going to be to provide a way of uploading and overwriting changed documents. In the past we provided similar solutions for a couple of Morpheus customers and they were quite comfortable with this.
    Andy
    SystemAdmin


  • 24.  Re: file upload (use)

    Posted Mon September 28, 2009 12:29 PM

    Why not use RichTextEditor?
    paoloc


  • 25.  Re: file upload (use)

    Posted Tue September 29, 2009 05:24 AM

    Hi Andy,
    I think that the enough solution for me is to use RichTextEditor and Input text area.
    2 other questions:
    How to save/load to/from local disk and how to change to PDF the edited documents. This will solve any problem.
    Have you any tips?
    paolo
    paoloc


  • 26.  Re: file upload (use)

    Posted Tue September 29, 2009 11:14 AM

    Hi Andy,
    with furter investigation on RichTextArea i think that this is no good solution to my problem.I must use images,Pdf,excel to many documents.RichTextArea accept only text: this is good for remarks but no for full document handling.
    I have no idea how to implement the "local" solution.Can You give me any tips? Can You explain to me the Morpheus "local upload and overwritting" a bit detailed? Have You any EGL code (no jsp) to suggest?
    paolo
    paoloc


  • 27.  Re: file upload (use)

    Posted Tue September 29, 2009 06:27 PM
    Paolo,

    there is no code to write for the "local" solution. You're using Word or OpenOffice or some other application to create/update the document. You then upload that in the same way as you're doing now. The only trick is that rather than creating a new file on the server, you're overwriting an existing one.

    What we did was to have a database file with details of the documents we were managing e.g.

    Record Document_mapping type SQLRecord { tableNames = [, keyitems =  }
    document_id DOCUMENT_ID {column = "DOCUMENT_ID", sqlVariableLen = yes, maxlen = 200};
    document_location DOCUMENT_LOCATION {column = "DOCUMENT_LOCATION", sqlVariableLen = yes, maxlen = 400};
    date_modified DATE_MODIFIED {column = "DATE_MODIFIED"};
    modified_by MODIFIED_BY {column = "MODIFIED_BY", sqlVariableLen = yes, maxlen = 50};
    // used in arrays: index of the row
    indexInArray int {persistent = no};
    end


    Each time a document is uploaded a new entry is created. The document_location field points to the physical file on the server file system. When a user is looking at the available documents they select from a list of the current document mappings from the database. Selecting any of these builds a URL that allows them to download the file. They can then view, edit etc. as you're doing now. When they have edited the file, you provide an upload edited file option. This takes the content to the server and the document_mapping record is used to figure out which file to overwrite. Once the file is uploaded you can update the record to show it was updated using the date_modified field, and, if necessary, who edited it using the modified_by field.

    Andy
    SystemAdmin


  • 28.  Re: file upload (use)

    Posted Wed September 30, 2009 05:01 AM

    Hi Andy,
    Excuse me but I are missing one thing.
    My project works already with a DB with a link to the physical file.When ,in the jsp page,i click the link the document opens with the local editor.This works well. The unresolved problem start now. When I exit from the editor ,You say, I must code an upload edited file option .This is the thing that I can't undestend because when I exit from the local editor the browser returns to the calling jsp page and have no trace of the content of the document just edited. So I missing the documents content and I can't understend how code the upload to the server.What I need from you(in hope to definitively solve this problem) is how to handle the content of the document with a few EGL code to upload to the server.
    paoloc


  • 29.  Re: file upload (use)

    Posted Wed September 30, 2009 07:36 AM
    Paolo,

    from what I understand you already have code to browse to a local file and upload it to the server. When you save the file and exit your local application you are creating a local copy of the new edited file. You just need to provide an upload control on your web page that will allow you to upload this local copy and overwrite the existing one rather than creating a new file.

    Andy
    SystemAdmin


  • 30.  Re: file upload (use)

    Posted Wed September 30, 2009 11:22 AM
    Hi Andy, I send you my sample project and screenshots to explain what I do.If you import the project in your RBD you can follow successively the question. The project have a folder= WebContent/Documents with the documents.The DB2 problem (to link documents position on the server) is alredy solved and is out of discussion in this sample.
    When I click TXT.txt and PDF.pdf the local editor opens and I can view,save and print on the client (I wont change the TXT too why is not possible?)
    1) When I click all other documents types Imm01 appear.
    2) If I click Salva(=Save) Imm02 I can save to the local disc
    3) If I click Apri(=Open) Imm03 I can modify,print and Salva con Nome(=Save As) the document.If I click Save As from the document menu I can save to the local disk Imm04.
    The only other option is backwards arrow to return to the initial jsp and all documents content is loss. My demand is: when and how update the document in the server? How to transfer the content of the new or changed document from the local editor to the initial jsp that can exchange data with the server?
    This question is my extrange.

    Thanks Paolo
    Attachments:
    Screenshots.zip
    testDinamico.zip
    paoloc


  • 31.  Re: file upload (use)

    Posted Wed September 30, 2009 02:47 PM
    Paolo,

    what I have been explaining is that you will not be able to automatically send the edits you have made back to the server using your web application. Once you open the document in an external editor, even if it is running as a plugin within the browser, you are passing control to that application.

    All you can do is to take your options 2) or 3) to make a new copy of the document on the local disk, use the back button to return to your JSP page, select an upload control, browse to the new version of your document and manually upload it.

    The only way you could automate this process is to start creating new plugins or macros for all the potential applications you could use on your local PC to edit documents and make the applications aware of your server application. That would be an extremely large and complicated project to take on.
    Andy
    SystemAdmin


  • 32.  Re: file upload (use)

    Posted Thu October 01, 2009 02:17 PM
    Andy,
    the solution that EGL offer is very manual but I have no time to create new plugins and macors.
    I have tryed to dynamic set the value of the fileUpload so that the client can establish in advance folders where read local documents but I can't find any instruction to set value tu fileUpload. Assigning a variable (dynamically computed for exemple c:\temp) to fileupload nothing appear in this field.
    paolo
    paoloc


  • 33.  Re: file upload (use)

    Posted Fri October 02, 2009 06:46 AM

    Andy,
    another last question.After reading the local disc with fileUpload ,how to transfer the documents content in a EGL variable? How to define this variable (string,clob,lob,...) that I use to write the document in the server?
    Paolo
    paoloc


  • 34.  Re: file upload (use)

    Posted Mon October 05, 2009 12:26 PM

    Hi Daron,
    Andys answer close the problem.
    I have posted another question to Andy without any reply to day.
    The question was:
    After reading the local disc with fileUpload ,how to transfer the documents content in a EGL variable? How to define this variable (string,clob,lob,...) that I use to write the document in the server?
    I cannot find any solution to this. Can you help me?
    paolo
    paoloc


  • 35.  Re: file upload (use)

    Posted Mon October 05, 2009 07:09 PM
    Paolo,

    you create a file upload component something like

    <hx:fileupload styleClass=<span class="jive-xml-quote">"inputText" id="fileupload1"      value="#{myPage.tempFileContent}" />


    and bind it to a BLOB variable:

    tempFileContent     blob;


    which can then be handled using the system library loblib:

      loblib.updateBlobToFile(tempFileContent, fileNameToSaveTo);  loblib.freeBlob(tempFileContent);

    Andy
    SystemAdmin


  • 36.  Re: file upload (use)

    Posted Thu October 08, 2009 09:30 AM

    Andy !
    I don't understand. When I run the program I recive the error:
    08/10/09 15.17.18:234 CEST 00000037 jsf E com.sun.faces.lifecycle.UpdateModelValuesPhase execute javax.faces.el.EvaluationException: Error setting property 'fromLocal' in bean of type jsfhandlers.richText: com.ibm.javart.resources.PageBeanException: egl.core.NullValueException: EGL0106E Null reference.
    EGL0001I L'errore si e verificato in richText.
    08/10/09 15.17.18:218 CEST 00000037 SystemErr R FacesException=javax.faces.el.EvaluationException: Error setting property 'fromLocal' in bean of type jsfhandlers.richText: com.ibm.javart.resources.PageBeanException: egl.core.NullValueException: EGL0106E Null reference
    The EGL is:

    *
    package jsfhandlers;

    *
    *
    import com.ibm.egl.jsf.UIViewRoot;

    *
    *
    handler richText type JSFHandler{onConstructionFunction = onConstruction, view = "richText.jsp", viewRootVar = viewRoot}

    *

    viewRoot UIViewRoot;
    diComodo *string*="xx";
    fromLocal blob;
    nameFileOut *string*="E:\\Worknovadent00\\testRichArea\\WebContent\\documenti
    Doc1.doc";
    function onConstruction()
    end
    function writeToFile()
    loblib.updateBlobToFile(fromLocal, nameFileOut);
    loblib.freeBlob(fromLocal);
    end
    end
    Attached the ProjectInterchange.
    paolo
    Attachments:
    testRichArea.zip
    paoloc


  • 37.  Re: file upload (use)

    Posted Thu October 15, 2009 10:37 AM

    Andy!
    I have solved the nullReference editor loading a dummy file during onCostruction.This is a bad solution but I cannot find another better.
    I have another problem that is: with wich istruction can I extract the name from the client file?I must load the document to the server with rigth extension (*.txt or *.rtf and so on).I need the name for the file in the upload field. How to save this name in a field? With the upload I have a blob in a EGL variable but not the name.
    Please answer this need and I have solved any problems.
    paolo
    paoloc


  • 38.  Re: file upload (use)

    Posted Thu October 15, 2009 11:40 AM

    Hi Paolo,
    to obtain the file name which the client uploads, bind a variable to the FileUpload component's fileName property.

    1. Select the FileUpload component
    2. Select the Properties view
    3. Click the Browse icon next to the File name: property (see attached)
    4. Select the EGL variable from the Select Page Data Object dialog

    I hope you find this helpful,
    Daron
    canutri


  • 39.  Re: file upload (use)

    Posted Fri October 16, 2009 04:12 AM
    Hi Daron,
    I have followed Your instructions (see attachment) but now the error is:

    **16/10/09 9.54.58:547 CEST 0000004e SystemOut O Development State Manager: View modified - discarding restored view.**
    **16/10/09 9.54.58:734 CEST 0000004e WebApp E SRVE0026E: Errore servlet-[JSPG0227E: Exception found during translation /Sito/concediPermessi.jsp:**
    **/Sito/concediPermessi.jsp(275,17) --> JSPG0123E: Impossible to find 'attribues informations tag for attribute tag binding.**
    **]: com.ibm.ws.jsp.translator.JspTranslationException: JSPG0227E: Rilevata eccezione durante la traduzione /Sito/concediPermessi.jsp:**
    **/Sito/concediPermessi.jsp(275,17) --> JSPG0123E: Impossible to find 'attribues informations tag for attribute tag binding.**


    • at com.ibm.ws.jsp.translator.visitor.validator.ValidateVisitor.validateCustomTagAttributeValues(ValidateVisitor.java(Compiled Code))**
    ............
    I have defined "proprietàSulPC" as string.
    If I delete the File Name the error persist.I must delete the fileUpload and insert again to the jsp work

    paolo
    Attachments:
    Immage.bmp
    paoloc


  • 40.  Re: file upload (use)

    Posted Tue October 20, 2009 02:04 PM
    Hi Daron,
    have You any tips to give me on this error?
    I have another big problem with fileUpload.The name in the fileUpload is 'nomeFileSulPC' defined as blob. I recive the following error when I test for null value:
    20/10/09 19.52.57:812 CEST 00000033 jsf E com.sun.faces.lifecycle.UpdateModelValuesPhase execute javax.faces.el.EvaluationException: Error setting property 'nomeFileSulPC' in bean of type jsfhandlers.gestDoc: com.ibm.javart.resources.PageBeanException: egl.core.NullValueException: EGL0106E Null reference.
    EGL0001I L'errore si è verificato in gestDoc.
    20/10/09 19.52.57:812 CEST 00000033 SystemErr R FacesException=javax.faces.el.EvaluationException: Error setting property 'nomeFileSulPC' in bean of type jsfhandlers.gestDoc: com.ibm.javart.resources.PageBeanException: egl.core.NullValueException: EGL0106E Null reference.
    paoloc


  • 41.  Re: file upload (use)

    Posted Fri October 23, 2009 11:36 AM
    Hi Daron,
    I can't understend how to extract the file name from fileUpload. The JSP is:

    <hx:fileupload styleClass="fileupload" id="fileupload1" value="#{richText.fromLocal}" binding="#{richText.fromLocal_Ref}">
    <hx:fileProp name="fileName" value="#{richText.nameFile}" binding="#{richText.nameFile_Ref}"/> <-------------------------------------------- Error<br />
    <hx:fileProp name="contentType" />
    </hx:fileupload>

    The jsp source signals the error: multiple annotations found at this line;
    -Udenfined attribute name bindning
    -nameFile_ref cannot be resolved as a member of richText
    - nameFile cannot be resolved as a member of richText

    Where fromLocal is defined as lob and nameFile as string (see attached) and when running I continue to recive the error:

    23/10/09 17.37.13:188 CEST 00000032 WebApp E SRVE0026E: Errore servlet-[JSPG0227E: Exception found during translation /richText.jsp:
    /richText.jsp(24,8) --> JSPG0123E: Impossibile individuare le informazioni sull'attributo tag per l'attributo tag binding.
    ]: com.ibm.ws.jsp.translator.JspTranslationException: JSPG0227E: Rilevata eccezione durante la traduzione /richText.jsp:
    /richText.jsp(24,8) --> JSPG0123E: Impossibile individuare le informazioni sull'attributo tag per l'attributo tag binding.

    at com.ibm.ws.jsp.translator.visitor.validator.ValidateVisitor.validateCustomTagAttributeValues(ValidateVisitor.java:1945)
    ............................................................
    ............................................................
    Attachments:
    richText.egl
    richText.jsp
    Immage.bmp
    paoloc


  • 42.  Re: file upload (use)

    Posted Tue October 27, 2009 08:21 PM

    Hi Paolo,
    My apologies for the late reply as I'm just returning from a business trip to Tokyo.
    When I compare you source to mine I notice that I do not have the "binding" attribute in the <hx:fileProp> tag, only the name and value attributes. Try removing the "binding" attribute and regenerate. Does this change your results?
    Daron
    canutri


  • 43.  Re: file upload (use)

    Posted Wed October 28, 2009 03:22 AM
    Daron welcome home!
    I have the file upoload defined as:
    <hx:fileupload styleClass="fileupload" id="fileupload1" value="#{richText.fromLocal}" binding="#{richText.fromLocal_Ref}">
    <hx:fileProp name="fileName" value="#{richText.nameFile}" binding="#{richText.nameFile_Ref}"/>
    <hx:fileProp name="contentType" value="#{richText.nameFile}" binding="#{richText.nameFile_Ref}"/>
    </hx:fileupload>
    but i recive the same error. I can't understend what You mean.(see atthached image)
    paolo
    Attachments:
    Image.bmp
    paoloc


  • 44.  Re: file upload (use)

    Posted Thu October 29, 2009 09:33 PM

    Hi Paolo,
    Try this:
    <hx:fileupload styleClass="fileupload" id="fileupload1" value="#{richText.fromLocal}" binding="#{richText.fromLocal_Ref}">
    <hx:fileProp name="fileName" value="#{richText.nameFile}" binding="#{richText.nameFile_Ref}"/>
    <hx:fileProp name="contentType" value="#{richText.nameFile}"/>
    </hx:fileupload>
    Notice the absense of the binding attribute from the <hx:fileProp> tag in line 3 above.
    Daron

    canutri


  • 45.  Re: file upload (use)

    Posted Sat October 31, 2009 06:53 AM

    Hi Daron,
    I think my RDB is missing something. I recive same preceding error. I have replaced my html code with yours. This is my actual code:
    <td><hx:fileupload styleClass=+"fileupload"+ id=+"fileupload1"+ value="#{richText.fromLocal}" binding="#{richText.fromLocal_Ref}">
    <hx:fileProp name=+"fileName"+ value="#{richText._nameFile_}" _binding_="#{richText.nameFile_Ref}"/>
    <hx:fileProp name=+"contentType"+ value="#{richText._nameFile_}"/>
    </hx:fileupload></td>
    like yours!!!.
    The source html panel shows 2 warnig errors(Why?) :
    on line
    <hx:fileProp name=+"fileName"+ value="#{richText._nameFile_}" _binding_="#{richText.nameFile_Ref}"/>
    Multiple annotations found at this line
    - undefined attribute name "binding"
    - nameFile cannot be resolved as a member of richText
    and on line
    <hx:fileProp name=+"contentType"+ value="#{richText._nameFile_}"/>
    nameFile cannot be resolved as a member of richText
    I have installed RDB 7.5.1.3
    The source code is the same sended on previous message(with Your suggestion)
    paolo
    paoloc


  • 46.  Re: file upload (use)

    Posted Tue November 10, 2009 04:41 AM

    Hi Daron,
    Had You time to see my last question?
    paolo
    paoloc


  • 47.  Re: file upload (use)

    Posted Tue November 10, 2009 11:58 PM
    Hi Paolo,

    My apologies for such a late reply as I'm still catching up on items follwing my trip to Tokyo.
    I have attached a screen shot of your code. When I compare your code to code I have in a couple different projects I see a couple extra properties. Please try removing these having the red strike-through in the screen shot.
    If that doesn't help, could you try packaging you page into a smaller sample and posting so I may try your code for myself?
    Daron
    Attachments:
    paolo.JPG
    canutri


  • 48.  Re: file upload (use)

    Posted Wed November 11, 2009 03:42 AM

    All is OK !!!!!!!
    thanks Daron
    good luck
    paolo
    paoloc


  • 49.  Re: file upload (use)

    Posted Wed November 11, 2009 10:12 PM

    Very good. Sorry it took so long.
    I hope your project progresses with success.
    Daron
    canutri


  • 50.  Re: file upload (use)

    Posted Thu November 12, 2009 04:17 AM

    Thank You very much,
    95% of this problem is now solved.
    The remainig 5% is about the problem to move the files content into a string to analyze the text.
    Which is the EGL instruction to do?
    paolo
    paoloc


  • 51.  Re: file upload (use)

    Posted Thu November 12, 2009 10:34 PM

    Hmmm - What do you wish to do with the files content as text? I understand you will have many different document types being uploaded - is this correct? Will you need to analyze a MS Word document or .jpg image file?
    Daron
    canutri


  • 52.  Re: file upload (use)

    Posted Fri November 13, 2009 02:24 AM

    Hi,
    yes I have all documents types (office,openoffice,cadcam and so on) and I need search words (strings) into the documents.
    With EGL i think to have documents content in a string and then search text or any other character into strings.
    paolo
    paoloc


  • 53.  Re: file upload (use)

    Posted Fri July 29, 2016 03:18 PM

    Paolo Greetings !!

    I checked the forum had difficulty working with files in EGL.

    We are working with EGL, but with problems.

    We are amazed with such difficulties in working with things as necessary ... and little support ..

    Mate, you could help us with our work?
    We simply need to read and write files (regardless of type - text, image, etc.) in folders windows and / or AIX .. What really would like is to read the Windows (client) and writes them in Aix (server).

    I thank your time to be reading this request.

    Grateful

    Osvaldo Menezes

    ojomenezes


  • 54.  Re: file upload (use)

    Posted Mon August 01, 2016 09:38 AM

    For reading a complete file, I have created this function in our environment:

     

        function getContentStringFromFile(fileNameIn string in) returns(string)

            try
                clobData clob;

                LobLib.loadClobFromFile(clobData, fileNameIn);
                content string = LobLib.getStrFromClob(clobData);

                LobLib.freeClob(clobData);

                return(content);

            onException(exception AnyException)
                SysLib.writeStdout("Exception caught on getFilecontent:");
                SysLib.writeStdout(filenameIn);
                SysLib.writeStdout(exception.message);
            end

        end

     

     

    Maybe it is of use for you

     

    Jan Willem.

    j.w.a.


  • 55.  Re: file upload (use)

    Posted Tue August 21, 2012 10:59 AM
    Hi canturi,

    You provided the link below about "upload control for ascii files", but the link is not working.
    maybe they change the position.
    Do you (or anybody else) know where i can find this information?
    or can you post a similar example.

    http://www-949.ibm.com/software/rational/cafe/thread/1310?tstart=0

    thank you in advance.
    YJTQ_Nikos_Dorkofikis


  • 56.  Re: file upload (use)

    Posted Fri July 29, 2016 03:17 PM

    Paolo Greetings !!

    I checked the forum had difficulty working with files in EGL.

    We are working with EGL, but with problems.

    We are amazed with such difficulties in working with things as necessary ... and little support ..

    Mate, you could help us with our work?
    We simply need to read and write files (regardless of type - text, image, etc.) in folders windows and / or AIX .. What really would like is to read the Windows (client) and writes them in Aix (server).

    I thank your time to be reading this request.

    Grateful

    Osvaldo Menezes

    ojomenezes