1

I'm using EWL and I have an EwfPage and when I type partial in the Info class I see:

partial void initDefaultOptionalParameterPackage( OptionalParameterPackage package )

and

partial void initUserDefaultOptionalParameterPackage( OptionalParameterPackage package )

I don't really see what they're used for. They also sound similar and I'm wondernig what the difference between them is.

Sam Rueby
  • 5,914
  • 6
  • 36
  • 52

1 Answers1

1

They are both used if you want an optional parameter to default to something other than the default value of its C# data type. There are two significant differences:

  • initUserDefaultOptionalParameterPackage is called only when you are creating an Info object for the page; it is not called when the page is requested. If a request is made without a parameter value in the URL, the framework will fall back to the value specified in initDefaultOptionalParameterPackage or the data type default.
  • You can access AppTools.User from initUserDefaultOptionalParameterPackage if you meet the conditions specified in the doc comment for AppTools.User.

An example of when you might use initUserDefaultOptionalParameterPackage is a page that should default to showing information for the currently logged-in user but has a select list or something that lets you look at information for a different user.

William Gross
  • 2,083
  • 2
  • 17
  • 35
  • Is `initDefaultOptionalParameterPackage` called only when the page is requested? Can you provide an example of when `initUserDefaultOptionalParameterPackage` is useful? – Sam Rueby Oct 14 '12 at 23:51
  • @Sam.Rueby: `initDefaultOptionalParameterPackage` is called whenever an `Info` object is created, whether it is for the current request or not. For your second question, see my edited answer. – William Gross Oct 16 '12 at 18:13