BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Populating HTML Form Fields with Data before serving it to C

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
jbk
Guest





PostPosted: Sat Apr 17, 2004 8:24 pm    Post subject: Populating HTML Form Fields with Data before serving it to C Reply with quote



I have a Indy HTTPServer Component serving html templates to clients. I
have no problem reading the data out of the templates once the user post
it. The question is how do I populate the fields in these templates
with data before serving them to the client?

Thanks in Advance

JBK
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Apr 17, 2004 8:47 pm    Post subject: Re: Populating HTML Form Fields with Data before serving it Reply with quote




"jbk" <jbk (AT) nowhere (DOT) com> wrote

Quote:
The question is how do I populate the fields in these templates
with data before serving them to the client?

Put placeholders in the template that your code can look for. Then store
the template data into memory, such as in a simple String, and then scan
through the data looking for the placeholders where you should be inserting
your data, and replace the placeholders with your actual data. Then serve
the final data.


Gambit



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Apr 17, 2004 10:47 pm    Post subject: Re: Populating HTML Form Fields with Data before serving it Reply with quote



"Ben Hochstrasser" <bhoc@surfeu123^H^H^H.ch> wrote


Quote:
If you're using windows, there's an easy way to
have the operating sytem fill in the values:

True. However:

1) it is Windows specific.

2) it only works with "%name%" strings specifically, which such a format may
not be desireable. Using custom opening/closing tags for tokens reduces the
risk of detecting mismatched/invalid tokens.

3) if a string is not found in the environment, the original string and
sorrounding "%" tokens is left untouched, whereas my code stripped them out
indicating an empty string.

4) the input and output strings are limited to 32K max, so you wouldn't be
able to process larger templates. Do do so would require breaking the
strings into 32K blocks and calling ExpandEnvironmentStrings() multiple
times, and as well as dealing with tokens overlapping at the block
boundaries.


Gambit



Back to top
Ben Hochstrasser
Guest





PostPosted: Sat Apr 17, 2004 11:15 pm    Post subject: Re: Populating HTML Form Fields with Data before serving it Reply with quote

Remy Lebeau (TeamB) wrote:

Quote:
1) it is Windows specific.

That's what I said too. :)

Quote:
2) it only works with "%name%" strings specifically, which such a
format may not be desireable. Using custom opening/closing tags for
tokens reduces the risk of detecting mismatched/invalid tokens.

Well, you came up with the "percent-tokens"; that's why I had this idea.

Quote:
3) if a string is not found in the environment, the original string
and sorrounding "%" tokens is left untouched, whereas my code stripped
them out indicating an empty string.

That is true.

Quote:
4) the input and output strings are limited to 32K max

The 32K were only in my example. Is there a hard-coded limit?

Oh, while we're discussing this - in HTML line breaks do not matter
(unless between <pre>...</pre> tags). So I'd write the template in a way
that had the placeholder in a line of its own which would greatly
simplify searching/replacing...

--
Ben

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sun Apr 18, 2004 6:14 am    Post subject: Re: Populating HTML Form Fields with Data before serving it Reply with quote


"Ben Hochstrasser" <bhoc@surfeu123^H^H^H.ch> wrote


Quote:
Well, you came up with the "percent-tokens"; that's why I had this idea.

I chose that because such an approach is commonly used in several
server-side scripting languages, such as ASP, PHP, etc. PHP uses "<?php ...
?>" instead of "<% ... %>". The point I am trying to make is to use SOME
kind of unique identifiers should be used to denote where special processing
should start and stop. Which tokens are actually decided on is jbk's
personal choice.

Quote:
4) the input and output strings are limited to 32K max

The 32K were only in my example. Is there a hard-coded limit?

Yes, there is, and it is clearly stated as such in the Win32 API
documentation for ExpandEnvironmentStrings():


http://msdn.microsoft.com/library/en-us/sysinfo/base/expandenvironmentstrings.asp

"The size of the lpSrc and lpDst buffers is limited to 32K."

Quote:
Oh, while we're discussing this - in HTML line breaks do
not matter (unless between <pre>...</pre> tags).

Not exactly. From a theoritical standpoint, you are correct that line
breaks should not make any difference. In real world use, however, you have
to be careful with them because line breaks DO make a difference in certain
situations. Depending on what the surrounding HTML content is, line breaks
can actually introduce extra spacing in the browser display, amongst other
possible minor/subtle side effects. That may or may not be
desirable/acceptable to the user.

Quote:
So I'd write the template in a way that had the placeholder
in a line of its own which would greatly simplify searching/replacing...

It may help the parser some, but in actuality the more inline the processing
tags are allowed to be, the more flexible the parser will be overall.



Gambit



Back to top
jbk
Guest





PostPosted: Mon Apr 19, 2004 4:07 pm    Post subject: Re: Populating HTML Form Fields with Data before serving it Reply with quote

Remy Lebeau (TeamB) wrote:
Quote:
"Ben Hochstrasser" <bhoc@surfeu123^H^H^H.ch> wrote in message
news:Xns94CFCE166339bhoc (AT) 207 (DOT) 105.83.66...


Well, you came up with the "percent-tokens"; that's why I had this idea.


I chose that because such an approach is commonly used in several
server-side scripting languages, such as ASP, PHP, etc. PHP uses "<?php ...
?>" instead of "<% ... %>". The point I am trying to make is to use SOME
kind of unique identifiers should be used to denote where special processing
should start and stop. Which tokens are actually decided on is jbk's
personal choice.


4) the input and output strings are limited to 32K max

The 32K were only in my example. Is there a hard-coded limit?


Yes, there is, and it is clearly stated as such in the Win32 API
documentation for ExpandEnvironmentStrings():


http://msdn.microsoft.com/library/en-us/sysinfo/base/expandenvironmentstrings.asp

"The size of the lpSrc and lpDst buffers is limited to 32K."


Oh, while we're discussing this - in HTML line breaks do
not matter (unless between <pre>...</pre> tags).


Not exactly. From a theoritical standpoint, you are correct that line
breaks should not make any difference. In real world use, however, you have
to be careful with them because line breaks DO make a difference in certain
situations. Depending on what the surrounding HTML content is, line breaks
can actually introduce extra spacing in the browser display, amongst other
possible minor/subtle side effects. That may or may not be
desirable/acceptable to the user.


So I'd write the template in a way that had the placeholder
in a line of its own which would greatly simplify searching/replacing...


It may help the parser some, but in actuality the more inline the processing
tags are allowed to be, the more flexible the parser will be overall.



Gambit


Thanks for your help.


Jef

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.