Error in XAFARI when using Web SwitchToNewStyle

StatusIDPriorityType
Closed25293MajorBug
ProfileReply
mgibsonClient

The Legacy Web version works fine. The NewStyle web version
receives this Error.

The error occurred:

Type: InvalidCastException
Message: Unable to cast object of type 'DevExpress.ExpressApp.Web.Templates.ActionContainers.Menu.SimpleActionMenuActionItem' to type 'DevExpress.ExpressApp.Templates.ChoiceActionItemWrapper'.
Data: 0 entries
Stack trace:

at Xafari.Web.WebAggregatedActionsViewController.CallbackManager_ScriptCreating(Object sender, ScriptCreatingEventArgs e)
at DevExpress.ExpressApp.Web.Templates.XafCallbackManager.GetScriptCore(String handlerId, String parameter, String confirmationExpression, String usePostBackExpression, Boolean usePostBack)
at DevExpress.ExpressApp.Web.Templates.XafCallbackManager.GetScript(String handlerId, String parameter, String confirmation, Boolean usePostBack)
at DevExpress.ExpressApp.Web.Templates.ActionContainers.Menu.ClickableMenuActionItem.GetScript(IXafCallbackManager callbackManager, String controlID, String indexPath)
at DevExpress.ExpressApp.Web.Templates.ActionContainers.Menu.ClickableMenuActionItem.GetScript(XafCallbackManager callbackManager, String controlID, String indexPath)
at DevExpress.ExpressApp.Web.Templates.ActionContainers.ActionContainerHolder.GetClickHandlers(XafCallbackManager callbackManager, ASPxMenu menu, String uniqueID)
at DevExpress.ExpressApp.Web.Templates.ActionContainers.ActionContainerHolder.menu_CustomJSProperties(Object sender, CustomJSPropertiesEventArgs e)
at DevExpress.Web.ASPxWebControl.RaiseCustomJSProperties(CustomJSPropertiesEventArgs e)

Replies

UserDescriptionPosted On
NikolayAgent

Thank you for the bug report. I will answer you as soon as possible.

Regards, Nikolay.

Sasha (Xafari Support)Agent

Hello Michael,

We have replicated this behavior, it happen when you use Web SwitchToNewStyle and Aggregate actions.
We are going to fix this issue in the near future.

At the moment you can fix this problem if you deactivate Xafari.Web.WebAggregatedActionsViewController:

public partial class FixWindowController : WindowController
{
public FixWindowController()
{
InitializeComponent();
}
protected override void OnActivated()
{
base.OnActivated();
Frame.GetController().Activated += OnDeactivateXafariController;
}
private void OnDeactivateXafariController(object sender, EventArgs eventArgs)
{
var st = sender as WebAggregatedActionsViewController;
if (st == null) return;
st.Active.SetItemValue("WebAggregatedActionsViewController", false);
}
protected override void OnDeactivated()
{
base.OnDeactivated();
Frame.GetController().Activated -= OnDeactivateXafariController;
}
}
public partial class FixViewController : ViewController
{
public FixViewController()
{
InitializeComponent();
}
protected override void OnActivated()
{
base.OnActivated();
Frame.GetController().Activated += OnDeactivateXafariController;
}
private void OnDeactivateXafariController(object sender, EventArgs eventArgs)
{
var st = sender as WebAggregatedActionsViewController;
if (st == null) return;
st.Active.SetItemValue("WebAggregatedActionsViewController", false);
}
protected override void OnDeactivated()
{
base.OnDeactivated();
Frame.GetController().Activated -= OnDeactivateXafariController;
}
}

We hope you find this information helpful.
Feel free to contact us if you need further assistance or have additional questions.

Regards,
Sasha.

mgibson

So I am a little confused. Should this code be in a View Controller in the MyProject.Module.Web?

I noticed the reference to Windows also, is that a separate View Controller?

Sasha (Xafari Support)Agent

Hi,

Yes, you can add this code in a ViewController and WindowController in your MyProject.Module.Web.
But you can override method OnViewChanged() or add next code in your existing ViewController, if the previous method does not suit you or bulky:

protected override void OnViewChanged()
{
base.OnViewChanged();
// TODO Delete this block after release new Xafari version.
var xafariController = Frame.GetController();
if (xafariController != null)
{
if (View != null)
xafariController.Active["WebAggregatedActionsViewController"] = false;
else
xafariController.Active.RemoveItem("WebAggregatedActionsViewController");
}
}

We will inform you when we are going to publish a new Xafari version.

Thanks, Sasha.

mgibson

it shows an error on Frame.GetController()

looks like it needs: ControllerType GetController() where ControllerType : Controller;

Sasha (Xafari Support)Agent

Sorry,
It is our mistake:
You have to replace the var xafariController = Frame.GetController();  on the var xafariController = Frame.GetController<WebAggregatedActionsViewController>();

× This ticket is closed.