Results 1 to 5 of 5

Thread: Best Practice? Load data via AppContext vs ref to httpService

  1. #1
    Join Date
    Dec 2008
    Location
    Aurora, CO, USA
    Posts
    24

    Default Best Practice? Load data via AppContext vs ref to httpService

    I'm just starting to use Prana and am adding it to an existing project. The project is a Flex frontend with a Grails backend. The grails backend will provide the current data and accept updates from the flex frontend via httpService objects. Currently I am not using a MVC framework. I might retrofit one later, but I'm too close to deadline right now.

    I am wondering about what would be considered a Best Practice for dealing with data. The data can safely be modeled with a singleton data object. In both of my examples the html launch page is dynamically generated and the id of the object we are interested in would passed in via the flashVars parameter.

    Here are my thoughts on my options.
    1. Dynamically generate a file, id.xml, as the application context and include the data inline. Construct a dataCommit HttpService in the applicationContext.xml
      Example:
      Code:
      <object id="assessment" class="valueObject.Assessment">
          <property name="name" value="some name"/>
          <property name="id" value="id value"/>
          <property name="childObjects">
            <value>
              <array-collection>
                <object .../>
                <object .../>
              </array-collection>
            </value>
          </property>
      </object>
      <object id="dataCommiter" class="service.HttpDataCommiter">
          <property name="url" value="serviceurl/path/to/commiter/<id value>"/>
      </object>
    2. Static applicationContext pointing at a dataSource and dataCommit object. Use the id as a parameter in the http service calls.
      Example:
      Code:
      <object id="dataSource" class="service.HttpDataSource">
          <property name="url" value="static url to data generator"/>
      </object>
      <object id="dataCommiter" class="service.HttpDataCommiter">
          <property name="url" value="static url to data commiter"/>
      </object>


    The advantage to the first option is only one round-trip to the server to load the data, but the disadvantage is the app will have a slower perceived load time.

    Another advantage to the first object is that it is instantiated as soon as the applicationContext is loaded, and can just be accessed immediately, where the second version has to make a second asynchronous call and have a handler called when the data is loaded. So the logic for the second method is a little more convoluted.

    Any thoughts? Am I missing something?

    Thank you,
    Adam

  2. #2
    Join Date
    Oct 2008
    Location
    Belgium
    Posts
    160

    Default

    Hi Adam,

    both methods would work, but as you said, the first method seems better. You can generate your pages on the server (on the fly, or static) and have the app load them.

    Just keep in mind that all the classes you reference in the application-context will need to be compiled into your swf that is loading the context.

    regards,
    Christophe
    Christophe Herreman
    Spring ActionScript Founder
    http://www.herrodius.com

  3. #3
    Join Date
    Jan 2009
    Location
    India
    Posts
    2

    Default Flex and Spring best practice

    Hi,

    I am new to Flex. I need to design an application using Flex and Spring and IBatis. Can anyone help me to provide suggestions for the flow and best practices.

    Thanks,
    Sanjay

  4. #4

    Default

    I use the first method. It works better for me.

  5. #5
    Join Date
    Jan 2009
    Location
    India
    Posts
    2

    Default Need detail for MVC

    Thanks for your reply. I need to know more detail on using MVC with Flex and Spring. Can you give some idea? is there a need to use struts for better MVC flow or any good suggestion for implementing MVC with Flex and Spring.

    Thanks in advance,
    Sanjay

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •