NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Rene Simons on July 12, 2009, 09:57:28 PM

Title: Use NetWebSource in a form
Post by: Rene Simons on July 12, 2009, 09:57:28 PM
Hi,
I want to embed HTML, produced by a NetWebSource into a Form.
What I have done is:
Is this a/the proper way to do it or is there a more efficient way to do it??

Kind regards,
René
Title: Re: Use NetWebSource in a form
Post by: Bruce on July 13, 2009, 09:58:06 PM
Hi Rene

This is perfectly within the design of how i's supposed to fit together, so carry on.
I recommend wrapping the code in the netWebSource in a <DIV></DIV> block, either manually or by using the template setting.

Cheers
Bruce
Title: Re: Use NetWebSource in a form
Post by: Rene Simons on July 13, 2009, 11:57:43 PM
Thanks Bruce,

Maby it's a good idea to use the term Web-procedure in stead of Browse, in the droplist.???

Cheers,
Rene
Title: Re: Use NetWebSource in a form
Post by: Rene Simons on July 14, 2009, 01:36:41 PM
Bruce,

By the way. I did it as I described. Nothing happens.
It seems that the procedure doesn't even execute.
I placed a p_web.trace('blabla') in the processed codes.
But de debugviewer shows nothing.

Rene
Title: Re: Use NetWebSource in a form
Post by: Rene Simons on July 14, 2009, 02:07:52 PM
Bruce,
Fixed it.
I used NetWebPage iso NetWebSource
Thanks,
Rene
Title: Re: Use NetWebSource in a form
Post by: Bruce on July 15, 2009, 12:08:23 AM
yes Rene, Web-Procedure would be inaccurate in the other direction because you can't use a NetWebForm or NetWebPage embedded onto a browse. Only a NetWebSource.

Cheers
Bruce
Title: Re: Use NetWebSource in a form
Post by: Rene Simons on July 16, 2009, 07:46:09 AM
Bruce,
Suppose I want to "refresh"tyhe content which is generated by my NetWebSource. E.g. after I use a button.
How would I do that?
Rene
Title: Re: Use NetWebSource in a form
Post by: Bruce on July 16, 2009, 09:12:29 PM
Hi Rene,

it depends a bit on the button, but assuming it is a "Button" and not a submit, and that the button is _not_ got a URL attached to it then;

a) make sure the netwebsource has the "Ajax Div" option turned on and
b) in the "server side code" for the button just call the netwebsource procedure.

cheers
Bruce
Title: Re: Use NetWebSource in a form
Post by: Rene Simons on July 17, 2009, 10:16:54 AM
Thanks Bruce,

Do I call the netwebsource procedure like:

packet = clip(packet) & '<!-- Net:kalender3 --><13,10>'
do sendPacket

in the server side code
Isn't it easier to give the procedure an equate and add this one to the reset-list? Or is this a stupid remark?

and

Do I place the button in the form??
Whar value do I give the timer??

Rene
Title: Re: Use NetWebSource in a form
Post by: Bruce on July 20, 2009, 01:27:25 AM
no, you call it as

kalender3(p_web)

> Do I place the button in the form??
yes

> What value do I give the timer??
0

Cheers
Bruce

Title: Re: Use NetWebSource in a form
Post by: Rene Simons on July 20, 2009, 09:50:11 PM
Hi Bruce,
I followed your instructions but nothing happens.
The server side code is executed however.
I can tell by the fact that a specific sessionvalue (startdate) has changed.

When I go to a different menu-option, and then go back to the specific page, the calender-offset date has changed according to the button I have clicked before I left the page.

Later I tried to assign an equate to the procedure (like you do with a browse) and reset that one after the server side code is executed but that also didn't work.

Cheers,
Rene
Title: Re: Use NetWebSource in a form
Post by: Bruce on July 20, 2009, 11:47:35 PM
perhaps you can make a small example and post it here Rene?

Cheers
Bruce
Title: Re: Use NetWebSource in a form
Post by: Rene Simons on July 21, 2009, 02:12:31 AM
I will. Tonight.
Title: Re: Use NetWebSource in a form
Post by: Bruce on July 21, 2009, 11:50:41 PM
There were 3 mistakes in the example app, but one of them is my fault, and another is a lack of docs, so I'll post the results here;

a) First Rene's mistake so I don't feel too bad;
You coded a routine (getMaandNaam) inside the Processed Code embed. this prevented the normal procedure end to take place (p_web._DivFooter etc.) Move this routine to the Procedure Routines embed with the other routines.

b) As you are aware the code inside the source must generate xHTML - ie it must be XML compliant HTML. And it was (almost). The one mistake you did make was to use &nbsp; which is good in HTML but not allowed in XML. In the procedure I've created a string for you (ie the template does this) called NBSP. This contains &#160; which is html and xhtml compliant.

c) lastly, my error. Since you are embedding the source on the form, as a form field, it becomes a child of that form. So when you call it from the form you need to set the Parent value. Specifically;
  p_web.SetValue('_ParentProc','exampleform')
  kalender3(p_web)
  p_web.SetValue('_ParentProc','')

the last line probably isn't necessary for your app, but might be a good habit to get into so that code after the call is unaffected by the call.

Note that this is one of the rare cases where we're using SetValue rather than SetSessionValue. This is because we're passing a "parameter" to the NetWebSource rather than setting a setting for the NetWebSource to use. You're correctly setting, and using, QDL:StartDatum as a SessionValue not a Value.

Cheers
Bruce

Title: Re: Use NetWebSource in a form
Post by: Rene Simons on July 22, 2009, 12:29:26 AM
Thanks Bruce,
I stand corrected  :D
This was a very usefull post I think.
Rene
Title: Re: Use NetWebSource in a form
Post by: Rob Mikkelsen on August 05, 2009, 09:20:53 AM
An extremely userful post, indeed!  I have successfully (thanks to this thread) been able to include a NetWebSource procedure in a web page.  I made all the mistakes that Rene did in the process and probably several more.

Added the div, removed the "return" from the processed code, set the parent, ensured proper xhtml, and it was off to the races.

To verify that I had proper XML code, I removed all the calls to SendPacket and just let the source routine call it once as the program as designed.  In the SendPacket routine, I copied the contents of Packet to the clipboard and pasted it into a text editor without all the form data which I am sure was correct.  I found that I was missing the terminator on the <img> statement.  Added that and, Voila!

Thanks, guys!  This has been a great help and opens up all kinds of possibilities.  Bruce, you may want to consider adding this process to your docs.

Rob