RegisterClientScriptBlock & RegisterClientScriptInclude do not work in Composite C1 when integrated in user control - user-controls

I try to add custom javascript block from within user control in Composite C1. The user control is integrated in a nested master page (called Frontpage.master - as basis starter site "ASP.NET Master Pages" from Composite C1 has been taken and I want to stick with it as close as possible).
For analysing the problem very simple code has been used within user control:
string _jsScriptBlock = "alert('here');";
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
ClientScriptManager scriptMgr = this.Page.ClientScript;
if (!scriptMgr.IsClientScriptBlockRegistered(this.GetType(), "jsScriptBlock"))
{
scriptMgr.RegisterClientScriptBlock(this.GetType(), "jsScriptBlock", _jsScriptBlock, true);
}
}
}
The same code works in another test ASP.NET website integrating user control within nested master page. RegisterClientScriptInclude is not shown here, but it's exactly the same problem.
As a workaround I could add Javascript block and script link directly in markup of user control and master page, but I prefer "dynamic" solution by registering if necessary.
Does anybody know, if this problem is a general issue with Composite C1 framework?

Related

How to add a New Action to the mobile App

Good day
Build 20.107.0026
I have created a New Action and want to add it to my Mobile app. Is it possible to add a custom action to a mobile screen? I have created the below action in the Appointment screen(FS300200)
namespace PX.Objects.FS
{
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class AppointmentEntry_Extension : PXGraphExtension<AppointmentEntry>
{
#region Event Handlers
public PXAction<PX.Objects.FS.FSAppointment> DoWork;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "DoWork")]
protected void doWork()
{
}
#endregion
}
}
Mobile code below. If I want to add the button to the main menu; the 3 dots on the side do I use AppointmentRecords as the container?
update screen FS300200 {
update container "AppointmentRecords" {
add listAction "StartTravelAPICall" {
behavior = Void
displayName = "StartTravelAPICall"
}
}
}
The short answer is YES! The long answer depends in part on what version of Acumatica you are using. For the purpose of this answer, I'll assume you are in 2019R2 and already know how to add or edit a Mobile App screen in Acumatica. If not, the training guides referenced below should give you all the detailed information you need to accomplish your goal.
Manipulating the Mobile App screens/actions is relatively easy if the screen/action works in the browser interface. The T410 course material explains how to add an action in 2019R2. I don't work with Field Services, so I'll have to explain more generically as per the training guide.
First you must either add or edit the screen in the Mobile Application section of the Customization Project. (In your case, you want to Update the existing screen.) This will create a section of code in the customization project that looks like this:
As you can see, the original screen definition in the mobile app is shown on the right, and you will be updating the screen to add your action. You will need to add the appropriate container (not shown in your question) and then the action within that container.
To continue the answer, let's switch to the training guide example on page 12 of the T410 course updating the SO303000 screen. You can compare to your screen to see what needs to be changed.
add container "InvoiceSummary" {
# fields declaration
…
add recordAction "Save" {
behavior = Save
}
add recordAction "Cancel" {
behavior = Cancel
}
add containerAction "Insert" {
behavior = Create
}
add recordAction "ReleaseAction" {
syncLongOperation = true
behavior = Record
}
}
I believe your action would follow the ReleaseAction portion at the bottom of the example, and the need for syngLongOperation = true would depend on what your action is doing (i.e. if you need the action performed asynchronously).
Assuming your container is already defined in the page, which I suspect it is, let's instead look at the example for PO302000 on page 35. This example shows how to UPDATE a container to add your action.
update screen PO302000 {
update container "DocumentSummary" {
add recordAction "AddPOOrderLine" {
displayName = "Add PO Line"
behavior = Void
redirect = True
redirectToContainer = "AddPurchaseOrderLine$List"
}
}
}
That was a more complex action, but yours may be as simple as.
update screen FS300200 {
update container "ServiceOrderTypeLine" {
add listAction "DoWork" {
Behavior = Void
displayName = "Do Work"
}
}
}
If you need guidance on how to read the WDSL Schema to identify the container, etc. that training is found in T400 starting on Page 13.
I highly recommend reviewing both T400 and T410 if you are working with the mobile app as there is a lot more detail in those training guides than can be explained easily in a Stack Overflow post/answer.

Sharepoint 2010 Site Page with User Control = Blank Page

I have a problem with a site definition, it has several site pages, in those pages i need to have a top menu, so i created a user control, that draw that menu, and added it to the pages.
After deploying the solution i can create the site just fine.
In the initial phase, i have hard coded values for the menu links, and in each of the pages i could see the menu.
Now the menu it's dynamic, so i have a sharepoint list with the menu options, so i changed the code, instead of hard-coded values, i get them from a list, the code runs fine, i can check that while debugging, but in the end i get a complete blank page.
I can't interact with sharepoint data inside a user control that will be used in a site page?
I tested the control in a normal/application page and it works just fine, in both cases (hard-coded and sharepoint data).
A simple sample of the code:
protected void Page_Load(object sender, EventArgs e)
{
lblDate.Text = DateTime.Now.ToLongTimeString();
ddlData.Items.Clear();
//Option Manual - WORKS FINE
ddlData.Items.Add("Manual 1");
ddlData.Items.Add("Manual 2");
ddlData.Items.Add("Manual 3");
//Option Sharepoint Data - DOESNT WORK
SPSecurity.RunWithElevatedPrivileges(delegate () {
using (SPSite site = SPContext.Current.Site)
{
using (SPWeb web = site.RootWeb)
{
foreach (SPList lista in web.Lists)
{
ddlData.Items.Add(lista.Title);
}
}
}
});
}
The rest of the code, it's a simple page with the reference to this user control, and the aspx code of the user control only have the declaration of this two controls.
After several tests, i came to conclusion that i have two problems:
1 - In this project for some reason, unknown to me, inside the code someone had added some code to clear the errors, that's why i had the blank page.
2 - After seeing the error, i could confirm that if i use site pages and trying to get the data with Using, when it tries to dispose the objects it throws the exception, so the solution was simple, just remove the Usings.
Thanks

MVVMCross changing selected tab bar item from within nested view controller

We're using MVVMCross within our application and I've come up against something that I'm not sure I've solved in the best way possible.
One of our ViewModels contains 3 other view models - a dashboard and 2 lists. In iOS this is presented using a MvxTabBarViewController which works great. Android and WP present this view in a similar manner. An example of the object model is below:
public class ProjectViewModel : MvxViewModel
{
public DashboardViewModel Dashboard {get;set;}
public FirstListViewModel FirstList {get;set;}
public SecondListViewModel SecondList {get;set;}
}
We're now in the situation where if a certain action happens within the DashboardViewModel we would like to instruct the navigation to change the tab in iOS and the same thing to happen on the other platforms.
The only way I've been able to get the tab to change on iOS is to use this.SelectedIndex = 1; from within the iOS ProjectView.
At the moment also the only way I've managed to trigger this change is to fire an event from the DashboardViewModel and then the ProjectViewModel subscribes to this and fires another event which is subscribed to by the ProjectView to instruct it to change the tab in whatever device specific way it needs to. I can't help but think there is a better way to do this.
I've tried taking a look at a custom ViewPresenter for iOS and calling ShowViewModel FirstListViewModel from within the DashboardViewModel but the presenter doesn't appear to be getting used so we just transition normally. My idea was I could get in the middle, cancel the navigation request and then flip the active tab on the ProjectView.
Any suggestions would be appreciated on how we could do this in a better cross platform way using MVVMCross to handle the change if at all possible.
You should be able to do this in any of several ways:
using a custom presenter with overridden Show as you suggest
using a custom presenter with overridden ChangePresentation - and using a custom hint
using a custom binding or a binding to a property within the ProjectView to drive the transition
using a custom IMvxInteraction property
using a custom event from VM to View
using a messenger to send a message from the ViewModels to the Views.
Ultimately lots of these could work and which of these I might choose would depend on which one worked and which one the team are happy with - shipping the working app is always the ultimate goal.
Given where I am with MvvmCross experience, I'd probably opt today for trying the approach of trying a custom IMvxInteraction property. But this might not be for everyone... it certainly might be overkill for this sample...
However, to do this, I would try:
add a public enum Display { Dash, First, Second } to the Core project
add a ProjectViewModel property:
private MvxInteraction<Display> _display = new MvxInteraction< Display >();
public IMvxInteraction<Display> DisplayChange { get { return _display; } }
whenever this ViewModel wants to fire the change it can fire it using e.g. _display.Raise(Display.First)
the ProjectView could then bind Display to its own property which might be implemented like:
private IDisposable _subscription;
private IMvxInteraction<Display> _displayInteraction;
public IMvxInteraction<Display> ChangeDisplay
{
get { return _displayInteraction; }
set
{
if (_subscription != null)
{
_subscription.Dispose();
_subscription = null;
}
_displayInteraction = value;
if (_displayInteraction != null)
{
_subscription = _displayInteraction.WeakSubscribe(DoDisplayChange);
}
}
}
private void DoDisplayChange(Display which)
{
// change the tab display here
}
the binding would be added in ViewDidLoad like:
set.Bind(this).For(v => v.ChangeDisplay).To(vm => vm.DisplayChange);

Xpage Component using UIDialog, UIDialog does not render its children

I am trying to develope a component for my company wich should have an integrated dialog. Creating the component was easy until i hit the point with the Dialog. I want to use the com.ibm.xsp.extlib.component.dialog.UIDialog for my component because it has some nice features wich i want to use so creating my own dialog with a ClientSideDojo is not an option.
Normaly when adding a component to another i use component.getChildren().add(MyNewComp),but when i try this Code:
public class myComponentWithADialog extends UIComponentBase implements FacesComponent {
//...other Code...
public void buildContents(FacesContext context, FacesComponentBuilder builder)
throws FacesException {
UIDialog dialog = new UIDialog();
TypedUtil.getChildren(container).add(dialog);
dialog.setStyleClass("dlgUserPref");
dialog.setTitle("titelxyz");
dialog.setId("TagDialog");
UIPanelEx panel = new UIPanelEx();
panel.setTagName("div");
panel.setStyle("border:2px solid red;");
panel.setStyleClass("lotusList lotusTags lotusRelatedTags");
dialog.getChildren().add(panel);
this.getChildren.add(dialog);
}
//....
}
My Panel does not display inside the dialog when calling XSP.openDialog('dialogClientId') in my browser the dialog is shown but empty.
I already tried several other methods like dialog.getPopupContent.getChildren().add() but then i get the error: javax.faces.component.UIPanel incompatible with com.ibm.xsp.extlib.component.dialog.UIDialog$PopupContent.
Also i tried to find a solution on google but i only found a entry at openNTF from someone with the same problem but also without any solution.
Note: I also tried to 'inject' some content to a standard <xe:dialog> and to a <px:panel> inside the <xe:dialog> via a button with SSJS like keithstric does in his blog. Code:
var dialog:com.ibm.xsp.extlib.component.dialog.UIDialog =
getComponent('extlibdialog');
if(dialog.getChildren().size() > 0) {
dialog.getChildren().clear();
}
var TextField:com.ibm.xsp.component.xp.XspOutputText = new com.ibm.xsp.component.xp.XspOutputText();
TextField.setTitle("test");
TextField.setId("testTextField");
TextField.setValue("<p>This is the new Content</p>");
dialog.getChildren().add(TextField);
This code works fine for a standard <xp:panel> outside a dialog but not on the dialog itself or a panel inside it.
The dialogue is not pre - rendered when the page is loaded, but when you actually call for it in XSP.openDialog(...)
So you need to get your code run in that event (mobile now, can't check if it is exposed).
Plan B: do use a Dojo dialogue that is backed by a rest control, so you can transport whatever data you need back and forth.
A word of caution: popup dialogs are a UI concept transplanted from desktop apps. They are alien to Web apps and mostly not working in mobile. Consider and Inline form instead (or a wizard)

How to control application from WebBrowser Control?

I've googled it, but came out empty. And the worst thing is that I know it is possible.
Anyway, I'm developing an application that uses the WebBrowser control to display information regarding an object (like Outlook does with the Rules and Alerts dialog box).
My question is how do I do for the click on a, say, hyperlink in the WebBrowser execute some function within the Windows Form?
For instance, say I have a link like this and when I click it I want the application to display an specific form, like the Outlook does when you click on hyperlinks like People and Distribution List
This looks useful: How to: Implement Two-Way Communication Between DHTML Code and Client Application Code
ChrisW's answer will work, but there's another way if you're just relying on hyperlinks.
In Comicster, I have links in my WebBrowser control like this:
New Collection
And then in the WebBrowser's Navigating event, I have some code to check if the user has tried to navigate to an "action:" link, and intercept it:
private void webBrowser1_Navigating(object sender,
WebBrowserNavigatingEventArgs e)
{
if (e.Url.Scheme == "action")
{
e.Cancel = true;
string actionName = e.Url.LocalPath;
// do stuff when actionName == "FileNew" etc
}
}
With a little bit of code you can even parse the URL parameters and "pass them through" to your host application's action, so I can do things like:
Edit this issue
... which will open a properties dialog for the issue with ID 1.

Resources