Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am developing an application in Flex. There are 20+ 'pages', each with its own form. I need to collect all the entered data and pass it to an API method. What I am wondering is when I should begin to pass the data and what the best way to collect it might be. I was thinking of instantiating a class

public class myCollectorClass

The API method has 10 parameters, 4 of which are not determined by the forms. Of the 6 remaining parameters, 5 are simple strings with few options. Those are not the difficult part. It is the last parameter that is the most difficult to work with:

public var myDataSet:DataSet[]; //DataSet is a data type from the API

The forms fall into two categories: Geographical Data which controls the geographical area of the API return values. And Search Data which controls the type of data returned within the geographical parameters. For instance, if you are looking for an IT company in the US Zip code 93003.

As you can see, the geo and search parameters are arrays not simple strings and a typical collection will contain multiple zip coes, area codes SCBA codes etc., as well as hundreds of search parameters.

Would it be better for me to pass each selected value to the array each time a value is entered?

btnAddParameter.addEventListener(Event.CLICK, dataHandler)

Or pass all of the values at the end right before an order is placed?

for each dataContainer in myClass
{
    var dataObj:Object;
    dataContainer.value = dataObj;
    myParamArray.addItem(dataObject)
}
share|improve this question
2  
20 pages? I'd hate to have to fill that out.... –  Michael Todd Jun 17 '11 at 22:42
    
Agreed. The graphic designer is responsible for that. She made this cool looking Accordion nested in a TabNav that is very difficult to program. The funny thing is the app that the API comes from does exactly what I am trying to do but they have all of the selections on one scrollable page. My boss does not like to "scroll down"... –  Steeev Jun 17 '11 at 22:45
1  
Sounds to me like your graphic designer isn't a user interface and usability expert.. Something you may want to look into. That number of pages would immediately short circuit my want to subscribe. –  Demian Brecht Jun 17 '11 at 23:22
add comment

2 Answers 2

up vote 1 down vote accepted

I would opt for an item-by-item feed to the server. This not only protects against the poor user having to re-input all of that stuff, it also gives you the chance to do on-the-fly modifications of the form.

share|improve this answer
    
Yeah that's a good point. It would also allow me to let them save their forms to come back to later. Is that going to slow the app's performance down though? –  Steeev Jun 17 '11 at 22:49
    
@steve: Slow it down? I kind of doubt it; we're dealing with "people speed" here. As soon as they move off a field and you get a onBlur event (or whatever the Flex equivalent is) then you write it out in the background. –  Peter Rowell Jun 17 '11 at 22:52
add comment

I like your idea of saving everything in a "collector class" for two reasons. One, it makes sense to perform everything at once at the end of the process, so you may as well have easy access to all of the information collected along the way. And two, having everything that you need stored away allows you to create state within your application. That way, if a user wants to exit the program and come back later (to finish all 20 pages), you could easily serialize their data to an external data source, then deserialize it back into the application when they're ready to continue.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.