NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Rob Kolanko on April 17, 2012, 10:48:03 AM

Title: Save and Next button for NetWebForm
Post by: Rob Kolanko on April 17, 2012, 10:48:03 AM
Hi,
I wish to have two save functions on two different buttons on a NetWebForm. The first save function will do the standard update of the record and  return to the browse (a Save button). The second save function will save the record as well, but instead of returning the browse, the next record in the table is fetched and the NetWebForm page is generated using this record (a Save and Next button).

I believe this a common concept  (similar to the old VCR next button) and I have easily programmed the function in windows apps many times, however I not sure where to start with a NetWebForm. Has anybody done this with a NetWebForm procedure?

I do not believe the a NetWebForm page can have two save buttons on form and if you can, how would you change the name of one of the Save buttons and not the other. One idea is to add a check box that says “Edit next record when checked” and in the form’s “URL on Save” field add a CHOOSE statement to select the URL based on the check box status. The URL to itself would have parameters to trigger fetching the next record before generating the form.  But, I would much rather just have a Save and Next button, instead of a checking the check box and pressing the Save button.

Are there parameters (values) that will have to be set to when NetWebForm is generated a second time to allow update of the fetch record? The Form to Form example has the following in the URL on Save field of the first form:
Code: [Select]
SecondForm?change_btn=change&_bidv_=' & p_web.AddBrowseValue('firstform','mailboxes',MAI:PrimaryKey)I do not understand what this does, but will I need similar parameters when I call the NetWebForm again for the Save and Next function.

Should I put the code to retrieve the next record in the  NetWebForm or in the _sendfile  routine of the web handler procedure?

Thanks,
Robert Kolanko
Title: Re: Save and Next button for NetWebForm
Post by: kevin plummer on April 17, 2012, 04:52:13 PM
I did a similar thing that you want on a mobile app where I just wanted to go straight to a form and toggle through the records.

I would experiment with using a memory form and then just adding 2 "other" type buttons to perform the actions you mean. Obviously you would need to code in your own fetch and save routines.

Title: Re: Save and Next button for NetWebForm
Post by: Bruce on April 17, 2012, 09:37:48 PM
Robert,

while you can have more than 1 save button on a form (you can add buttons of type "save") - they will all be the "same", so I don't think you can use this to get the effect you want.

Kevin's approach is probably the best one - you would use "other" buttons. But replicating "save" behavior, or indeed "next record" behavior will not be completely trivial. There are some very intricate actions going on under the hood to make all the embeds work, to make the form itself work, and so on.

What I recommend is that you take one of the examples, and mock up what you have in mind. Example 1 should do nicely. Don't worry about making it work, just mock up the general layout.

then post that here, and I'll see if I can add the code to support what you have in mind.

cheers
Bruce
Title: Re: Save and Next button for NetWebForm
Post by: Rob Kolanko on April 18, 2012, 10:10:49 AM
Hi Bruce,
As suggested, I have attached is my attempt add a “Save and Next” button on the web1 example. I changed the wizard tabs to plain tabs for ease of use in this test.  I did not change  NetWebForm  to update memory, in an attempt to keep the update as generic as possible. The “Save and Next” button actually works with validation. However after the “Save and Next” button is used the standard “Save” button no longer updates the record.  The _sendfile method to call the form again may require additional parameters to make the form work properly. Also the return statement may not be correct where it is located or if it is even necessary, I was just trying to leave before any other values were set.  Additional validation is needed when the end of file is reached, but I can add that later.
Please correct if possible.

Thanks
Robert Kolanko


[attachment deleted by admin]
Title: Re: Save and Next button for NetWebForm
Post by: Bruce on April 19, 2012, 06:13:51 AM
thanks Robert - I'll give it a look.
(warning, it may take a few days - I'm out the office tomorrow)

cheers
Bruce
Title: Re: Save and Next button for NetWebForm
Post by: Rob Kolanko on April 25, 2012, 07:49:39 AM
Hi Bruce,
Any luck with that example?
Thanks Robert Kolanko
Title: Re: Save and Next button for NetWebForm
Post by: Bruce on April 27, 2012, 02:00:36 AM
sort of.
doing it elegantly is not easy. I've tried a couple approaches, but I'm not satisfied with any of them. I'll keep at it though.

cheers
Bruce
Title: Re: Save and Next button for NetWebForm
Post by: Rob Kolanko on April 27, 2012, 06:27:06 AM
Thanks Bruce,
When I first attempted the procedure, I thought it would be straight forward, prep the session variables the same way as the NetWebBrowse does, then use the _sendfile method to call the NetWebForm again. But obviously there is more to it than that. I really appreciate you helping me, I believe others will benefit from your work as well.

Robert Kolanko
Title: Re: Save and Next button for NetWebForm
Post by: Rob Kolanko on May 08, 2012, 06:54:37 AM
Hi Bruce,
Do you think that there will be a solution to this request? or will there need to be a future enhancement of Nettalk? Do you believe that there is much need for this functionality?
Thank-you for your assistance.
Robert

Title: Re: Save and Next button for NetWebForm
Post by: Bruce on May 08, 2012, 10:42:44 PM
Hi Robert,

I think, to do it "right" I'll definitely need to add support into NetTalk for this. It's probably "hackable" with NetTalk as it is now, but it would be ugly hand-code, and would be quite "fragile" because it would rely on a bunch of things remaining unchanged. So it's not an ideal way to do it.

With a bit of low-level support it becomes much more robust, and is likely to work for longer, and work smoother. Unfortunately I've just been over-whelmed the past while, so I haven't had much time to develop the necessary code.

>> Do you believe that there is much need for this functionality?

That's a hard question to answer, because like so many things nicer interfaces only become popular once they exist. No-one has asked for this before, but frankly that doesn't mean much. I think it definitely has a use-case - perhaps not as common as the browse-form paradigm, but useful nonetheless.

At the end of the day I only have the 4 pairs of fingers, so I'll try and get to it as soon as I can.

cheers
Bruce


Title: Re: Save and Next button for NetWebForm
Post by: Rob Kolanko on May 09, 2012, 08:46:26 AM
Hi Bruce,
Thank-you for your reply. If the right solution is forth coming then I will wait as long as I can. I do not wish to be a squeaky wheel, I only wish to let you know that I am looking forward to the proper solution, even if you do not hear from me on this topic.

Actually, the ideal solution for me, would be a method to use "_SendFile"  using the NetWebForm page with the primary key to the file record in session variables and have the NetWebForm handle the record update as if it was called from the NetWebBrowse. I could use this method in other situations besides this one.

Regards,
Robert Kolanko
Title: Re: Save and Next button for NetWebForm
Post by: Bruce on May 09, 2012, 11:22:40 PM
A reminder from time to time (just adding to this thread) would be no bad thing Rob. Usually there's more to do than time to do it in, so bumping outstanding issues is a good way to get them back into the brain.

cheers
Bruce
Title: Re: Save and Next button for NetWebForm
Post by: Bruce on May 19, 2012, 03:52:18 AM
Hi Robert,

just a progress update.

>> The second save function will save the record as well, but instead of returning the browse, the next record in the table is fetched and the NetWebForm page is generated using this record (a Save and Next button).

The devil, as they say, is in the details. In this case the phrase "next record in the table" is deceptive. It implies that a sort order, and quite possibly a filter for the table has been set.

In the case of a browse / form paradygm these have been set, by the browse procedure - so we need a mechanism to hook into that. (But remember the browse is View based, so that's a complication.) If you do come from a browse you'd definitly want the browse order and filter to be respected.

On the other hand, there may be no browse - you may instead use the Form-only approach, in which case the order and filter need to be defined in the form.

Do-able, but not trivial.

cheers
Bruce
Title: Re: Save and Next button for NetWebForm
Post by: Rob Kolanko on May 22, 2012, 10:32:30 AM
Hi Bruce,
Thank-you for your continued effort on this issue. You are right, I have made two requests in this thread. The first “Save and Next button”  request is simpler to explain, is to be able to add a button to a form that will save the current record and get the next record in the browse without returning to the browse. If you could modify the NetWebForm template  to do this by simply adding a special button in the NetWebForm template, that would be super cool.  Thus the template would generate the code to construct the view as in the browse, then locate the position of the current record in the view, then get the next record and reload the form with this record.   

The second request would be a just to be able to do part of the first request. That would be to have capability to call a NetWebForm page (i.e. via the "_SendFile"  method)  from the same or different NetWebForm with the primary key to the file record in session variables and have the NetWebForm handle the record update as if it was called from the NetWebBrowse. Then  the programmer is responsible to get next primary record key fields for the form, such as building the view, or whatever to get the next record.  The NetWebForm template only allows a single table to be updated anyway, not the view.  One of my objectives is to do a “save and next” method. The second request, although more complex for programmer,  has more flexibility, thus I am just as happy with the second request.

Hopefully this helps you or maybe I am just rewording your comment.

Robert Kolanko
Title: Re: Save and Next button for NetWebForm
Post by: Rob Kolanko on June 01, 2012, 07:13:36 AM
Hi Bruce,
I got 2 of my 3 change request coming in 6.33, How about this one?
Thanks,
Rob Kolanko :)
Title: Re: Save and Next button for NetWebForm
Post by: bruce2 on June 01, 2012, 07:59:07 AM
sorry Rob... :(
Title: Re: Save and Next button for NetWebForm
Post by: Rob Kolanko on July 19, 2012, 12:55:14 PM
Hi Bruce,
You said I could remind you of this request. I will need to make a decision soon on how to handle this problem. I am thinking that I will need to change my NetWebForm from a table to memory source form. I would then add the code to update the record and to get the next record. I would like to keep the NetWebForm  as  a table source form, but there appears to be no way, the NetWebForm will update the table record unless the  NetWebForm is requested from a NetWebBrowse. (e.g. my original example in this thread).

In short, I would be to have capability to call a NetWebForm page (i.e. via the "_SendFile"  method)  from the same or different NetWebForm with the primary key to the file record in session variables and have the NetWebForm handle the record update as if it was called from the NetWebBrowse. Then  the programmer is responsible to get next record for the form, such as building the view, or whatever to get the next record. 

Thanks,
Rob Kolanko
Title: Re: Save and Next button for NetWebForm
Post by: Bruce on July 19, 2012, 09:58:30 PM
Hi Rob,

yeah, I haven't had much time to work on this, and I don't yet have an ellegant solution in mind.

>> but there appears to be no way, the NetWebForm will update the table record unless the  NetWebForm is requested from a NetWebBrowse. (e.g. my original example in this thread).

no, this isn't true. Forms can be called "directly" (and often are.) See Web Server FAQ, question #4 to do it via a URL. also notice on the "advanced" tab of the form settings that you can specify the default action for the form, and even bind the form to a record.

In your case you would use the techniques from FAQ #4 for the ID, and you could set the action of the form to "Change" on the advanced tab.

Cheers
Bruce
Title: Re: Save and Next button for NetWebForm
Post by: Rob Kolanko on July 20, 2012, 11:35:23 AM
Hi Bruce,
I originally tried calling the form using the method described in FAQ 4 in my example, but it did not work properly. The form appears but the save button does not update the record. Attached is my example of the Save and Next button using the  method described in FAQ 4. The MailboxesFormControl form's Save button will save the record if called from the browse, but the Save button will not save the record if the form is requested by the  _Sendfile function using the FAQ 4 method in the Save and Next button. Have I done something wrong in the example?
Thanks,
Rob Kolanko 

[attachment deleted by admin]
Title: Re: Save and Next button for NetWebForm
Post by: Bruce on July 22, 2012, 10:52:22 PM
I changed your approach a bit - example is attached.
note that I changed the "save and next" button to be a "save" button - that's a better starting point.

Bruce


[attachment deleted by admin]
Title: Re: Save and Next button for NetWebForm
Post by: Rob Kolanko on July 23, 2012, 09:21:52 AM
Hi Bruce,
Unfortunately your example does not work ( I least for me).  I compiled the web1 example posted and observed the following:
Edit the second record (Courtney) change size limit field value and press the Save and Next Button. The Courtney  record is saved and the next record is available for update (Derek).  Change Size limit filed value and press the Save button, and nothing happens. The page does not change and the Save, Save and Next or Cancel buttons no longer not work.

Yet I have seen the Save button work after a Save and Next, but I cannot repeat the process. Not working far exceeds working.  :(

Rob Kolanko
Title: Re: Save and Next button for NetWebForm
Post by: Bruce on July 24, 2012, 04:36:00 AM
pah - the work of a single line of embed code to fix that problem...
(ok, I admit, it took a bit of time to figure out exactly what the line should be <g>)

updated example is attached.

[attachment deleted by admin]
Title: Re: Save and Next button for NetWebForm
Post by: Rob Kolanko on July 24, 2012, 07:18:29 AM
Hi Bruce,
The example works great now. The post update embed code is the "bomb".  ;D I will deploy it in my applications. I think this function is often used in applications and addition to an example would benefit others.
Thanks again, I really appreciate your help.
Rob Kolanko
 
Title: Re: Save and Next button for NetWebForm
Post by: Rob Kolanko on July 26, 2012, 09:24:31 AM
Hi Bruce,
When I tried to put the Save and Next code into my application, the results where not as expected. When the Save and Next button was selected, the current record was saved successfully and the next record appear in the form, however selecting either the Save or the Save and Next buttons returned to the browse without update.  Debug shows no p_stage events occurred after these Save buttons were pushed and the browse screen returns.  First let us verify that I have not made any errors in entering the PostUpdate embed code. The italicized code is replaced with the values described.

  if p_web.GetValue('_buttontext_') = p_web.translate('Save and Next')
    do GetNextRecord
    p_web.Requestfilename = '<NetWebForm procedure name>'
    p_web.SetValue('<NetWebForm procedure name>_form:inited_',0)
    p_web.setValue('change_btn','change')         
    p_web.SetValue('_parentPage','<NetWebbrowse procedure name that called the NetWebForm>')
    p_web.SetValue('_bidv_',p_web.AddBrowseValue('<NetWebbrowse procedure name that called the NetWebForm>','<File Name>',<primary key of file>,p_web.GSV('<primary key value>')))   
    p_web.SetValue('<primary key field name>',p_web.GSV('<primary key value>'))
    p_web.RequestReferer = p_web.gsv('SaveRefer<NetWebForm procedure name>')
  end

Rob Kolanko
Title: Re: Save and Next button for NetWebForm
Post by: Bruce on July 31, 2012, 06:13:16 AM
two minor things I noticed;

p_web.SetValue('_bidv_',p_web.AddBrowseValue('<NetWebbrowse procedure name that called the NetWebForm>','<File Name>',<primary key of file>,p_web.GSV('<primary key field name>')))   
p_web.SetValue('<primary key field name>',p_web.GSV('<primary key field name>'))

other possible pressure points;

a)  if p_web.GetValue('_buttontext_') = p_web.translate('Save and Next')
Double check that the text on your "save and next" button is what you are testing for here.

b) The buttons (Save & Save and Next) are both of type SAVE. I think at some points in your testing you had them set as type BUTTON.

Keep us posted.
cheers
Bruce

Title: Re: Save and Next button for NetWebForm
Post by: Rob Kolanko on August 04, 2012, 03:12:39 PM
Well, I got Save and Next on NetWebForm to work for my application, but I did number of variances to the method that Bruce had proposed in the web1 example. I documented the changes on the attached word file, SaveAndNext.doc.  When I get a chance, I will put these changes into the Web1 example . The reasons for the changes is that the second Save button was causing problems and it just was not working in my application.

Also I would like to report a bug. When program is used with the MSIE8 browser, the p_web.GetValue('_buttontext_') is returning  'undefined' for the “Save and Next” button. So right now,  I am also checking for 'undefined' text as if it was 'Save and Next' .  This is likely a bug in the NetTalk object because the p_web.WholeURL method returns the same text when used with  either MSIE8 or Firefox browsers.

Thank-you for your assistance,
Robert Kolanko

[attachment deleted by admin]
Title: Re: Save and Next button for NetWebForm
Post by: Bruce on August 05, 2012, 11:34:28 PM
I think I'd need an example to test the IE8 problem you're having Rob.

cheers
Bruce
Title: Re: Save and Next button for NetWebForm
Post by: Rob Kolanko on August 06, 2012, 08:18:11 AM
Attached is an example. I added a submit button to the MailboxesFormControl form of the Web1 example that we have been working with. This submit button links to the MailboxesFormControl via URL. I added a p_web._trace statment in the InitForm embed that shows the value returned from p_web.GetValue('_buttontext_') method. Use debug to see the results. When firefox is used, p_web.GetValue('_buttontext_') method  returns the button's text "Submit Button" when MSIE8 is used, the method returns "undefined".

Thanks for your assistance,
Robert Kolanko

[attachment deleted by admin]