Initialize not being called

  • Thread starter Thread starter bryan
  • Start date Start date
B

bryan

I'm using the UIP App block and I have overridden the Initialize
method, but my override never gets called. Here's the code:

public override void Initialize(TaskArgumentsHolder args,
ViewSettings settings) {

base.Initialize (args, settings);

Logger.Write("Initialize");

}

Any ideas?

Thanks,
Bryan
 
Hi Bryan,

We have reviewed this issue and are currently researching on it. We will
update you ASAP. Thanks for your patience!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Bryan,



Welcome to MSDN newsgroup!



Based on my understanding, the current situation is you create a custom
class to implement the IView interface and use the custom class in the
project. Please let me know if I have misunderstood anything.

As far as I know, the Initialize method is called after the view manager
instantiates the view. So could you please help me to confirm some
information?

First, the category of the application is Winform or Web form;

Second, please supply the code snippet of calling the Initialize method;

Third, I suggest we set the breakpoint for the override function and debug
the project. Then we can confirm whether the Initialize method executes or
just add log failed.



I look forward to your reply.



Yuan Ren [MSFT]
Microsoft Online Support
 
On Mon, 19 Sep 2005 06:30:34 GMT, (e-mail address removed) ("ÈÎÔ¶[΢Èí]")
wrote:

Yuan -
I create a class derived from WebFormView and override the
Initialize method:

public class ViewWelcome : WebFormView {


public override void Initialize(TaskArgumentsHolder
args, ViewSettings settings) {

base.Initialize (args, settings);

Logger.Write("Initialize");

}
..
..
..
}

I never see the "Initialize" message in the log, and if I set a
breakpoint in this method it never gets hit.

I verified that the page does actually load by setting a breakpoint in
the Page_Load method.

Thanks for the help.
Bryan
 
Hi Bryan,

Thanks for your post!

After my researching, the reason of the Initialize method not executing is
that the architecture is different between Winform and Webform. In the
Webform application, switching form is implemented by call redirect method
in "Http.Context.Response". It means if we want to go to the new form, the
server side redirect to the new page directly. Below is the snippet for UIP
source code in "WebFormViewManager.cs file":
public void ActivateView( string previousView, Guid taskId, string
navGraph, string view )
{
RedirectToNextView(previousView, viewSettings);
}
the RedirectToNextView method:
private void RedirectToNextView(string previousView, ViewSettings
viewSettings)
{
try
{
if( previousView == null )
HttpContext.Current.Response.Redirect(
HttpContext.Current.Request.ApplicationPath + "/" + viewSettings.Type, true
);
else
HttpContext.Current.Response.Redirect(
HttpContext.Current.Request.ApplicationPath + "/" + viewSettings.Type ,
false );
}
catch(System.Threading.ThreadAbortException) {}
}
Actually the Initialize method is never called in the Webform application.
And below is the snippet for UIP source code in "WindowsFormViewManager.cs"
file:
public void ActivateView( string previousView, string view, Navigator
navigator, TaskArgumentsHolder args )
{
¡­
if (winFormView != null)
{
winFormView.Activate();
¡­
}
else if(controlView != null)
{
ActivateControl(controlView, previousView);
¡­
}
viewSettings = CreateNewView(view, navigator, taskId, args);
ClosePreviousFormIfNecessary(null, previousView, taskId, viewSettings);
¡­
}
We can find the CreateNewView call the ActivateForm method. And in the
ActivateForm method, the Initialize executes directly.
So the reason for designing is the Webform application use Http pipeline to
communicate with each other but the Winform application can create the new
form directly. We can find the description about the Initialize method in
the documentation as below:
"Called after the view manager instantiates the view, but before calling
Show()."
(*The documentation you can download from below link:
http://www.microsoft.com/downloads/details.aspx?FamilyId=98C6CC9D-88E1-4490-
8BD6-78092A0F084E&displaylang=en)
It means the method is used in the Winform application because there is no
the show method in the Webform application.
If your want to add the log for the Webform application. I suggest we add
the function into the "WebFormView_Load" method or your custom load method.

I hope the above information helps, if you have any questions or concerns,
please do not hesitate to let me know. I am standing by to help you.

Thanks.

Yuan Ren [MSFT]
Microsoft Online Support
 
Hi Yuan -

Thanks for the response. I figured it was something like that. My
reason for wanting to override the Initialize method is to be able to
use custom attributes in the <view> section of the config file, which
are passed to Initialize in the ViewSettings argument. (Each page has
some supplementary information and I thought the config file would be
a good place to store it.) Since Initialize is never being called, is
there an easy way to get access to this information?

Thanks again for all the help!

Bryan
 
Hi Bryan,

Thanks for your posting!

Based on my understanding, you require getting a custom attributed value
while the application is loading. Meaning you want to use a ViewSettings
argument such as ¡°ViewSettings.Type¡±. Please let me know if I have
misunderstood.

If we want to use the value in our custom class, I think reading the
setting from the config file directly is a better way. In the ¡
°WebFromViewManager.cs¡± file, the ¡°ActiveView¡± method is another method
for getting the value of settings, but different from the ¡
°WindowsFormViewManager.cs¡± file. The WebForm Application doesn¡¯t supply
any method like ¡°Initialize¡±, so my suggestion is we read the value of
the setting from the config file by using a XML reader or have the UIP do
it. The reading method can be executed in our custom ¡°WebFormView_Load¡±
method.

I hope the above information helps, if you have any questions or concerns,
please do not hesitate to let me know. I am standing by to help you.

Yuan Ren [MSFT]
Microsoft Online Support
 
Hi Yuan -
I think you have understood my problem. I have several attributes
which I want to associate with individual views. Since it looks like
there is no easy way to have the UIAP block get these for me in a
WebFormView derived class, I'll just read them from the config file
myself as you suggested.

Thanks,
Bryan
 
Hi Bryan,

While, I'm glad to help you for the issue. If you have any issues or
concern, welcome to MSDN newsgroup. We'll discuss together.

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top