How to Omit HTML for Parts of a Component Embedded in an .a5w page
Individual portions of a component are emitted separately when embedded in an A5W page. You can omit portions of the component -- such as the Page Title for a UX Component or the Detail View for a Grid Component.
When a component is embedded in an A5W page, content is emitted in both the head and body portions of the page for the component. While it is generally unnecessary to modify the embed code for a component, there are situations where you may want to delete the generated code to prevent a section of the component from being rendered.
A common use case for modifying the generated code is to prevent a UX Component from overwriting the page title for a page.
You can also omit portions of a Grid Component if they're unused, though this is optional and leaving in the code to emit the Search Part or Detail View of a Grid Component will not cause any layout issues.
The code below is the generated code for embedding a Grid component called "nw_customers" in an A5W page. The generated code for the Grid Component is placed in two sections in the HTML output: the head and body.
Additional output code may be generated for other component types. For example, the UX Component will add the title tag for the page in the head section. You may want to prevent the UX from setting the title for the A5W page. This is accomplished by commenting out the line ending with Output.Head.Title. For example:
' commented out: don't let UX override page title ' ?x_someUXComponentNameHere.Output.Head.Title
The BODY portion contains Xbasic to render the Search Part, main Grid, and Detail View. The last line in the code below is necessary if the Grid Component uses web sockets. If your application does not have a Search Part or doesn't use web sockets, you can comment out or delete these lines from the A5W page.
<%A5 ?x_NW_CUSTOMERS.Output.Body.Search_HTML %> <%A5 ?x_NW_CUSTOMERS.Output.Body.Grid_HTML %> <%A5 ?x_NW_CUSTOMERS.Output.Body.DetailView_HTML %> <%a5 ?a5dialogHelper_generateCORSHeaders() %>
For example, web sockets are not used in the nw_customers Grid. Therefore, it's not necessary to emit the CORS Headers when the component is embedded. To prevent the CORS Headers from being added, we can modify the generated code as follows:
<%A5 ?x_NW_CUSTOMERS.Output.Body.Search_HTML %> <%A5 ?x_NW_CUSTOMERS.Output.Body.Grid_HTML %> <%A5 ?x_NW_CUSTOMERS.Output.Body.DetailView_HTML %> <%a5 ' Web Sockets are not needed; skip this next step '?a5dialogHelper_generateCORSHeaders() %>
In general, it is not necessary to modify the code created by Alpha Anywhere to embed components in A5W pages. In fact, modifying the code created by Alpha can lead to unexpected issues down the road if components are modified to include the features that are omitted in the A5W page. For example, if you delete the Xbasic that embeds a part of the Grid, such as the Detail View, the Grid Component will not work as expected if you add the Detail View at a later date.