This project is read-only.

Consult about OnBubbleEvent

May 13, 2009 at 4:52 PM

Following is the snippet code about OnBubbleEvent on wss3workflow Framework, I am confused about the code marked with red color. In my view, it's necessary for "Commit" command only to check

_hasValidated == false || IsValid.

If the page is not valid and a "Cancel" command bubbles, in this case the page will not be redirected ! but this result is not what we want to see, you know! so I want to know why you add the condition judgement (_hasValidated == false || IsValid) for both "Cancel" and "Commit".

protected override bool OnBubbleEvent(object source, EventArgs args)
        {
            CommandEventArgs e = args as CommandEventArgs;
            if (e != null)
            {
                if (_hasValidated == false || IsValid)
                {
                    if (e.CommandName == "Cancel")
                        CancelModification();
                    else if (e.CommandName == "Commit")
                    {
                        WorkflowDataControl<ModificationData, ModificationMetaData> dataControl =
                            FormPlaceHolder.GetWorkflowControl();
                        CommitModification(dataControl.SaveData(e.CommandArgument));
                    }
                }
            }
            return base.OnBubbleEvent(source, args);
        }

Coordinator
May 13, 2009 at 7:18 PM
Here's how it works.

We want to support the CausesValidation property on buttons. So sometimes the page will not be validated when the bubble takes place. If you call IsValid when nobody called Validate in the first place, you get an error in ASP.NET. So basically, we check to see if someone called Validate (we override this method to toggle the flag), and only when someone did, we call IsValid to ensure we only commit when all page validators are ok with it.

Perhaps you forgot to set CausesValidation to false on your cancel button?

Wouter

________________________________

Van: foggia [mailto:notifications@codeplex.com]
Verzonden: wo 13-5-2009 17:52
Aan: Wouter van Vugt
Onderwerp: Consult about OnBubbleEvent [wss3workflow:56185]



From: foggia

Following is the snippet code about OnBubbleEvent on wss3workflow Framework, I am confused about the code marked with red color. In my view, it's necessary for "Commit" command only to check

_hasValidated == false || IsValid.

If the page is not valid and a "Cancel" command bubbles, in this case the page will not be redirected ! but this result is not what we want to see, you know! so I want to know why you add the condition judgement (_hasValidated == false || IsValid) for both "Cancel" and "Commit".

protected override bool OnBubbleEvent(object source, EventArgs args)
{
CommandEventArgs e = args as CommandEventArgs;
if (e != null)
{
if (_hasValidated == false || IsValid)
{
if (e.CommandName == "Cancel")
CancelModification();
else if (e.CommandName == "Commit")
{
WorkflowDataControl<ModificationData, ModificationMetaData> dataControl =
FormPlaceHolder.GetWorkflowControl();
CommitModification(dataControl.SaveData(e.CommandArgument));
}
}
}
return base.OnBubbleEvent(source, args);
}

Read the full discussion online <http://wss3workflow.codeplex.com/Thread/View.aspx?ThreadId=56185&ANCHOR#Post189807> .

To add a post to this discussion, reply to this email ([email removed] <mailto:[email removed]?subject=[wss3workflow:56185]> )

To start a new discussion for this project, email [email removed]

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings <http://www.codeplex.com/site/discussions/project/unsubscribe/wss3workflow> on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com
May 14, 2009 at 3:56 AM

oh, I got it, it's a great work!

another question: 

in TaskPage.cs, "DueDate" property is included, and your code cast "ListItem[SPBuiltInFieldId.TaskDueDate]" to DataTime type explicitly. Two hidden occasions may occur:

1. if someone would delete "SPBuiltInFieldId.TaskDueDate" field from Task List

2. if no value has been set to DueDate in Task instance

there will raise up an unknown error to user if one of occasions above occur, and for developers we will need much time to debug this problem,

so I mean,  it's necessary to add some tolerant actions to get DueDate value. so what do you think of it ? Thank you.

May 15, 2009 at 5:39 AM

If you're referring to the error caused by an empty Due Date, they are fixed in the 1.1 alpha release.  We haven't fully tested it, but it seems to be fairly stable at this point.

Chris