Announcement Announcement Module
Collapse
No announcement yet.
dwr 2.0.3 integration with 2.5.5 and webflow 2.0.2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • dwr 2.0.3 integration with 2.5.5 and webflow 2.0.2

    We are working looking at integrating web flow with dwr in an app. I am new to both spring and dwr as I am making the transition from .Net to Java with this project. A lot of the discussion so far has been centered around previous versions spring 1.x and dwr 1.x. There are enough changes (i think) and I am so new to it that I have not been able to work out to integrate the two.

    I have been using the tutorial at interna (can't post link) as a starting point but it seems to make some assumptions of knowledge that I don't have yet.

    First one of the critical thing that i need to work out is how to access the objects that are in the flowscope from my dwr servlet. I think i am screwing up something in the applicationprototype-servlet file

    I have included the trace that i have added to drwaccess because I noticed that the FlowExecutorImpl and DefaultFlowExecutionRepository are using different instances (i think), depending on if I am going through the webflow standard views or if I call through the dwr access page.


    From looking at the user guide for web flow 2 and schema the <action> tag seems to have been removed and replaced with the evaluate tag.
    So I am not sure if the DRWAction is even the correct way to implement this in 2.0.3. We have prototyped the validation and in the current version it doesnt seem like it is the prefered way to implement validator; one should implement a method with the viewstate name instead.

    The article that I was using is describing a method of having the states and transitions created dynamically but I havent even figured how to declare it statically at the moment so I cant figure out what he is getting at with that.

    I got the Expert Spring MVC and Web Flow book and it has a section on DWR but only for MVC.

    Sorry for the noob questions but we are just trying to get something started as a prototype and figure as the app grows things will start clicking. I originally had a samples of my code include but the forum post handler seems to think that the code is an external link and I had to remove. it would let me include stack trace either. If anyone is interested in looking at what i've tried i can email them.

    Any help would be appreciated.

  • #2
    DWR integration with

    I have written a small article in my blog as to how to integrate DWR 2.0.5 with Spring 2.5.5 and Spring web flow 2.0.3. The article is available at http://vigilbose.blogspot.com/2008/0...g-255-and.html.
    I hope this will give you a head start.

    Comment


    • #3
      Follow up

      I'm going to give this a go now. This seems to be a lot of the missing pieces that that wasn't in the original article, but i didn't see any references to how to get things in and out of the repository for the flow executor which seems to be the painful bit. Am I being a bit thick? will the flowscope be available in this solution or do i need to do some kind of hybrid between what you have and what was in the original blog on interna blogspot? Do i need avoid flowscope all together and just work in session?

      I think I have an image in my head about how this is supposed to work and it is completely different from how people are using it. In my servlet config file I think that I need both a flow controller and a dwr controller because the flow controller doesn't seem to understand the drw stuff and the dwr spring controller wouldn't understand the flow stuff. If I use them independently which is what i first tried they don't seem to have access to the same repository so i am unable to access the data. I tried injecting the flow executor into my drw object access and a tostring showed that it was a different instance from what the flow controller was using.

      Thanks for your help with the configuration, this does clear up a bit of confusion about where to put things that i have been having a trouble with. I'll give it a go and see if it all starts to make sense.

      Comment


      • #4
        Hi vbose

        it seems that you have experience with SWF 2.0.x
        i used to work with SWF 1 series, and with DWR

        maybe you can tell me why SWF 2.0.x has,
        "more preference" (if the term is correct) with dojo?

        regards

        Comment


        • #5
          Originally posted by walterdeane View Post
          I'm going to give this a go now. This seems to be a lot of the missing pieces that that wasn't in the original article, but i didn't see any references to how to get things in and out of the repository for the flow executor which seems to be the painful bit. Am I being a bit thick? will the flowscope be available in this solution or do i need to do some kind of hybrid between what you have and what was in the original blog on interna blogspot? Do i need avoid flowscope all together and just work in session?

          I think I have an image in my head about how this is supposed to work and it is completely different from how people are using it. In my servlet config file I think that I need both a flow controller and a dwr controller because the flow controller doesn't seem to understand the drw stuff and the dwr spring controller wouldn't understand the flow stuff. If I use them independently which is what i first tried they don't seem to have access to the same repository so i am unable to access the data. I tried injecting the flow executor into my drw object access and a tostring showed that it was a different instance from what the flow controller was using.

          Thanks for your help with the configuration, this does clear up a bit of confusion about where to put things that i have been having a trouble with. I'll give it a go and see if it all starts to make sense.
          Yes. You need both flowcontroller and dwrcontroller to work with DWR and webflow.

          You may configure flowcontroller as given below.

          <!-- Handles requests mapped to the Spring Web Flow system -->
          <bean id="flowController" class="org.springframework.webflow.mvc.servlet.Flo wController">
          <property name="flowExecutor" ref="flowExecutor"/>
          </bean>

          Please ensure the flowexecutor is defined in webflow configuration. A sample of flowexecutor definition in webflow configuration is given below.

          <!-- Executes flows: the central entry point into the Spring Web Flow system -->
          <webflow:flow-executor id="flowExecutor"/>


          To map DWR and weblow requests to different controllers, you can do something similar to what is given below.

          <!-- Maps request URIs to controllers -->
          <bean class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
          <property name="mappings">
          <value>
          /engine.js=dwrController
          /util.js=dwrController
          /call/**=dwrController
          /dwr/**"=dwrController
          /interface/**=dwrController
          /my-page=flowController
          </value>
          </property>
          <property name="defaultHandler">
          <!-- Selects view names to render based on the request URI: e.g. /main selects "main" -->
          <bean class="org.springframework.web.servlet.mvc.UrlFile nameViewController" />
          </property>
          <property name="order" value="0"/>
          </bean>

          If you use DRW namespace you can configure DWR controller like the following way.

          <dwr:controller id="dwrController" debug="true" />

          You may refer spring web flow reference document to get an idea about configuring webflow.

          Spring Web Flow 2.0.x handles the optional rendering of fragments directly in the flow definition language through use of the render element. DWR does not interfere with how Spring web flow deals with scopes. There are several implicit variables you may reference from within a flow. One of them is the flowScope. Please refer 3.5. Special EL variables in the spring web flow document.

          Comment


          • #6
            Originally posted by dr_pompeii View Post
            Hi vbose

            it seems that you have experience with SWF 2.0.x
            i used to work with SWF 1 series, and with DWR

            maybe you can tell me why SWF 2.0.x has,
            "more preference" (if the term is correct) with dojo?

            regards
            Yes. I do have experience with SWF 2.0.x. I have worked a lot with SWF 1.x as well. Currently I am working on a product where I use Spring 2.5.5, SWF 2.0.3, Spring Faces, JSF, Richfaces, DWR, Dojo and JPA technologies. Personally I feel SWF 2.0.x has improved a lot with cleaner and smaller configuration. Some of the improvements I like are given below.

            1. Cleaner and smaller configuration
            2. Partial Rendering of the page
            3. Availability of Implicit EL variables including the scopes
            4. AJAX capability
            5. Spring Faces
            6. Exporting the resources using Resource servlet (more secure)
            7. Model Validation eliminates the need to have a separate validator configuration
            8. Spring Security Integration
            9. Model Binding with limited exposure to the attributes per view
            10. Spring JS

            Comment


            • #7
              Hi vbose

              thanks for the reply

              Currently I am working on a product where I use Spring 2.5.5, SWF 2.0.3, Spring Faces, JSF, Richfaces, DWR, Dojo and JPA technologies.
              why both?

              i am confuse in this aspect, by instance Pro Spring 2.5 has a chapter with DWR,
              and it seems that SWF 2.0.x has more preference for Dojo

              so i do thinking that spring developers must learn the 2 approach?
              DWR and dojo?
              can you tell me for your experience, most important differences
              between DWR, Dojo ?

              i hope you see my point

              regards and thanks in advanced

              Comment


              • #8
                Originally posted by dr_pompeii View Post
                Hi vbose

                thanks for the reply


                why both?

                i am confuse in this aspect, by instance Pro Spring 2.5 has a chapter with DWR,
                and it seems that SWF 2.0.x has more preference for Dojo

                so i do thinking that spring developers must learn the 2 approach?
                DWR and dojo?
                can you tell me for your experience, most important differences
                between DWR, Dojo ?

                i hope you see my point

                regards and thanks in advanced
                Spring web flow 2.0.x is already integrated with dojo and I am hoping to see more integration with all the features of dojo, dijit & dojox via Spring faces tag librabry. I can only think of DWR as a tool kit designed to work with Java whereas dojo is more a javascript library to create widgets and pixel perfect UI's. I am using DWR in my product only to a limited extend where I needed to talk to Java server side from a non web flow related facelet (.xhtml) without page refresh. However the page is rendered using Spring MVC and DWR has nice integration with Spring MVC and so it becomes an obvious choice to serve the purpose.
                I am not using DWR extensively in my current project.
                Last edited by vbose; Aug 21st, 2008, 04:14 PM.

                Comment


                • #9
                  Spring web flow 2.0.x is already integrated with dojo and I am hoping to see more integration with all the features of dojo, dijit & dojox via Spring faces tag librabry.
                  it seems that i must learn dojo, mmm, some book of preference?
                  in amazon it seems that this book is the best
                  http://www.amazon.com/Dojo-Definitiv...9260362&sr=1-1

                  I can only think of DWR as a tool kit designed to work with Java whereas dojo is more a javascript library to create widgets and pixel perfect UI's
                  i see the difference now

                  Spring MVC and DWR has nice integration with Spring MVC and it becomes an obvious choice to server the purpose.
                  i am agree, even i use SWF/DWR together and not problems yet

                  thanks a lot for your information

                  Comment


                  • #10
                    Originally posted by dr_pompeii View Post
                    it seems that i must learn dojo, mmm, some book of preference?
                    in amazon it seems that this book is the best
                    http://www.amazon.com/Dojo-Definitiv...9260362&sr=1-1
                    I also refer the same book. It seems a good reference guide.

                    Comment


                    • #11
                      bit of progress

                      I have come up with a solution for this in my project and thought I would post for anyone who has the same problem. The Class is declared ServletContextAware. The portfolio is the object i am reading and writing out. Hopefully this is clear enough. Bit of a bugger to figure out until i come accross the ExternalContextHolder method which is what i was missing at first.

                      write to flowscope

                      public void setPortfolio(String key, Portfolio portfolio, HttpServletRequest req) {
                      ExternalContextHolder.setExternalContext(new ServletExternalContext(servletContext, req, null));
                      FlowExecutionRepository executionRepository = ((FlowExecutorImpl) flowExecutor).getExecutionRepository();
                      FlowExecution flowExecution = executionRepository.getFlowExecution(executionRepo sitory.parseFlowExecutionKey(key));
                      FlowSession flowSession = flowExecution.getActiveSession();
                      flowSession.getScope().put("Portfolio", portfolio);
                      executionRepository.putFlowExecution(flowExecution );
                      }

                      Read from flowscope

                      public Portfolio getPortfolio(String key, HttpServletRequest req) {
                      ExternalContextHolder.setExternalContext(new ServletExternalContext(servletContext, req, null));
                      FlowExecutionRepository executionRepository = ((FlowExecutorImpl) flowExecutor).getExecutionRepository();
                      FlowExecution flowExecution = executionRepository.getFlowExecution(executionRepo sitory.parseFlowExecutionKey(key));
                      FlowSession flowSession = flowExecution.getActiveSession();
                      flowSession.getScope().get("Portfolio");
                      }

                      Comment

                      Working...
                      X