| Author |
Message |
Kenneth Wong
Guest
|
Posted:
Mon Nov 07, 2005 9:51 pm Post subject:
Question about CmsHttpContext.RollBackAll() |
|
|
Hi Stefan and the other Experts,
I am new to this newsgroup and MCMS as well, please correct me if I
have asked some irrelevant or redundant questions.
I am trying to write a method to update the content of the
HtmlPlaceholder in a posting.
Here is part of my code:
protected Posting P;
HtmlPlaceholder Body = P.Placeholders["Body"] as HtmlPlaceholder;
Body.Html = "This is an Updated Content.";
If (bSave)
this.cmsHttpContext.CommitAll();
else
this.cmsHttpContext.RollBackAll();
//Exit..
It looks like even the RollBackAll() is called, the content hasn't
rolled back to the original content. Do I miss anything??
Best,
Kenneth |
|
| Back to top |
|
 |
AC [MVP MCMS]
Guest
|
Posted:
Mon Nov 07, 2005 9:51 pm Post subject:
Re: Question about CmsHttpContext.RollBackAll() |
|
|
First, you're saying that it looks like the Rollback isn't actually removing
your changes? That doesn't sound right at all.
Second, how come you don't have a Submit() or Approve() action on the
posting in there before you Commit/Rollback?
--
-AC [MVP MCMS]
http://www.andrewconnell.com
http://www.andrewconnell.com/mvp
"Kenneth Wong" <kewong@gmail.com> wrote in message
news:1131391866.822812.36120@g47g2000cwa.googlegroups.com...
| Quote: | Hi Stefan and the other Experts,
I am new to this newsgroup and MCMS as well, please correct me if I
have asked some irrelevant or redundant questions.
I am trying to write a method to update the content of the
HtmlPlaceholder in a posting.
Here is part of my code:
protected Posting P;
HtmlPlaceholder Body = P.Placeholders["Body"] as HtmlPlaceholder;
Body.Html = "This is an Updated Content.";
If (bSave)
this.cmsHttpContext.CommitAll();
else
this.cmsHttpContext.RollBackAll();
//Exit..
It looks like even the RollBackAll() is called, the content hasn't
rolled back to the original content. Do I miss anything??
Best,
Kenneth
|
|
|
| Back to top |
|
 |
Kenneth Wong
Guest
|
Posted:
Mon Nov 07, 2005 9:51 pm Post subject:
Re: Question about CmsHttpContext.RollBackAll() |
|
|
Do you mean that I have to do P.Submit() or P.Approve() before calling
CmsHttpContext.RollBackAll()??
I have done Submit()/Approve() action before CmsHttpContext.CommitAll()
but not for CmsHttpContext.RollBackAll().
Please advise.
Best,
Kenneth
AC [MVP MCMS] wrote:
| Quote: | First, you're saying that it looks like the Rollback isn't actually removing
your changes? That doesn't sound right at all.
Second, how come you don't have a Submit() or Approve() action on the
posting in there before you Commit/Rollback?
--
-AC [MVP MCMS]
http://www.andrewconnell.com
http://www.andrewconnell.com/mvp
"Kenneth Wong" <kewong@gmail.com> wrote in message
news:1131391866.822812.36120@g47g2000cwa.googlegroups.com...
Hi Stefan and the other Experts,
I am new to this newsgroup and MCMS as well, please correct me if I
have asked some irrelevant or redundant questions.
I am trying to write a method to update the content of the
HtmlPlaceholder in a posting.
Here is part of my code:
protected Posting P;
HtmlPlaceholder Body = P.Placeholders["Body"] as HtmlPlaceholder;
Body.Html = "This is an Updated Content.";
If (bSave)
this.cmsHttpContext.CommitAll();
else
this.cmsHttpContext.RollBackAll();
//Exit..
It looks like even the RollBackAll() is called, the content hasn't
rolled back to the original content. Do I miss anything??
Best,
Kenneth
|
|
|
| Back to top |
|
 |
Chester Ragel
Guest
|
Posted:
Tue Nov 08, 2005 9:42 am Post subject:
RE: Question about CmsHttpContext.RollBackAll() |
|
|
Hi Kenneth,
I think you are saying about the content change while debugging. Am I
correct? From this what I think is that you are not in update mode. To make
changes in MCMS you should be in update mode. When you RollBack all the
changes in the current CmsContext gets rolled back!
Cheers,
Chester.
"Kenneth Wong" wrote:
| Quote: | Hi Stefan and the other Experts,
I am new to this newsgroup and MCMS as well, please correct me if I
have asked some irrelevant or redundant questions.
I am trying to write a method to update the content of the
HtmlPlaceholder in a posting.
Here is part of my code:
protected Posting P;
HtmlPlaceholder Body = P.Placeholders["Body"] as HtmlPlaceholder;
Body.Html = "This is an Updated Content.";
If (bSave)
this.cmsHttpContext.CommitAll();
else
this.cmsHttpContext.RollBackAll();
//Exit..
It looks like even the RollBackAll() is called, the content hasn't
rolled back to the original content. Do I miss anything??
Best,
Kenneth
|
|
|
| Back to top |
|
 |
Stefan [MSFT]
Guest
|
Posted:
Tue Nov 08, 2005 9:51 am Post subject:
Re: Question about CmsHttpContext.RollBackAll() |
|
|
Hi Kenneth,
after you did a rollback all you need to dispose the CmsHttpContext.
You are not allowed to use this context or any object retrieved using the
context again.
The content would not be valid.
So if you checked the content in code after the Rollback all you will not
find the rolled back changes if you did not dispose the context beforehand
and retrieved the posting and the placeholder again from a new context
object.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"Kenneth Wong" <kewong@gmail.com> wrote in message
news:1131399866.840804.25810@o13g2000cwo.googlegroups.com...
| Quote: | Do you mean that I have to do P.Submit() or P.Approve() before calling
CmsHttpContext.RollBackAll()??
I have done Submit()/Approve() action before CmsHttpContext.CommitAll()
but not for CmsHttpContext.RollBackAll().
Please advise.
Best,
Kenneth
AC [MVP MCMS] wrote:
First, you're saying that it looks like the Rollback isn't actually
removing
your changes? That doesn't sound right at all.
Second, how come you don't have a Submit() or Approve() action on the
posting in there before you Commit/Rollback?
--
-AC [MVP MCMS]
http://www.andrewconnell.com
http://www.andrewconnell.com/mvp
"Kenneth Wong" <kewong@gmail.com> wrote in message
news:1131391866.822812.36120@g47g2000cwa.googlegroups.com...
Hi Stefan and the other Experts,
I am new to this newsgroup and MCMS as well, please correct me if I
have asked some irrelevant or redundant questions.
I am trying to write a method to update the content of the
HtmlPlaceholder in a posting.
Here is part of my code:
protected Posting P;
HtmlPlaceholder Body = P.Placeholders["Body"] as HtmlPlaceholder;
Body.Html = "This is an Updated Content.";
If (bSave)
this.cmsHttpContext.CommitAll();
else
this.cmsHttpContext.RollBackAll();
//Exit..
It looks like even the RollBackAll() is called, the content hasn't
rolled back to the original content. Do I miss anything??
Best,
Kenneth
|
|
|
| Back to top |
|
 |
Kenneth Wong
Guest
|
Posted:
Wed Nov 09, 2005 1:50 am Post subject:
Re: Question about CmsHttpContext.RollBackAll() |
|
|
Hi Stefan, AC, Chester and All the experts,
Thanks for the suggestion. I have got the RollBackAll() call to work,
but it doesn't solve my problem.
Here is the screenshot of the app http://tinypic.com/ffbmrk.jpg
Basically, what I am trying to do is to make a "MultiPage" posting
which is actually implemented by adding separators in a HtmlPlaceholder
called "Body". When Prev/Next/Go Page button is clicked, it should
preserved the edited "page" and go to the other "page". If the user
didn't save the posting and exit from this posting, it should
"RollBack" to the previous saved state.
My current implementation is:
1. Use a placeholdercontrol to display a page of the "Body" Placeholder
2. Created a HtmlPlaceholder object to update the content of the "Body"
Placeholder
HtmlPlaceholder BP = P.Placeholders["Body"] As Htmlplaceholder;
BP.html = "New Content#Page 2";
3. String manipulation.
4. if (SaveButton is Pressed)
Submit() and do CommitAll()
else
do RollBackAll() then dispose()
But it doesn't work properly.
Below is the use case:
1. BP.html = "Page 1#Page 2" where '#' is the separator
2. Next button is pressed and BP.html is changed to "Page 1#Dirty 2"
3. Prev button is pressed and BP.html is changed to "Dirty 1#Dirty2"
When I call Exit() and do RollBackAll(), I expected it to rollback to
"Page 1#Page 2" coz' all the processes are done in one session, but it
doesn't.
Anyone has any clues.
Best,
Kenneth |
|
| Back to top |
|
 |
Stefan [MSFT]
Guest
|
Posted:
Wed Nov 09, 2005 1:50 pm Post subject:
Re: Question about CmsHttpContext.RollBackAll() |
|
|
Hi Kenneth,
how do you check if it is rolled back?
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"Kenneth Wong" <kewong@gmail.com> wrote in message
news:1131497007.196413.52860@g44g2000cwa.googlegroups.com...
| Quote: | Hi Stefan, AC, Chester and All the experts,
Thanks for the suggestion. I have got the RollBackAll() call to work,
but it doesn't solve my problem.
Here is the screenshot of the app http://tinypic.com/ffbmrk.jpg
Basically, what I am trying to do is to make a "MultiPage" posting
which is actually implemented by adding separators in a HtmlPlaceholder
called "Body". When Prev/Next/Go Page button is clicked, it should
preserved the edited "page" and go to the other "page". If the user
didn't save the posting and exit from this posting, it should
"RollBack" to the previous saved state.
My current implementation is:
1. Use a placeholdercontrol to display a page of the "Body" Placeholder
2. Created a HtmlPlaceholder object to update the content of the "Body"
Placeholder
HtmlPlaceholder BP = P.Placeholders["Body"] As Htmlplaceholder;
BP.html = "New Content#Page 2";
3. String manipulation.
4. if (SaveButton is Pressed)
Submit() and do CommitAll()
else
do RollBackAll() then dispose()
But it doesn't work properly.
Below is the use case:
1. BP.html = "Page 1#Page 2" where '#' is the separator
2. Next button is pressed and BP.html is changed to "Page 1#Dirty 2"
3. Prev button is pressed and BP.html is changed to "Dirty 1#Dirty2"
When I call Exit() and do RollBackAll(), I expected it to rollback to
"Page 1#Page 2" coz' all the processes are done in one session, but it
doesn't.
Anyone has any clues.
Best,
Kenneth
|
|
|
| Back to top |
|
 |
Stefan [MSFT]
Guest
|
Posted:
Wed Nov 09, 2005 5:51 pm Post subject:
Re: Question about CmsHttpContext.RollBackAll() |
|
|
Hi Charly,
not this should not happen.
If you are calling RollbackAll in the same request the change should not be
written to the database.
If this does happen, please check your workflow events. Maybe you are
calling CommitAll there.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"Charly" <cbretana@areteind.com> wrote in message
news:1131554439.904531.6240@f14g2000cwb.googlegroups.com...
| Quote: | Stefan,
Then one last question should clear this up for good for me (just
confirm this for me...
When we don't write to placeholder.html property, the changes are not
persisted, but when we do, they are, Does this mean that calling
property setter for HtmlPlaceholder.html property implicitly calls
commitAll() ??
And thanks so much for investing the time on this... I was assuming too
much on the part of the "binding" process... between placeholder
control and transaction...
|
|
|
| Back to top |
|
 |
Charly
Guest
|
Posted:
Wed Nov 09, 2005 5:51 pm Post subject:
Re: Question about CmsHttpContext.RollBackAll() |
|
|
Stefan,
Then one last question should clear this up for good for me (just
confirm this for me...
When we don't write to placeholder.html property, the changes are not
persisted, but when we do, they are, Does this mean that calling
property setter for HtmlPlaceholder.html property implicitly calls
commitAll() ??
And thanks so much for investing the time on this... I was assuming too
much on the part of the "binding" process... between placeholder
control and transaction... |
|
| Back to top |
|
 |
Charly
Guest
|
Posted:
Wed Nov 09, 2005 5:51 pm Post subject:
Re: Question about CmsHttpContext.RollBackAll() |
|
|
Stefan, If only a commit writes to the database, what is the call to
Rollback() rolling back ? In SQL land, you write to the database,
and then either Commit, or rollback the write... If it doesn't work
that way in MCMS, what is the rollback for ? |
|
| Back to top |
|
 |
Stefan [MSFT]
Guest
|
Posted:
Wed Nov 09, 2005 5:51 pm Post subject:
Re: Question about CmsHttpContext.RollBackAll() |
|
|
Hi Charly,
just to be clear:
- it is not possible to preserve a CmsHttpContext or a CmsApplicationContext
between different requests.
- every MCMS transaction has to be completed within one request
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"Stefan [MSFT]" <stefang@online.microsoft.com> wrote in message
news:OlTO%23pU5FHA.1416@TK2MSFTNGP09.phx.gbl...
| Quote: | Hi Charly,
MCMS has a similar transaction model.
But it does this in memory.
As many different users can access MCMS by hitting the same page it would
be bad if the actions of all these users are would interact.
These are decoupled with transactions. These tansactions are handled in
memory. They are either rolled forward (commit) and saved or rolled back.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS:
http://tinyurl.com/6zj44
----------------------
"Charly" <cbretana@areteind.com> wrote in message
news:1131552783.627984.17490@z14g2000cwz.googlegroups.com...
Stefan, If only a commit writes to the database, what is the call to
Rollback() rolling back ? In SQL land, you write to the database,
and then either Commit, or rollback the write... If it doesn't work
that way in MCMS, what is the rollback for ?
|
|
|
| Back to top |
|
 |
Stefan [MSFT]
Guest
|
Posted:
Wed Nov 09, 2005 5:51 pm Post subject:
Re: Question about CmsHttpContext.RollBackAll() |
|
|
Hi Charly,
MCMS has a similar transaction model.
But it does this in memory.
As many different users can access MCMS by hitting the same page it would be
bad if the actions of all these users are would interact.
These are decoupled with transactions. These tansactions are handled in
memory. They are either rolled forward (commit) and saved or rolled back.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"Charly" <cbretana@areteind.com> wrote in message
news:1131552783.627984.17490@z14g2000cwz.googlegroups.com...
| Quote: | Stefan, If only a commit writes to the database, what is the call to
Rollback() rolling back ? In SQL land, you write to the database,
and then either Commit, or rollback the write... If it doesn't work
that way in MCMS, what is the rollback for ?
|
|
|
| Back to top |
|
 |
Charly
Guest
|
Posted:
Wed Nov 09, 2005 5:51 pm Post subject:
Re: Question about CmsHttpContext.RollBackAll() |
|
|
If you mean in ASP.Net Session, not in "Cms session", Then I
understand that completely... I thought it made more sense to try to
use the CmsSession, which I assumed lasted for more than one request...
If I understand you correctly, it can not span requests, so we will
have ot use ASP session or in our case (since we're on a web farm,)
viewstate or hidden form fields... But this still would not answer our
problem, and that is that even though we are NOT calling commit on
these postbacks, the data changes are going into the database. On
each postback, even if we track the changes in some other persistance
medium, the changes would still be getting written to the database by
whatever mechanism is currently writing them to the database. |
|
| Back to top |
|
 |
Stefan [MSFT]
Guest
|
Posted:
Wed Nov 09, 2005 5:51 pm Post subject:
Re: Question about CmsHttpContext.RollBackAll() |
|
|
Hi Charly,
you can't check this.
But it is a clear statement that it is never possible to preserve a
CmsContext between posts.
MCMS objects are always gone at the end of a request.
You need to redesign the applicaiton to preserve the values in session
variables and only add them to the placeholders right before you would like
to commit the changes.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"Charly" <cbretana@areteind.com> wrote in message
news:1131551741.543667.254400@g47g2000cwa.googlegroups.com...
| Quote: | Stefan,
SOmething else you mentioned... "I assume that the CmsEndModule will
do a CommitAll before it disposes the
context"
What does this mean ? and How can I check this? If something is
automatically calling CommitAll() on our postbacks, that would explain
the behavior we are seeing...
|
|
|
| Back to top |
|
 |
Charly
Guest
|
Posted:
Wed Nov 09, 2005 5:51 pm Post subject:
Re: Question about CmsHttpContext.RollBackAll() |
|
|
Stefan,
Hi, Kenneth is researching this for a project we are working on
together. We know it is not being rolled back because when we close
the template (this is a Postback in which we call
CmsHttpContext.RollBackALl() And reload the same posting into the
template again, the changes made in the previous seesion are still
visible.
I have noticed something else. If we make some changes, and
immediately close the template form, (calling RollbackAll() on the
close ), the changes are not persisted.... But we have some
functionality on the template form that does a postback, and if we use
that functionality, and then on a subsequent postback close the form,
the changes are persisted... could the postbacl be afecting this ?
Regards,
Charly |
|
| Back to top |
|
 |
|
|
|
|