Announcement Announcement Module
No announcement yet.
Best Practice? Load data via AppContext vs ref to httpService Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
      <object id="assessment" class="valueObject.Assessment">
          <property name="name" value="some name"/>
          <property name="id" value="id value"/>
          <property name="childObjects">
                <object .../>
                <object .../>
      <object id="dataCommiter" class="service.HttpDataCommiter">
          <property name="url" value="serviceurl/path/to/commiter/<id value>"/>
    2. Static applicationContext pointing at a dataSource and dataCommit object. Use the id as a parameter in the http service calls.
      <object id="dataSource" class="service.HttpDataSource">
          <property name="url" value="static url to data generator"/>
      <object id="dataCommiter" class="service.HttpDataCommiter">
          <property name="url" value="static url to data commiter"/>

    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,

  • #2
    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.



    • #3
      Flex and Spring best practice


      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.



      • #4
        I use the first method. It works better for me.


        • #5
          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,