work-table problem please help!!!

ira_claire

New Member
Hi,
we are currently developing a Web Based Application which is based from our previous text application. We just recently bought a new licensed for open edge of progress just to create this application.
Since we are just new with web speed, we are having problem with creating our temporary work-table. Unlike in text based we can retain the record of the temporary table in web based as soon as you click the html input tag (type is submit) the record would not retain. We need to evaluate the field entries from the user before we could store the entry to the physical database. Is there any way we can create temporary work-table even if you will click the submit button the record would retain? Or any code we could use to solve this problem?
Please help!

:confused::confused:
 

Casper

ProgressTalk.com Moderator
Staff member
I don't think I understand you correctly, but if you have a user send a form by clicking the submit button, then in the progres procedure you're calling from the submit you can retrieve the entered values.

With webspeed you don't have any progress code at the client side (i.e webbrowser). The progress code only runs at the webspeed agent.

If you want to validate code at the client site (i.e. in the webbrowser) then you have to use javascript for that.

At the agent site you can retrieve the values the user entered by using the function get-value('name input field').

So the summarise:
  1. You have a form with fields that can have data input from the user.
  2. Submit form (action=some progress programm which runs on the server)
  3. In that progress program you retrieve the values from the fields the user entered data in by using get-value('name input field in HTML form')
Temp-tables (we don't use worktables anymore... ;-) can be made in the progress procedure and used anyway you like.

I don't know if this answers your question, if you meant something else then please specify.


HTH,

Casper.
 

ira_claire

New Member
I don't think I understand you correctly, but if you have a user send a form by clicking the submit button, then in the progres procedure you're calling from the submit you can retrieve the entered values.

With webspeed you don't have any progress code at the client side (i.e webbrowser). The progress code only runs at the webspeed agent.

If you want to validate code at the client site (i.e. in the webbrowser) then you have to use javascript for that.

At the agent site you can retrieve the values the user entered by using the function get-value('name input field').

So the summarise:
  1. You have a form with fields that can have data input from the user.
  2. Submit form (action=some progress programm which runs on the server)
  3. In that progress program you retrieve the values from the fields the user entered data in by using get-value('name input field in HTML form')
Temp-tables (we don't use worktables anymore... ;-) can be made in the progress procedure and used anyway you like.

I don't know if this answers your question, if you meant something else then please specify.


HTH,

Casper.
Actually we are using Open Edge v10, We had created our webform via application builder with blank document save them as html files, with this we can embed progress code under script tag language = SpeedScript we already used get-value to get user's entry in the fields. We used define work-table progress code to create temporary table. Usually from our previous text-based application we are doing the same thing but using procedures creating temp table to evaluate user's entry before we finally save data in our database but in web-based it no longer applies. I did try using CGI wrapper to create my temp-table their by defining work-table but it didn’t work. Is there any way I could create temporary table?
 

jongpau

Member
Hi Ira_Claire,

It does not matter what you create your application in. AppBuilder or Notepad, it is all the same (except that Notepad cannot compile of course). The web is stateless. So if you send something to a web browser, that is that and that is the end of the story. There is NO progress running on the web browser (like Casper already said). All that is sent to the client is HTML, CSS, Javascript and whatever else you have in your web page. If you want to keep the record/information you sent to the browser, you could for instance keep the primary key in a hidden field on the form so that you can go and fetch it again once the user hits submit (which you can catch in your SpeedScript). So there is no way to actually keep a Progress temp-table or work table open once you have sent data to the client (and if there actually is such a way I would not advise you to use it). The web works completely different from "normal" Progress, so you have to rethink what you are doing and how you do it...

Also know, when you use SpeedScript/WebSpeed you will need to have a web server with WebSpeed configured and installed on it -- like Casper said, the code is executed by the agent and that is on the web server

And all this this is nothing new to Progress or WebSpeed, it works the same for most other languages that allow you to do web programming (for instance php and asp). The only thing you normally run on the client will be something like JavaScipt (which can do part of your validations), or Java (slow), or maybe some ActiveX (but then you bind yourself to Internet Explorer and you definately do not want to do that).

Does this help/answer your question? If not, create a slimmed down version of your code (without all the AppBuilder tag gobbledigook in it and with only one or two fields and a submit button) and post some of it here so we can have a look at what you are doing.


Good luck!

Paul
 

ira_claire

New Member
Thanks for the information. If that is the case, can you please give us some advice on how we should do this?
Our web server is already Webspeed configured. Our head doesn’t wants us to create a physical temporary table in our server solely use for validation purposes.
Here is the scenario:

<input type="text" name="code1" >
<input type="text" name="code2" >
<input type="text" name="code3" >
<input type="text" name="code4" >
<input type="text" name="code5" >
<input type="text" name="code6" >
<input type="text" name="code7" >
<input type="text" name="code8" >
<input type="text" name="amount1" >
<input type="text" name="amount2" >
<br>
<iframe scr='samp.html'></iframe>
<br><br>
<input type="submit" name="save" value='Save'>
<input type="submit" name="delete" value='Delete'>

Code1 has corresponding code2 to code8 validations entries; either amount1 or amount2 should be zero depending from the code1 (We already have javascript for all these validation). As soon as the user onkeypress the last amount2 field, the 10 entries from the 10 fields should be display at the iframe and the 10 fields should be cleared for another 10 entries and so on. Once the user finally submit the form, the total of amount1 plus the total of amount2 should be equal to zero otherwise all the entries should not be save on the ledger table.
:eek:
 

jongpau

Member
Hi,

Sounds like you require no SpeedScript for this really; more of a job for some JavaScript/DHTML or AJAX. I would not have any examples of how to best do this handy. Maybe someone else can help you out?
 

a.vermeulen

New Member
I advise you to use two frames in one page like this:
<form id="sub" method="post">
<input type="hidden" name="function" value="subs">
<input type="text" name="code1">
<input type="text" name="code2">
<input type="text" name="code3">
<input type="text" name="code4">
<input type="text" name="code5">
<input type="text" name="code6">
<input type="text" name="code7">
<input type="text" name="code8">
<input type="text" name="amount1">
<input type="text" name="amount2"> <br>
<input type="submit" name="savesub" value="Save sub">&nbsp;
</form>
<form id="total" method="post">
<input type="hidden" name="function" value="totals">
<input type="hidden" name="numlines" value="2">
<input type="hidden" name="values1" value="1,2,3,4,5,6,7,8,10">
<input type="hidden" name="values2" value="1,2,3,4,5,6,7,8,10">
<input type="submit" name="save" value="Save"> <input type="submit" name="delete" value="Delete">
</form>

From the post, first read the "function" value.
If "subs" then add another hidden field to the second form and increase the "numlines" value.
If "totals" then the user clicked in the second form.
do counter = 1 to integer(get-field('numlines')):
valueline = get-field('values' + string(counter)).
/* fill a temp-table */
end.
/* do some more checking on the temp-table */
/* if correct then save the temp-table to the database */

I hope this gives you a hint in the right direction.
Regards,
Alexander Vermeulen
 

ira_claire

New Member
Hi Alex,
Thanks for your suggestion, I did try it but I have a problem with adding hidden element. My code won't work in my Appbuider but in other html editor like frontpage or macromedia it does work well. Below is my code :
function addElement(){
var newElement = document.createElement('<INPUT TYPE='hidden' ID='myId' VALUE='0'>')
document.body.insertBefore(newElement);
var num = (document.getElementById('myId').value -1 + 2) ;
alert(num);
}

I did copied and paste your html codes above plus a button for calling
to call addElement().Is there some limitation in AppBuilder?Or did I miss something?Please advice.

Thanks in Advance,
Ira_claire
 

a.vermeulen

New Member
This way you are trying to get it done in Javascript.
But just try it the Progress way....

save this as a .p (twoform.p for example) in the propath of your webspeed server.
CREATE WIDGET-POOL.
&Scoped-define PROCEDURE-TYPE Procedure
&Scoped-define DB-AWARE no
{src/web2/wrap-cgi.i}
output-content-type ("text/html":U).
def var count as integer no-undo.
def var countto as integer no-undo.
def var postval as char no-undo.
def temp-table hidvals
field nr as integer
field hidval as char.

assign countto = integer(trim(get-value('numlines'))).
do count = 1 to 8:
assign postval = postval + "," + get-value('code' + string(count)).
end.
assign postval = trim(postval,",").
message countto get-value('numlines').
do count = 1 to countto:
create hidvals.
assign hidvals.nr = count
hidvals.hidval = get-field('values' + string(count)).
message count.
end.
create hidvals.
assign hidvals.nr = count + 1
hidvals.hidval = postval.

case get-value('button'):
when "delete" then do:
empty temp-table hidvals.
count = 0.
end.
when "save" then do:
/* do something with the values saved in temp-table */
end.
end.

{&OUT} '
<form id="sub" method="post">
<input type="hidden" name="function" value="subs">
<input type="hidden" name="numlines" value="' count + 1 '">
<input type="text" name="code1">
<input type="text" name="code2">
<input type="text" name="code3">
<input type="text" name="code4">
<input type="text" name="code5">
<input type="text" name="code6">
<input type="text" name="code7">
<input type="text" name="code8">
<input type="text" name="amount1">
<input type="text" name="amount2"> <br>
<input type="submit" name="savesub" value="Save sub">&nbsp;
</form>
<form id="total" method="post">
<input type="hidden" name="function" value="totals">
<input type="hidden" name="numlines" value="' count + 1 '">'.
for each hidvals no-lock:
{&OUT} '<input type="hidden" name="values'
hidvals.nr
'" value="'
hidvals.hidval
'">'.
end.
{&OUT} '<table>'.
for each hidvals no-lock:
{&OUT} '<tr><td>' hidvals.nr '</td><td>' hidvals.hidval '</td></tr>'.
end.
{&OUT} '</table>'.
{&OUT} '
<input type="submit" name="button" value="Save"> <input type="submit" name="button" value="Delete">
</form>'.

Both forms will submit to the program itself. In fact you can work with only one form. I hope this helps.

Regards,
Alexander
 
Top