Web Connection
Web Controls and Form Vars
Gravatar is a globally recognized avatar based on your email address. Web Controls and Form Vars
  n/a
  All
  Oct 21, 2014 @ 08:45am
Hello.

When using the Web Control framework, and working with a standard update-one-record in a table page, do all fields in a table record have to be present on the form in order for their values to be stored each time the data is saved?

I have a pretty simple page that updates a proposal record. The page will present different sub-sets of the proposal table's fields based on the type of the proposal. IOW, not every proposal record will make use of all the fields in the table. So the page will only show the appropriate sub-set of fields for the proposal based on its type.

The problem is, you enter all the appropriate data for the proposal, save it, and then, if you decide to switch the type of the proposal, you lose the data in the original fields. IOW, whenever the type of the proposal is switched and the page reloaded with the new set of fields presented, any data in the previous set of fields is zeroed out when the proposal is saved again.

It's as though, because the unnecessary fields are not shown on the page, when the data is Unbind-ed, those missing fields are being blanked out because they are not found on the page.

Thanks for any help!
Kirk


Gravatar is a globally recognized avatar based on your email address. Re: Web Controls and Form Vars
  Rick Strahl
  Kirk
  Oct 21, 2014 @ 02:47pm
Kirk,

Web Connection doesn't save your data - it only binds it so it's up to you to deal with how the data is eventually saved to disk. Web Connection only binds to the controlsource that you provide.

My guess is the problem you have is that you start with a blank record and then save this record. You get the bindings from the page to bind the stuff that displays but the rest is blank.

What you need to do is load the data you're editing (ie. do a look up by ID or whatever), then bind to the object (or cursor record) that has the old data in it. At that point the data is updated and any non-bound fields are as they are before.

This is why I advocate using business objects and an oData member to hold the actual data, because it makes it very clear what you're binding against. The process then is this:

To display:


  • Load a record in a bus object
  • Bind to that record
  • Render the form (bound fields render)

To edit:


  • Load the record you're updating
  • Or create a new record and new ID that you're saving to
  • Unbind data from the form
  • Unbinding should update only the fields that you're binding to
  • All other fields are left as before
  • Save the bus object record to disk (after validation)

This works with direct cursor binding too, but it's more difficult to undo those changes if validation fails or other things go wrong. Having an object makes the temporary binding process much, much easier.

+++ Rick ---


Hello.

When using the Web Control framework, and working with a standard update-one-record in a table page, do all fields in a table record have to be present on the form in order for their values to be stored each time the data is saved?

I have a pretty simple page that updates a proposal record. The page will present different sub-sets of the proposal table's fields based on the type of the proposal. IOW, not every proposal record will make use of all the fields in the table. So the page will only show the appropriate sub-set of fields for the proposal based on its type.

The problem is, you enter all the appropriate data for the proposal, save it, and then, if you decide to switch the type of the proposal, you lose the data in the original fields. IOW, whenever the type of the proposal is switched and the page reloaded with the new set of fields presented, any data in the previous set of fields is zeroed out when the proposal is saved again.

It's as though, because the unnecessary fields are not shown on the page, when the data is Unbind-ed, those missing fields are being blanked out because they are not found on the page.

Thanks for any help!
Kirk



Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

© 1996-2024