Hi! I want to do some functionality in my ASP XAF project. It is should be some javascript code on client side which will connect though ajax to the server and check if new objects is added to some table and display a blinking icon to a user. How to do that?
How to execute some action from the client side in XAF Web application
Answers
Hi Aibol,
You can use the following approach to redirect to an XAF view by clicking on a client-side image (this code was tested on MainDemo):
C#public class CallbackHandler : IXafCallbackHandler {
#region IXafCallbackHandler Members
public void ProcessAction(string parameter) {
WebApplication application = WebApplication.Instance;
IObjectSpace objectSpace = application.CreateObjectSpace();
DemoTask obj = objectSpace.FindObject<DemoTask>(new BinaryOperator("Subject", "Review reports", BinaryOperatorType.Equal));
DetailView view = application.CreateDetailView(objectSpace, obj);
WebApplication.Redirect(application.RequestManager.GetQueryString(view.CreateShortcut()));
}
#endregion
}
public partial class DefaultVertical : BaseXafPage {
protected void Page_Load(object sender, EventArgs e) {
CallbackManager.RegisterHandler("Redirect to task detail view", new CallbackHandler());
ASPxImage image = new ASPxImage();
image.ClientSideEvents.Click = string.Format("function(s, e){{ {0}; }}", CallbackManager.GetScript("Redirect to task detail view", ""));
Controls.Add(image);
.......................
}
}
Please let us know if you need an additional assistance.
Hello Aibol,
I believe it is possible to accomplish this task.
Since this is not specific to XAF, you can use any solution you would use to achieve the same goal in a regular non-XAF ASP.NET application. If you experience difficulties integrating this solution in XAF, please let us know. We will be glad to assist you further.
PS.
If you need to register client scripts in XAF, check out the 3rd point of the eXpressApp Framework 11.2 ASP.NET Application Migration Guidelines KB Article.
Ok, i done this with my custom coding (AJAX + JQUERY). Now i need to redirect user to some form by clicking on that icon. How i should generate that link?