LogoLogo
WinForms to WebPowerBuilder to .NETPowerBuilder to Java
  • WebMAP Documentation | Mobilize.Net
  • WinForms
    • Introduction
    • Getting Started
    • Conversion Process
    • Post-Conversion
    • Extend or Modify the Converted Application
      • NoWebMap Forms Winforms
        • How to add a new Form
        • Adding the created form to the migrated App
        • Interacting with the application data
        • Call the custom API
        • Interaction between the no webmap added Form and the WebMap components
      • Adding a component
      • Adding a component dynamically
      • Add a new control model
      • Switching CSS theme
      • Adding new window
      • Conversion Configuration
        • WebMAP configuration file
        • Stub Filter
      • Adding Non-WebMap Angular Forms
      • Adding FrontEnd Handler to a ToolStripMenuItem
      • Changing ToolStripButton icons
      • Adding new items to existing toolbar
      • Adding FrontEnd element properties and JS listeners
      • Adding FrontEnd output handlers
      • Access FrontEnd components
      • Create custom components based on existing WebMap Component
      • Override FrontEnd methods
    • Assessment Mode
    • Errors and Troubleshooting
      • How to resolve broken reference problems with VBUC
    • Portability
    • Glossary
    • Release Notes
    • Internal Demos
    • Known Issues
    • WinForms DCP
  • WebForms
    • Introduction
    • Overview
    • Desktop Compatibility Platform (DCP)
      • Pages and Master Pages
      • GridView and DataList data synchronization
      • HTTP objects
    • Post-Conversion
    • Extend or Modify the Converted Application
      • Adding FrontEnd validator
      • Adding Page
      • Adding MasterPage
    • Designer classes on WebForms Conversion Tool
    • Errors and Troubleshooting
      • How fix Solution when have been added website from filesystem without project file
    • Release Notes
  • PowerBuilder to .Net
    • Introduction
    • Getting Started
      • Conversion Tool
    • Desktop Compatibility Platform (DCP)
      • Data Manager
    • Reports
      • Report Rendering in Modernized Code
      • ReportWatcher Service Configuration
      • Data Manager to RDL Conversion
      • Reporting Service Internals
      • Troubleshooting
  • PowerBuilder to Java
    • Introduction
    • Getting started
    • Post-Conversion
      • Setup PBJava Environment
      • Architecture
      • App Start
    • Glossary
    • Errors
    • Glossary
    • FAQ
      • How to create a new Control
      • How to create a new Screen
      • What is the Mobilize.WebMAP.CoreServices.All?
      • What is the DesignerAttribute?
      • What is the InterceptedAttribute?
      • What is the InterceptedAttribute?
      • What is the ObservableAttribute?
      • What is the Mobilize.Weaving.WebMAPExtensions.All?
  • General
    • FrontEnd
      • Documentation
        • Webforms Angular Components
          • Web Components
            • Base Components
              • BaseValidator Component
            • KendoUI Components
              • CompareValidator
              • CustomValidator
              • RegularExpressionValidator
              • RequiredFieldValidator
              • ValidationSummary
          • Directives
          • AJAX Web Components
            • AjaxCalendar
            • AjaxModalPopupExtender
          • Ajax Interaction Services
        • Client Core
          • WebMap's Client Core
        • Angular Client
          • Introduction
          • WebMap Service
          • WebMap Interceptor Service
        • Base Components
          • Introduction
          • Components
            • Container
            • Control
            • ControlContainer
            • FormsContainer
            • Loading
            • Stub
        • Winforms Angular Components
          • Web Components
            • Base Components
              • Control Component
              • Form Container
              • Grid Component
              • Style
            • KendoUI Components
              • AdoDataControl
              • Button
              • C1TrueDBGrid
              • CheckBox
              • CheckedListBox
              • ComboBox
              • ContextMenuStrip
              • DataGridView
              • DataGridViewFlex
              • DateTimePicker
              • FileDialog
              • GroupBox
              • Label
              • ListBox
              • ListView
              • MaskedTextBox
              • MessageBox
              • NumericUpDown
              • Panel
              • PictureBox
              • PrintDialog
              • ProgressBar
              • RadioButton
              • RichTextBox
              • StatusStrip
              • Stup
              • TabControl
              • TabPage
              • TextBox
              • Timer
              • ToolStrip
              • TreeView
              • WebBrowser
              • Window
            • JQuery Web Components
          • WebMap FrontEnd Architecture
          • Migrated Structure
          • Setup
            • Front-End setup and compilation
            • Components Manual
            • Browser Support
            • Unit Test Manual
            • Development Process
            • Setup AOT/JIT Compilation
          • Decorators
            • Server Event
          • Conventions
            • Application Structure and NgModules
            • Coding
            • Components
            • Data Service
            • Directives
            • Lifecycle hooks
            • Names
            • Services
        • PowerBuilder Kendo Components
          • Base Components
            • base-component
            • column-control
            • controlcontainer
          • Data Manager Componets
            • base-data-manager
            • data-manager-control
            • data-manager-control-base
            • dw-checkbox
            • dw-column
            • dw-complexNumericMaskComponent
            • dw-compute
            • dw-date-time-edit-mask
            • dw-dropdowndatawindow
            • dw-edit
            • dw-edit-mask
            • dw-radio-button
            • dw-simple-numeric-edit-mask
            • dw-string-edit-mask
            • dw-time-edit-mask
          • Window Components
            • basemask
            • graphics
            • w-checkbox
            • w-command-button
            • w-complex-numeric-mask
            • w-date-time-edit-mask
            • w-dropdownlistbox
            • w-group-box
            • w-line
            • w-listbox
            • w-maskedtextbox
            • w-mdiclient
            • w-menu
            • w-multiline
            • w-picture
            • w-picture
            • w-radiobutton
            • w-rectangle
            • w-simple-numeric-edit-mask
            • w-single-line-edit
            • w-statictext
            • w-string-edit-mask
            • w-time-edit-mask
            • w-toolbar
            • w-toolbaritem
            • w-user-object
            • w-window
          • Services
            • DmInteractionService
          • DataManagerEvents
          • FocusManager guide
      • Api Documentation
        • WebMap Silverlight
        • WfNetC1Components
        • WebFormsComponents
      • Guides
        • Setup NPM package registry in the workspace
        • How to Setup WebMap Applications To Run Over SubDomains or WebApplications In IIS
        • Deploy several WebMap Apps in the same Server
        • Update to Angular 16
        • Appearance
          • How to change the CSS
          • How to override the style for a component
        • Component maintenance
          • How link WebMap package to the migrated Application
          • How to resolve broken reference problems with VBUC
          • How to test a local WebMap Components package
          • How to add a new component in a migrated application
          • How to update a component
          • Dynamic Control Support
          • How to add new set of component with a different provider
          • How to test your component in the playground
          • Tools
        • WMLogger
          • How to use the WMLogger's instance
          • How to change log's level
          • How to add log tags
        • Integration test
        • Setup WebMap Applications to Run Front-End And Back-End In Separates Sites
          • Setup WebMap Applications To Run Front-End And Back-End In Separates Sites in Production (IIS)
        • Setup Migrated WebMap Applications To Run Front-end & Back-end In Separates Sites (Only development)
        • Initial Set Up
          • Software to Install
          • Necessary Repositories
      • Errors
      • Version Notes
        • Client Core
        • Angular Client
        • Web Base Components
        • Winforms Angular Components
        • PowerBuilder Kendo Components
      • Licenses
        • Client Core
        • Angular Client
        • Base Components
        • PB Kendo Components
        • WFNet Kendo Components
        • WebForms Components
        • WFNet Access Components
        • WFNet Janus Components
        • WFNet C1 Components
        • Silverlight wms-framework
        • Silverlight i-components
    • BackEnd
      • WebMAP From Scratch
      • Setup
      • DCP: Desktop Compatibly Platform
        • Overview
        • Library Bundles
          • Bundle Library
            • Create an Observable Object
          • Bundle DTO
            • DTO: Data Transfer Objects
              • Creating a DTO
            • Mappers
              • Create Mappers
            • Observable Wrappers
              • Create an Observable Wrapper
            • API/Controllers
      • Architecture
      • Weaving on WebMAP
      • Glossary
      • FAQ
        • How to create a new Control
        • How to create a new Screen
        • What is the Mobilize.WebMAP.CoreServices.All?
        • What is the DesignerAttribute?
        • What is the InterceptedAttribute?
        • What is the Mobilize.Extensions.Logging.RollingFile?
        • What is the ObservableAttribute?
        • What is the Mobilize.Weaving.WebMAPExtensions.All?
      • Licenses
        • PBNet DCP
        • WebFormsDCP
        • WFNet DCP
        • CoreServices
        • CoreServicesCommon
    • Request and Response
  • SCALABILITY
    • Introduction
    • Microservices
    • Containerizing a WebMap .Net Application with Docker
    • Vertical scalability
Powered by GitBook
On this page

Was this helpful?

  1. WinForms
  2. Extend or Modify the Converted Application

Adding Non-WebMap Angular Forms

PreviousStub FilterNextAdding FrontEnd Handler to a ToolStripMenuItem

Last updated 2 years ago

Was this helpful?

The following section will guide you through this case scenario, in which you would need to add a non-WebMap Angular form to an existing migrated Angular project. This means that the developer can add new forms that don't use the WebMap model paradigm and launch them from the existing WebMap migrated app.

The initial assumption is that the developer already has access to a migrated WebMap Angular project, and the developer already implemented on the project a FrontEnd click handler in a menu item (just like the one described in the existing on this site).

The first step is to create an Angular component named NoWebMapFormsContainerComponent. This component will be in charge of handling the open and close of the new forms that don't use the WebMap mechanism.

/***********************************************************************
 * Copyright (C) Mobilize.Net <info@mobilize.net> - All Rights Reserved
 *
 * This file is part of the Mobilize Frameworks, which is
 * proprietary and confidential.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Mobilize.Net Corporation.
 * The intellectual and technical concepts contained herein are
 * proprietary to Mobilize.Net Corporation and may be covered
 * by U.S. Patents, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Mobilize.Net Corporation.
 *
 * This file is subject to the terms and conditions defined in
 * file 'LICENSE.txt', which is part of this source code package.
 ***********************************************************************/
 import {
  ChangeDetectorRef,
  Component,
  ComponentFactoryResolver,
  ComponentRef,
  OnDestroy,
  OnInit,
  ViewChild,
} from '@angular/core';
import { WebMapService, WMConstants } from '@mobilize/angularclient';
import { WMLogger } from '@mobilize/logging';
import { ContainerDirective } from '@mobilize/base-components';
import { TypeResolver } from '@mobilize/base-components';
import { ErrorCodes, ExceptionHandlerClass } from '@mobilize/webmap-core';

@Component({
  selector: 'wm-nowebmapformscontainer',
  styleUrls: ['./no-web-map-forms-container.component.css'],
  templateUrl: './no-web-map-forms-container.component.html'
})
@ExceptionHandlerClass(ErrorCodes.BaseComponents)
export class NoWebMapFormsContainerComponent implements OnInit, OnDestroy {
  constructor(
    private changeDetector: ChangeDetectorRef,
    private componentFactoryResolver: ComponentFactoryResolver,
    private webmapService: WebMapService
  ) {}

  @ViewChild(ContainerDirective, { static: true })
  componentContainer: ContainerDirective;

  private openedComponents = {};

  private events = [];

  /* istanbul ignore next */
  ngOnInit(): void {
    this.events.push(
      this.webmapService.core.getEvent().subscribe('showForm', (url) => {
        this.navigateToForm(url);
      })
    );
    this.events.push(
      this.webmapService.core.getEvent().subscribe('closeForm', (url) => {
        this.disposeComponent(url);
      })
    );
  }

  /**
   * Load a new component inside the formsContainerComponent
   * @param url the url object of the component.
   */
  /* istanbul ignore next */
  navigateToForm(id: any): void {
      const componentType = TypeResolver.getType(id);
      /* istanbul ignore else */
      if (!componentType) {
        WMLogger.instance()
          .error(`There is not a type registered with the name ${id} in the TypeResolver.
        Please check that the name is well written or the dataTransfer is the same in the backend`);
        return;
      }
      this.loadComponent(componentType, id);
  }

  /**
   * Creates a new component instance inside the formscontainer component
   * @param componentToLoad The new component to load
   * @param name The name of the component.
   */
  /* istanbul ignore next */
  loadComponent(componentToLoad: any, id: any): ComponentRef<any> {
    const componentFactory =
      this.componentFactoryResolver.resolveComponentFactory(componentToLoad);
    const viewContainerRef = this.componentContainer.viewContainerRef;
    const componentRef = viewContainerRef.createComponent(
      componentFactory
    ) as ComponentRef<any>;
    if (componentRef.instance.afterLoadComponent) {
      componentRef.instance.afterLoadComponent();
    }
    this.openedComponents[id] = componentRef;
    return componentRef;
  }

  /**
   *  Removes a component inside the formsContainerComponent
   * @param url the url object of the component.
   */
  /* istanbul ignore next */
  disposeComponent(id: any): void {
    if (id && this.openedComponents[id] && this.openedComponents[id].hostView) {
      const viewContainerRef = this.componentContainer.viewContainerRef;
      const vcrIndex = viewContainerRef.indexOf(
        this.openedComponents[id].hostView
      );
      try {
        viewContainerRef.remove(vcrIndex);
      } catch (e) {
        // Avoid triggering synchronization error while deleting the component.
        WMLogger.instance().debug(e);
      }
      delete this.openedComponents[id];
    } else {
      WMLogger.instance().debug(`The view ${id} to be removed was not found:
      ${
        this.openedComponents[id]
          ? 'HostView property undefined.'
          : ' The view is not present in the openedComponents collection.'
      }`);
    }
  }

  /**
   * Executes on component destroy to unsubscribe the events
   */
  ngOnDestroy(): void {
    this.events.forEach((evnt) => {
      this.webmapService.core.getEvent().unSubscribe(evnt);
    });
  }
}
<ng-template wm-content></ng-template>
/* Empty css file*/

Notice how, inside of the ngOnInit method. the showForm and closeForm events are subscribed to the WebMap service. These subscriptions are the ones that handle the open/close of the non-WebMap forms.

The second step is to create a new Angular form to add (for this example, we will call the new angular component "heroes").

To accomplish this, first create the Hero interface:

export interface Hero {
    id: number;
    name: string;
}

Then, create a file called mock-heroes.ts that contains the Heroes list constant.

import { Hero } from './hero';

export const HEROES: Hero[] = [
  { id: 12, name: 'Dr. Nice' },
  { id: 13, name: 'Bombasto' },
  { id: 14, name: 'Celeritas' },
  { id: 15, name: 'Magneta' },
  { id: 16, name: 'RubberMan' },
  { id: 17, name: 'Dynama' },
  { id: 18, name: 'Dr. IQ' },
  { id: 19, name: 'Magma' },
  { id: 20, name: 'Tornado' }
];

The following elements must be added in heroes.components.ts :

  1. Add the WebMap dataTransfer decoration. The dataTransfer defines a unique identifier for the form. This will be used later by the nowebmapformscontainercomponent to know which form should be opened or closed.

  2. Inject the WebMapService to the form. This service will be used to trigger the closeForm event from the form.

import { Component } from '@angular/core';
import { Hero } from '../../hero';
import { HEROES } from '../../mock-heroes';
import { dataTransfer} from "@mobilize/base-components";
import { WebMapService} from "@mobilize/angularclient";

@Component({
  selector: 'heroes',
  templateUrl: './heroes.component.html',
  styleUrls: ['./heroes.component.css']
})
@dataTransfer(["HeroesComponent"])
export class HeroesComponent {
  constructor(private wmservice : WebMapService) {}

  heroes = HEROES;
  selectedHero?: Hero;

  onSelect(hero: Hero): void {
    this.selectedHero = hero;
  }

  close() {
    this.wmservice.core.getEvent().publish('closeForm', 'HeroesComponent');
  }
}
<kendo-window
title="Non webmap form"
(close)="close()"
[minWidth]="250"
        [width]="450"
>
<h2>My Heroes</h2>
<ul class="heroes">
  <li *ngFor="let hero of heroes"
    [class.selected]="hero === selectedHero"
    (click)="onSelect(hero)">
    <span class="badge">{{hero.id}}</span> {{hero.name}}
  </li>
</ul>

<div *ngIf="selectedHero">

  <h2>{{selectedHero.name | uppercase}} Details</h2>
  <div><span>id: </span>{{selectedHero.id}}</div>
  <div>
    <label for="hero-name">Hero name: </label>
    <input id="hero-name" [(ngModel)]="selectedHero.name" placeholder="name">
  </div>

</div>
</kendo-window>
/* HeroesComponent's private CSS styles */
.heroes {
    margin: 0 0 2em 0;
    list-style-type: none;
    padding: 0;
    width: 15em;
  }
  .heroes li {
    cursor: pointer;
    position: relative;
    left: 0;
    background-color: #EEE;
    margin: .5em;
    padding: .3em 0;
    height: 1.6em;
    border-radius: 4px;
  }
  .heroes li:hover {
    color: #2c3a41;
    background-color: #e6e6e6;
    left: .1em;
  }
  .heroes li.selected {
    background-color: black;
    color: white;
  }
  .heroes li.selected:hover {
    background-color: #505050;
    color: white;
  }
  .heroes li.selected:active {
    background-color: black;
    color: white;
  }
  .heroes .badge {
    display: inline-block;
    font-size: small;
    color: white;
    padding: 0.8em 0.7em 0 0.7em;
    background-color:#405061;
    line-height: 1em;
    position: relative;
    left: -1px;
    top: -4px;
    height: 1.8em;
    margin-right: .8em;
    border-radius: 4px 0 0 4px;
  }
  
  input {
    padding: .5rem;
  }

Once both components are created, the third step is to include them in the app.module.ts file. Besides, the selector of the nowebmapformscontainercomponent should be added to the app.component.html.

The non-WebMap component should be added in both declarations and bootstrap sections.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA, NgZone, ChangeDetectorRef} from '@angular/core';
import { AppComponent } from './app.component';
import { BaseComponentsModule } from '@mobilize/base-components';
import { WebMapKendoModule } from '@mobilize/winforms-components';
import { WebMapService, WebMapModule } from '@mobilize/angularclient';
import { HeroesComponent } from './components/heroes/heroes.component';
import { NoWebMapFormsContainerComponent } from './components/no-web-map-forms-container/no-web-map-forms-container.component';
import { WindowModule } from "@progress/kendo-angular-dialog";
@NgModule({
  declarations: [
    AppComponent,
    HeroesComponent,
    NoWebMapFormsContainerComponent,
  ],
  imports: [
    BrowserModule,
    BaseComponentsModule,
    WebMapKendoModule,
    WebMapModule,
    WindowModule,
  ],
  providers: [WebMapService  ],
  bootstrap: [AppComponent, HeroesComponent],
  schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export class AppModule { }
<div>
    <wm-formscontainer></wm-formscontainer>
    <wm-loading></wm-loading>
    <wm-background-worker [url]="'/bgw'"></wm-background-worker>
    <wm-nowebmapformscontainer></wm-nowebmapformscontainer>
</div>

Using a FrontEnd handler just like the one described in the last post, the developer can open a Non-WebMap form in the following way:

WebMapService.currentService.core.getEvent().publish('showForm', 'HeroesComponent');

Please notice that opening the form just consists of publishing the showForm event and passing the data transfer of the form the developer wants to open.

Closing the form works in a similar way. For example, on the close method of the HeroesComponent you will find that the closeForm event is published passing the datatransfer of the HeroesComponent to close it.

To test this example, you must compile the angular project with all the changes described before and run the app. Then, you will have to click on the element with the frontend handler where the publish of the showForm event was added.

post
The Non WebMAP form opened