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

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.

主站蜘蛛池模板: 揭西县| 哈尔滨市| 英超| 乌恰县| 湘乡市| 历史| 英山县| 荣昌县| 抚顺市| 隆化县| 淅川县| 康保县| 通榆县| 普宁市| 屯门区| 连南| 凉城县| 南安市| 砀山县| 喀喇沁旗| 同心县| 罗城| 上栗县| 铜川市| 富平县| 涪陵区| 上蔡县| 桃源县| 灵璧县| 迁安市| 轮台县| 自治县| 舞钢市| 合肥市| 彭水| 双桥区| 新巴尔虎右旗| 辉南县| 巴彦淖尔市| 绥棱县| 泸州市|