close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Delete file server behavior

Thread began 10/11/2012 9:07 am by dvan_zelst | Last modified 10/12/2012 8:04 am by Jason Byrnes | 2258 views | 8 replies |

dvan_zelst

Delete file server behavior

Hi Jason,

I need your help for this:

I created some insert,update,detail and result pages (standard) with DataAssist.
In the insert page i have a file field to upload an image to a folder.
This all works well, the file get's uploaded and the filename stored in the databse column.

Now i added a delete file behavior to the results page with the trigger set to Delete button pressed. This behavior code is placed before the delete record from database and it works great. The file get's deleted when delete is pressed and also the record is deleted from the database.

Now i do exactly the same on the detail page but where ever i place the delete file behavior code only the database record get's deleted but the file remains in the folder.

Do you have any idea why it works on the result page but not on the detail page when delete button is pressed?

Thanks for your advice.

Sign in to reply to this post

Jason ByrnesWebAssist

without seeing the code, my only guess is that the delete record behavior comes first, and is redirecting to another page before the delete file behavior can run.

if you send the pages though, i can give a more concrete answer.

Sign in to reply to this post

dvan_zelst

Hi Jason,

Attached is the detail page where the delete file behavior comes before the delete record behavior. I also tried to put it after the delete record but same result.

Thanks

Attached Files
teams_detail.zip
Sign in to reply to this post

Jason ByrnesWebAssist

in the delete file behavior you are using the recordset to tell it which file to delete.

the problem with that is this:
on page load, the recordset uses the teamID querystring variable to filter the correct team record

when the form post, it reloads the page, this means the record is recreated. The action of the form does not pass the teamID url variable, so the recordset is empty.

since the recordset is empty, the delete behavior does not know which file to delete.

there are 2 ways to correct the problem:
1) add a hidden form element to the delete form and set the initial value for the hidden element to use the tamPicture column from the recordset. then in the delete file behavior, bind the file name to the hidden element.

2) change the code for the form tag:

php:
<form class="DetailsPage DetailsPage Custom_CustomSharp" id="Details_Custom_CustomSharp" method="post"  action="<?php echo (htmlentities($_SERVER["PHP_SELF"], ENT_QUOTES)); ?>">



to:

php:
<form class="DetailsPage DetailsPage Custom_CustomSharp" id="Details_Custom_CustomSharp" method="post"  action="<?php echo(htmlentities($_SERVER["PHP_SELF"], ENT_QUOTES)."?".$_SERVER["QUERY_STRING"]); ?>">
Sign in to reply to this post

dvan_zelst

Hi Jason,

Thanks for your explanation. I did not realize that but understand now.
On the results page the recordset returns all records, no URL varaibles are used so when posting the form on the resultspage just re-crreates the recordset with records again. That's why it is working on the resultspage, however on the detail page you filter by URL variable the first time the page loads but when submitted there are no URL varaibles passed anymore resulting in an empty recordset for the delete file behavior to use. Am i correct?
If so then i understand.

I will add the hidden form element to store the filename for deletion and try again.

Thanks again Jason it was very helpfull.

Sign in to reply to this post

dvan_zelst

Hi Jason,

I figured out i also had to include the hidden form element in the repeat region on the results page to make it work. Before it always deleted the wrong file because of the same reason.

Now it is working on the result page and on the detail page.

I also want to include the delete file behavior on the update page once a new file is uploaded. i know i can set the trigger on succesfull upload and again i need to include a hidden field that holds the teamPicture filename.

My question is: when i look at the hidden form element used on the update page, the hidden field value is: <?php echo($_GET["invalid"])((isset?ValidatedField("teamsupdate","WADAUpdateRecordID"):$_GET["teamID"])); ?>

Now i was wondering which binding generates this code when adding such value manually to a hidden form? Do i need similar code holding my teamPicture filename?

If i choose a binding for the hidden element value the code is without the '($_GET["invalid"])' code.

All is working now though also the update page but just wonder if this code has to be handcoded or comes from a binding.

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

that is the hidden element for the pictureID, not for the picture name.

you need to have another hidden element that is bound to the picture name column of the recordset.

Sign in to reply to this post

dvan_zelst

Hi Jason,

I know and already have the extra hiddenfield. All is working well now.

I was just wondering which binding generates the code used in the hidden form element 'WADAUpdateRecordID' value field? <?php echo($_GET["invalid"])((isset?ValidatedField("teamsupdate","WADAUpdateRecordID"):$_GET["teamID"])); ?>

Thanks.

Sign in to reply to this post

Jason ByrnesWebAssist

that code is not generated by a binding, it is generated by the wizard.

the validation failure passed a querystring back:
update.php? invalid=true


this querystring is used to tell the form element whether to use the Validated entries value or the recordset value (or in the case of this element the URL variable) as the initial value.


this is done to preserve any changes that might be made, say the user changes the first name, but validation fails for another element, it will retain the changed first name instead of defaulting back to what is in the recordset.


it uses a shortened if statement called a ternary expression. the format of a ternary exrpesing is:

(question)?if true:if false;


in this case, it's looking to see if the "invalid" URL variable is set, if it is, it uses the validated entries binding. if not, it uses the teamID URL variable

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...