4 Replies Latest reply on Jun 5, 2008 1:12 PM by bravocharlie.seam.signup.benny.me.uk

    How Do I Access The DocumentStore From Within A Class?

    flynn

      Good Afternoon, All:


      How do I access the DocumentStore from within a class?


      What notations and imports need to be made?


      What code should I use to do this?


      Please be as specific and detailed as you can. I hate to ask, but the answer is not as intuitive as I'd hoped, and the only examples of code that I've found haven't worked. I'm hoping that a direct appeal will help me move forward past this roadblock.


      With Regards,


      Jason Flynn Kemp

        • 1. Re: How Do I Access The DocumentStore From Within A Class?
          nickarls

          Try DocumentStore.instance(), what are you trying to do?

          • 2. Re: How Do I Access The DocumentStore From Within A Class?
            flynn

            Man, that was easy. I'm trying to get the contents of the DocumentStore after it generates a PDF, so that I can write it out to a file instead of to the browser.


            I was trying to use Ben Catherall's approach as described in this thread:
            http://www.seamframework.org/Community/PDFdocumentStore


            However, conversation doesn't work like he has in his code (there is no get(String) method for Conversation), so I'm now trying to access the DocumentStore directly.


            Now I have to figure out how to get the document's id String so that I can get the DocumentData, since the DocumentStore's getDocumentData method requires an id String.


            Any clues or suggestions?


            With Regards,


            Jason Flynn Kemp

            • 3. Re: How Do I Access The DocumentStore From Within A Class?
              nickarls

              I'm just brainstorming here but looking at the source code in the UIDocument encodeEnd I see something like


                      if (sendRedirect) {
                         // The stuff that puts data in DocumentStore and redirects
                      } else {
                          UIComponent parent = getParent();
              
                          if (parent instanceof ValueHolder) {
                              ValueHolder holder = (ValueHolder) parent;
                              holder.setValue(documentData);
                          }
              
              



              which could indicate that if you set sendRedirect=false in the UIDocument, the data should end up in the parent, as long as it is a ValueHolder.


              I've never used it so just guessing: If you set sendRedirect to false and nest the UIDocument in something with a value-binding, the byte[] data ends up there?

              • 4. Re: How Do I Access The DocumentStore From Within A Class?
                bravocharlie.seam.signup.benny.me.uk

                My bad in the code before its a Context object, not Conversation object


                conversation = Contexts.getConversationContext()