Highlighted

Search Fragment - Best Practice?

Elaine_Schmitz

20-03-2009

We are designing a search fragment that will reside at the beginning of every form. The search fragment will allow a user to select one customer from a number of customers displayed. Once the user selects a customer, the search fragment will populate the main (parent) form with the customer data and then the search fragment should disappear.



We have a mock-up of the search fragment, but questions are surfacing as to the best way to integrate this into the form. Each form has different "customer data" fields that it needs from the search, for example, one form needs customer name and account while another form only needs customer name.



Here are some questions that are surfacing:

1. Should the search fragment "poke" the information into the parent form once the user makes a selection? If so, the fragment needs to detect which form it's on and send only the data the form needs. This will make the search fragment's javascript more complex.



2. Or, should the parent form "grab" only the information from the search fragment that it needs? This localizes the javascript to the parent form, leaving the search frag more generic. In this scenario I envision that once a user selects a customer, all customer information will be plopped into hidden fields on the search frag and the parent will use only the data that it needs.



Is there a best practice for doing something like this? Lessons learned?





Thanks,

Elaine

Replies

Highlighted

pguerett

20-03-2009

How is the search fragment going to know what to extract or is there goinng to be the same info everytime? I assume that is what you are doing. Depending on how the data is returned to you will dictate the best pratice. If it is a stream of XML then I woudl load that stream into the datadom and allow each of the fields to get their own data from the Dom (this would minimize the code needed on each form). If you are getting the info back field by field then the hidden field route is th ebest way to go (it is simple and the coding is very simple as well).