CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Notification after adding a record

Print topic Send  topic

Author Message
act_corp

Posts: 13
Posted: 09/13/2007, 3:42 AM

All,

I'm using a test page, generated with the Record Builder, connected to a database table.
After records are submitted to the DB (click on "submit"), the page is reloaded, and the form has all the fields cleared.

What I was looking for is a way to notify the succesful insertion of the record in the DB, for example by setting the value of a label with a "the record has been added, thanks" type of message.

I tried setting the label's value in the "After Insert" event, with no luck: the label doesn't display the message after the page is reloaded.
Another way could be to append a parameter on the url once the page is submitted (how?) or setting a flag/status variable (how?). Then, in the "Before Show" event for the label I could check for that parameter/flag and set its value accordingly.

What is the most common/correct way for doing this with CC?


Thanks in advance,
Andrea Battisti

_________________
ACT Corp. - www.actgate.com
View profile  Send private message
datadoit.com
Posted: 09/13/2007, 4:45 AM

In the AfterExecuteInsert event:

if ($Container->Errors->Count == 0) {
$Container->Errors->addError("Record added.");
}
act_corp

Posts: 13
Posted: 09/13/2007, 5:31 AM

Thanks for the hint...

Adding an error message works as expected, but the "Record added" is not exactly an error, it is a notification and I would like to show it in a different place and with a different style.

I cannot simply change the style used to render the errors, because they should still remain errors and be rendered like errors (i.e. in red).

Is there a way to use a similar approach but updating an arbitrary label somewhere in the page?


Thanks again,
Andrea Battisti

_________________
ACT Corp. - www.actgate.com
View profile  Send private message
DonB
Posted: 09/13/2007, 5:57 AM

Seems to me the best thing is to have a separate page specified as the
Return Page for the 'insert page' . That can have a <meta refresh> that
returns you to the initial page after a few seconds and/or a link to the
page so they can immediately go there. This way, the users clearly see the
operation succeeded, and they wind up back on the corect page to continue
working. This also facilitates having a 'print this page for your records'
when that's desirable.

--
DonB

http://ccswiki.gotodon.net


"act_corp" <act_corp@forum.codecharge> wrote in message
news:546e92d9032a28@news.codecharge.com...
> Thanks for the hint...
>
> Adding an error message works as expected, but the "Record added" is not
> exactly an error, it is a notification and I would like to show it in a
> different place and with a different style.
>
> I cannot simply change the style used to render the errors, because they
should
> still remain errors and be rendered like errors (i.e. in red).
>
> Is there a way to use a similar approach but updating an arbitrary label
> somewhere in the page?
>
>
> Thanks again,
> Andrea Battisti
>
> _________________
> ACT Corp. - www.actgate.com
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

act_corp

Posts: 13
Posted: 09/13/2007, 6:24 AM

Quote DonB:
Seems to me the best thing is to have a separate page specified as the
Return Page for the 'insert page' .



Thanks... yes, this is another option, I'll try it.

Anyway I'm still wondering if it's possible to do it within the same page...
It could be useful also in other cases to have the ability to store a state of the interaction
and displaying something based on it...


Thanks,
Andrea Battisti



_________________
ACT Corp. - www.actgate.com
View profile  Send private message
wkempees


Posts: 1679
Posted: 09/13/2007, 7:25 AM

To act_corp
The DonB solution is likely to be your best adoption,
as you yourself state that after sucessful insert one is redirected back to EMPTY page.
Being an empty page, displaying the message would be useless, therefore the redirection to a InsertSuccess page sounds like a good solution.

Walter

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
datadoit.com
Posted: 09/13/2007, 7:34 AM

wkempees wrote:
> To act_corp
> The DonB solution is likely to be your best adoption,
> as you yourself state that after sucessful insert one is redirected back to
> EMPTY page.
> Being an empty page, displaying the message would be useless, therefore the
> redirection to a InsertSuccess page sounds like a good solution.
>
> Walter
>
> ---------------------------------------

...and the fact that you're going to an empty page (record) is because
you don't have Updates Allowed, I assume. Thus, DonB's solution seems
best - a quick little 'Record Saved' screen, which after say a few
seconds redirects back to the insert a new record page.

Could even be done with a javascript alert(). Maybe (untested)...

AfterExecuteInsert event:

echo "<HTML><SCRIPT>alert('Record saved.');</SCRIPT></HTML>";
act_corp

Posts: 13
Posted: 09/13/2007, 8:13 AM

Thanks to you all for the replies!

I guess I'll go for an additional page, with the notification message, set as the returned page of the form, as suggested.
I tried it and it seems to behave well.

Anyway I think it will be nicer to have the notification message in the same page, just as the error messages, also because the user could start immediately adding a new entry if he/she wants.
In addition, as I said, it is a more general problem: saving a state (based on some events) and use it in various places within the same page.


Thanks again,
Andrea Battisti

_________________
ACT Corp. - www.actgate.com
View profile  Send private message
datadoit.com
Posted: 09/13/2007, 8:52 AM

act_corp wrote:
> Thanks to you all for the replies!
>
> I guess I'll go for an additional page, with the notification message, set as
> the returned page of the form, as suggested.
> I tried it and it seems to behave well.
>
> Anyway I think it will be nicer to have the notification message in the same
> page, just as the error messages, also because the user could start immediately
> adding a new entry if he/she wants.
> In addition, as I said, it is a more general problem: saving a state (based on
> some events) and use it in various places within the same page.
>
>
> Thanks again,
> Andrea Battisti
>
> _________________
> ACT Corp. - www.actgate.com
> ---------------------------------------

So, change the style in your error message to something like:

if ($Container->Errors->Count == 0) {
$Container->Errors->addError("<font color='green'>Record added.</font>");
}

You could get real fancy with it using a style instead of deprecated
<font> tags. Throw a picture of a big smiley face there. All sorts of
wonderful things you could do with that Error control.

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.