Inside Dynamics AX 4.0: The Web Framework
The EP Web framework is the design-time and run-time Web infrastructure of MorphX. This includes the kernel, X++ classes, designer and debugging tools, data binding, security trimming, metadata store, and the mechanism for linking all of these components together. In combination with the EP Web Parts and Windows SharePoint Services, they constitute the Web user interface to Dynamics AX.
Weblets are the basic unit of the Dynamics AX Web elements that generate HTML. Web forms, Web reports, and Web menus are some of the specialized Weblets in Dynamics AX included for rapid Web development. Web forms allow you to quickly build a Web user interface by using pre-built Dynamics AX Web controls; these controls are then tied to the Dynamics AX data source and the event model to define the business logic. Reports and Web reports have a finer-grained designer surface (with grid-snapping, pixel-positioning, and so on) for defining the layout and binding to a data source, and they include built-in tools for generating summary reports and graphs. Web menus allow you to build and render the navigation hierarchy or site map. Dynamics AX comes with many other specialized, ready-to-use Weblets that can be used in the EP, such as the Category Browser Weblet, Favorite Record Weblet, and Questionnaire Weblet.
Developers can use these pre-built Weblets or build their own by using MorphX. Data retrieval, business logic, and presentation as defined in Web forms, reports, Web reports, or custom-built Weblets. The navigation and menu hierarchy are defined in Web menu items and Web menus. Web menu items are secured in the AOT by applying the security key.
In below picture shows all the Web nodes in the AOT.
The Web nodes in the AOT
Web forms derive from Weblets and are generally the Web elements used for creating, editing, viewing, and listing business data from Dynamics AX in the EP. Essentially, you can consider a Web form to be a Web element that returns a stream of HTML about transactional data that can be rendered and displayed in a Web browser. One or more application tables can be set as the data source for Web forms. Dynamics AX includes several default Web form controls that can be used in Web forms. Programmed entirely in HTML, the Web form controls are like very thin wrappers of the standard HTML controls. Dynamics AX includes the following Web form controls: WebButton, WebCheckBox, WebComboBox, WebDate, WebEdit, WebGrid, WebGroup, WebGuid, WebImage, WebInt64, WebInteger, Weblet, WebRadioButton, WebReal, WebStaticText, WebTab, WebTabPage, and WebUserDefined.
The layout for all the controls, except WebUserDefined, is pre-built. This enables developers to perform rapid application development simply by binding the controls to the data source. If the development requires more granular control in regard to how the layout generates HTML, the WebUserDefined Web control can be useful, because its layout method can be overridden.
You can place Web form controls into groups by using a WebGroups control, and you can arrange them on the page by using standard HTML. This means that you position every element relative to other page elements, and that you cannot define absolute positions for the controls.
Web form controls also offer support for data lookup to provide a way for the user to fill in fields from a pre-populated list. The Web lookup uses the relations that are added to table fields or extended data types to list the possible values for the field. The LookupButton property on a Web control specifies whether a Lookup button must be displayed next to the control. The default setting is Auto, which displays the Lookup button. The LookupMethod property specifies how the lookup should be handled for the control. The default setting displays the lookup form or list in a separate browser window.
Web Form Runtime
At run time, the EP Web framework instantiates an object of the WebFormHTML class. The WebFormHTML object reads the Web form's design and calls the appropriate layoutControls method passing the control's ID. This method then calls the control type specific methods, such as layoutText, layoutDate, or layoutButton. These methods render the Web form controls by using the appropriate HTML controls. The controlName method on the WebFormHTML class returns a name that uniquely identifies the control, whether it is data-bound or not. This identifier is used by the SetControls method, which is called when the Web form is posted. The SetControls method does the opposite of the layoutControls methodit reads the values of the Web form controls and puts them back into the form's data sources by calling the getParm method on WebSession class, passing the unique control names provided by the layout methods. In below picture shows a simplified Web form HTML generation sequence diagram.
Web form HTML generation (simplified).
Web Form Events
The EP is stateless. On every round trip to the server, pages are instantiated, processed, rendered, and disposed of. If a page needs to keep its state between server round trips, when a server-side event is processed, the ASP.NET page framework uses a hidden input control, referred to as ViewState, to store the state of the page and all the controls in that page in encoded format to persist between Web requests. A server round trip to the same page for processing a server-side event is commonly referred to as a postback. A postback occurs when a page is submitted in the browser or when the Web control on the page raises a server-side event that necessitates a postback. The EP Web framework persists the value of the Web controls in the ASP.NET ViewState during page postback. No custom coding is required to persist the Web control values between postbacks. However, information other than the values stored in ViewState must be handled separately.
The EP Web framework provides several events that allow you use X++ code to persist the values of variables and temporary tables into ViewState during postbacks in Web forms. The first such event is called the loadViewState event. You can use this event to load the in-memory variables from ViewState. The loadViewState event occurs before the init and run events are executed. After the run event lays out the controls and updates them with postback data, the framework updates the ViewState with postback data.
The second event to occur that is related to ViewState is the loaded event. By this time, the changes to the data source and Web controls have been applied, the controls on the Web page have been updated with postback data, and the ViewState of the page has been updated with postback data. This is the right place to use the in-memory variables retrieved from ViewState and subsequently update the Web controls, if necessary.
The third event related to ViewState is called saveViewState. This event can be used to save the in-memory variable into ViewState. The SaveViewState event occurs after the layout event.
In below image shows the sequence of Web form events.
The sequence of Web form events
Web Form Example
Imagine that you have been asked to create a Web page in your company's EP so that salespeople can create a sales order from anywhere on the Web. To accomplish this task, you create a Web form called EPSalesTableCreateTunnel and add data sources and Web controls. Because this Web form is designed like a wizard to make creation of sales orders more intuitive, the sales basket ID must be preserved between the pages of the wizard. To do this, a salesBasketId variable is declared in the class declaration. The value of salesBasketId is persisted into ViewState in the saveViewState event. Between page posts, the variable is loaded from ViewState in the loadViewState event. The following code illustrates this task.
In below image shows the EPSalesTableCreateTunnel Web form in the AOT, the property pane of the Web Form Web Part pointing to this Web content, and the run-time view.
The Web form in the AOT, the Web Part property, and the run-time rendering
</img> </img> </img> </img> </img>
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
|axStart: Microsoft Dynamics AX 2009 Hot Topics Web Seminar Series||Blog bot||DAX Blogs||0||06.08.2008 12:05|
|Inside Dynamics AX 4.0: The Security Framework||Blog bot||DAX Blogs||0||31.10.2007 11:40|
|Inside Dynamics AX 4.0: Usage Scenarios||Blog bot||DAX Blogs||0||04.10.2007 05:15|
|Inside Dynamics AX 4.0: Inside the Business Connector||Blog bot||DAX Blogs||0||04.10.2007 05:15|
|Inside Dynamics AX 4.0: RunBase Framework Extension Part I||Blog bot||DAX Blogs||0||30.09.2007 09:20|
|Опции темы||Поиск в этой теме|