The changes made to the data in the EmployeeWebPart will now be saved. in .NET framework

Encoder DataMatrix in .NET framework The changes made to the data in the EmployeeWebPart will now be saved.

The changes made to the data in the EmployeeWebPart will now be saved.
Data Matrix 2d Barcode Maker In VS .NET
Using Barcode generation for ASP.NET Control to generate, create Data Matrix image in ASP.NET applications.
www.OnBarcode.com
Barcode Creation In .NET Framework
Using Barcode generator for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
NOTE
Painting Data Matrix ECC200 In Visual Studio .NET
Using Barcode creator for ASP.NET Control to generate, create Data Matrix image in ASP.NET applications.
www.OnBarcode.com
Linear 1D Barcode Maker In VS .NET
Using Barcode creation for ASP.NET Control to generate, create Linear Barcode image in ASP.NET applications.
www.OnBarcode.com
In the chapter 6 folder of the resources included with this book, there is a project named PersonalizationInterfaces which contains the full source code for a web page named TestSetPersonalizationDirty.aspx, which can be used to test the SetPersonalizationDirty behavior.
EAN / UCC - 13 Maker In Visual Studio .NET
Using Barcode encoder for ASP.NET Control to generate, create GTIN - 128 image in ASP.NET applications.
www.OnBarcode.com
Draw Barcode In VS .NET
Using Barcode creation for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
In this example the calling web page is required to call the SetDirty method on the web part to ensure that changes are saved. Failure to implement that method call will result in a loss of data for users who make changes and expect to have them saved. Calling the SetDirty method is therefore an unintuitive additional step which is likely to lead to data being lost. A better way would be to include the call to the SetPersonalizationDirty method directly within the Employee property of the web part itself, like so:
Create PDF-417 2d Barcode In Visual Studio .NET
Using Barcode creator for ASP.NET Control to generate, create PDF-417 2d barcode image in ASP.NET applications.
www.OnBarcode.com
MSI Plessey Generator In Visual Studio .NET
Using Barcode generator for ASP.NET Control to generate, create MSI Plessey image in ASP.NET applications.
www.OnBarcode.com
[Personalizable] public Employee Employee { get { return _employee; } set { SetPersonalizationDirty() ; employee = value; } }
Data Matrix Creator In Objective-C
Using Barcode generator for iPhone Control to generate, create Data Matrix 2d barcode image in iPhone applications.
www.OnBarcode.com
Printing ECC200 In Java
Using Barcode drawer for Android Control to generate, create ECC200 image in Android applications.
www.OnBarcode.com
This way, whenever the Employee data was set, the web part would be flagged as dirty and the personalization data would be saved. Although this change would be useful for calling code because there would no longer be a need remember to call the SetDirty method, it also would mean that the data for the EmployeeWebPart would always be marked as dirty. This is because personalization uses this property setter when it is re-loading personalization data at the beginning of lifecycle of the page. What we really need is a way to have the call to SetPersonalizationDirty 182
Barcode Creation In Objective-C
Using Barcode printer for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
Code39 Maker In None
Using Barcode generation for Excel Control to generate, create Code 39 Extended image in Excel applications.
www.OnBarcode.com
UNDERSTANDING PERSONALIZATION
Printing Code 39 Extended In Objective-C
Using Barcode generation for iPhone Control to generate, create Code-39 image in iPhone applications.
www.OnBarcode.com
ECC200 Maker In None
Using Barcode printer for Word Control to generate, create Data Matrix 2d barcode image in Office Word applications.
www.OnBarcode.com
included in the property setter, but only have it called when the data being set is from some operation other than personalization loading. We can see an example of this in the following code snippet:
Create GTIN - 13 In Java
Using Barcode printer for Android Control to generate, create EAN-13 image in Android applications.
www.OnBarcode.com
QR Code JIS X 0510 Encoder In None
Using Barcode creator for Software Control to generate, create QR image in Software applications.
www.OnBarcode.com
[Personalizable] public Employee Employee { get { return _employee; } set { if( !this.IsLoading ) SetPersonalizationDirty() ; employee = value; } }
Encoding UPC-A Supplement 2 In Java
Using Barcode maker for Eclipse BIRT Control to generate, create UPC-A Supplement 2 image in BIRT applications.
www.OnBarcode.com
USS-128 Drawer In None
Using Barcode generation for Font Control to generate, create EAN128 image in Font applications.
www.OnBarcode.com
To help solve problems such as this, the portal framework supplies special interfaces that can be implemented to hook into the loading, saving, and state tracking activities performed throughout the lifecycle of a web part. In the next section we ll see how these interfaces are used and look at some scenarios surrounding their use. 6.5.2 Personalization interfaces As mentioned, the portal framework contains certain interfaces that can be implemented to allow us to extend web part controls with custom logic. These interfaces provide hooks into the lifecycle of saving and loading personalization data and allow us to create custom solutions for loading and storing personalization data as well as tracking activity that occurs throughout the lifecycle. The personalization interfaces are IPersonalizable Provides methods that allow us to take ownership of the loading and storing process of personalization data for an individual web part control. IVersioningPersonalizable Provides a way to manage personalization data for a web part that has now had its definition changed. ITrackingPersonalizable Allows us to write code to perform tasks at various stages during the loading and saving of personalization data. By implementing these interfaces, developers can control how data is loaded, tracked, and saved by writing code to manage complex personalization. Let s take a deeper look at each of the personalization interfaces to see what they are and how we can use them to assist us when dealing with complex personalization scenarios. IPersonalizable Implementing IPersonalizable on a web part control requires that the following property and two methods be implemented: IsDirty This property indicates whether data for the control has changed Load Custom logic for loading the data for the control Save Custom logic for saving the data for the control WORKING WITH PERSONALIZATION DATA 183
Encode Data Matrix ECC200 In Java
Using Barcode creator for Java Control to generate, create Data Matrix 2d barcode image in Java applications.
www.OnBarcode.com
EAN-13 Supplement 5 Encoder In None
Using Barcode drawer for Online Control to generate, create GTIN - 13 image in Online applications.
www.OnBarcode.com
Both the Load and Save methods are passed a PersonalizationDictionary object which contains a collection of PersonalizationEntry items as shown by the following method signatures:
Load(PersonalizationDictionary state) Save(PersonalizationDictionary state)
For example, consider a web part that maintains a list of a user s favorite website links. Such a web part might maintain the list of links in a complex property such as the following property, which uses a generic list of strings to store data:
private List<string> _hyperlinks = new List<string>(); [Personalizable] public List<string> Hyperlinks { get { return _hyperlinks; } set { _hyperlinks = value; } }
For such a class, this data would not be persisted because the standard personalization behavior for ASP.NET portals does not know how to deal with complex data types such as this. By implementing the IPersonalizable interface, custom code such as that shown in listing 6.6 can be written to store any serializable data types in the PersonalizationDictionary.
Listing 6.6 Implementing the Load and Save methods of the IPersonalizable interface provides a way to write custom logic for handling personalization data.
public new void Load(PersonalizationDictionary state) { PersonalizationEntry pe = state["Hyperlinks"] as PersonalizationEntry; if (pe != null) { this.Hyperlinks = (List<string>) pe.Value; } }
Copyright © OnBarcode.com . All rights reserved.