官术网_书友最值得收藏!

Adding services

There is no single order in which you must build your project. However, as we learned in the previous chapter, types play an important role in projects, and project types come from the server. This means there is significant benefit to importing project services early in the creation of the application, as it enables us to use those service types to create type-specific forms and variables right away.

Tip

Try to minimize type iterations. While Studio will update existing typed components when you regenerate services with updated types, this is best avoided if possible. Studio is better at creating components of a type than updating component types. In the case of databases, this means finalizing your database schema as much as possible before importing it in order to avoid re-imports due to schema evolution. If you must make type updates, you might need to clear your browser cache or reload the project to get type updates to show.

Services are imported via the Services menu of the top level menus. The Services menu items all operate with server-side aspects. We'll discuss them in detail in later chapters. For the WaveyWeb project, we'll use the HRDB sample database. Selecting Import Database brings up the New Data Model dialog. The Import Sample button on the dialog automatically imports the sample HyperSQL Database (HSQLDB), (http://www.hsqldb.org/).

Human Resources Database (HRDB) is a sample database shipped with WaveMaker that defines a simple example Human Resources (HR) schema consisting of departments, employees, and vacations. There's also a user table that is good for examples using database security.

Now that we've added the HRDB service to our project, it shows up in the Services tree (the right tab in region one). The security service is automatically added to the project, but with security disabled by default. Selecting a service in the service tree expands that service item and brings us into the appropriate viewer for that service. For Java services, this is the Java source code editor. For a database service, this means we see a listing of all table entities and HQL queries in the services tree with the selected table entity shown in the data model editor. It is also by going into a service editor that we get the delete button to remove a service from our project.

In the lower-half of the Services tab is the Components tree. This is where we can find the non-visual client-side components of a project such as variables. Inserting a variable from the Insert menu immediately adds the variable to the components tree.

Services are server-side constructs, and all project services are siblings in the single tree. Components, however, can be owned by the page or the application. This is also called scope. Setting the owner of wm.variable to application enables the variable to be seen by all pages in the application and moves the variable to the Project section of the component tree. Application-owned variables are good choices for datasets that are used across multiple pages such as the logged in username and ID or the primary record being edited in the application such as a selected customer in a customer management application. Storing these values in application-scoped variables allows any page in the application to obtain values from the variable instead of needing to make a server call.

Tip

Use application-scoped components judiciously. Unlike page-owned components, application-scoped data will be in memory for the life of the application as they cannot be garbage collected.

主站蜘蛛池模板: 靖西县| 辛集市| 麦盖提县| 福海县| 祥云县| 湖南省| 临沂市| 安图县| 林西县| 博罗县| 讷河市| 年辖:市辖区| 沙洋县| 孝义市| 南宁市| 洮南市| 阳山县| 封开县| 大新县| 浠水县| 枞阳县| 太白县| 丘北县| 景宁| 阳城县| 潞城市| 曲麻莱县| 时尚| 新郑市| 乳山市| 林甸县| 杂多县| 三门峡市| 上高县| 泽普县| 临武县| 阜新市| 洛隆县| 奈曼旗| 秭归县| 阿拉尔市|