The question says it all. I want to know if it a good idea to manually call the accepttext() or pfc_accepttext to force powerbuilder to accept the values in the datawindow fields.
The reason behind this question is that I have a datawindow in a popup window which contains some fields. When the user enters values in that fields and presses an OK button, the datawindow is saved and the popup window is closed. When the ok button is clicked, the last field isn’t properly accepting the input value. That’s why I was thinking of manually firing accepttext() or pfc_accepttext event.
Any help will be appreciated!!!
Thanks.
Yes, it is a very good idea to make sure a
dw.accepttext()is fired prior to attempting to save any datawindow. Otherwise, like you pointed out, it may not save all the information the user enters unless they tab out of each field; which end users should not be expected to do.For more complicated windows/objects you could create a simple function for this, such as
wf_accepttext()which contains all thedw.accepttext()calls for each datawindow that will need to be updated. Then you can just call that function before you attempt to update your datawindows.(Edit) Additional thoughts:
Terry’s comment above reminded me of something I neglected to include in my initial answer.
accepttext()returns-1if a field’s validation fails.So if you make a custom function to handle all your
accepttext()calls, make sure you write it to handle this return code. Something such as this should be sufficient:This way, at the top of your save function, let’s call it
wf_save(), you can do this:And in the event that something doesn’t validate,
wf_save()will bail, and youritemchangedevent should have code to handle the rest.