Ads 468x60px

Tuesday, February 19, 2013

XAF : Access current object when override Link or UnLink actions

To do this, follow the following steps
  1. Create XAF ViewController that inherit from WebLinkUnlinkController Class
  2. Override Link or Unlink actions
    Protected Overrides Sub Link(ByVal args As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs)
  3. Use the following code to access the current object
    CType(Frame, NestedFrame).ViewItem.CurrentObject
Code:

   1:  Imports System
   2:  Imports System.ComponentModel
   3:  Imports System.Collections.Generic
   4:  Imports System.Diagnostics
   5:  Imports System.Text
   6:   
   7:  Imports DevExpress.ExpressApp
   8:  Imports DevExpress.ExpressApp.Actions
   9:  Imports DevExpress.Persistent.Base
  10:  Imports DevExpress.ExpressApp.SystemModule
  11:  Imports DevExpress.Persistent.BaseImpl
  12:  Imports DevExpress.Data.Filtering
  13:  Imports DevExpress.ExpressApp.Web.SystemModule
  14:   
  15:  Public Class CustomLinkUnlinkViewController
  16:      Inherits WebLinkUnlinkController
  17:   
  18:      Public Sub New()
  19:          MyBase.New()
  20:   
  21:          'This call is required by the Component Designer.
  22:          InitializeComponent()
  23:          RegisterActions(components)
  24:   
  25:      End Sub
  26:   
  27:      Protected Overrides Sub OnActivated()
  28:          'Dim target As LinkUnlinkController = Frame.GetController(Of LinkUnlinkController)()
  29:          ' target.LinkAction.Active.SetItemValue("LinkAction", False)
  30:          ' target.UnlinkAction.Active.SetItemValue("UnlinkAction", False)
  31:          'InputBox("", "", View.Id)
  32:          MyBase.OnActivated()
  33:      End Sub
  34:   
  35:      Protected Overrides Sub Link(ByVal args As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs)
  36:          MyBase.Link(args)
  37:   
  38:      End Sub
  39:   
  40:   
  41:   
  42:  End Class

No comments:

Post a Comment