The page "Country list" of the ASAMPLE site illustrates the data access concept proposed by XTEND.
In our example, the page is formed of:
If the XTEND site was created from a copy of the ASAMPLE site, the setup records are already present.
Otherwise it is possible to either create them or to copy them one by one from the ASAMPLE site via the X3 action button 'Copy'.
The three interfaces ACOUNTRY, ALANGUAGES, ACURRENCIES are used to access respectively tables TABCOUNTRY, TABLAN, TABCUR are of type 'Data access'.
The creation procedures are identical.
Only the table names and the list of selected fields are different.
1. Create the interface record
2. Select the table
3. Save
4. Generate access after having entered the fields used
5. Save and Validate
6. Generate the fields via menu Tools\Field token creation
Type
Table access
Table code
TABCOUNTRY, TABLAN, TABCUR
Publication name
TABCOUNTRY, TABLAN, TABCURRENCY by default but can be modified
Messages display
All
Protected access
no
Generate access
Select the fields and generate the Web service by clicking on OK
The button 'Generate access' triggers following operations:
Entities ACOUNTRY, ALANG, ACURRENCY are created in the same way as interfaces.
Only the interface name and the list of fields are different.
1. Create the entity of type 'Data access' based on the interface .
The entity is used to store data from table queries
2. Associate fields
with the help of menu Tool\Entry help
3. Enter the entity key field in grid 'Fields (selection)'.
4. Save and Validate
In order to display the flag it is necessary to create a field token COUNTRYFLAG to type "Picture access" and to set it up so that it generates an access url to the .gif file containing the flag picture.
The field COUNTRYFLAG will be inserted in a tag <img>.
The token setup consists in:
Here the flag files are stored in a FLAGS file of the HTML directory and are named CODEPAYS.gif
Validate the field after creation.
The COUNTRYFLAG field does not belong to the interface and must be calculated upon entity creation.
It is sufficient to add the COUNTRYFLAG field to entity ACOUNTRY and to 'map' it with the CRY field containing the country code.
Upon mapping, the XTEND server adds a COUNTRYFLAG field to the entity and values it with the country code.
Upon display, the field is transformed in an URL in the src attribute of the img tag pointing to file CODEPAYS.gif
<img height="25" width="40"
src="/xtend/data/remote/SOLSUPV6/SUPERV/X_TEND/X_HTML/ASAMPLE/ENG/FLAGS/ATF.gif"/>
In this example, the url points directly to the file in the X3 server.
The section tokens are inserted in the HTML page. They will trigger the query to X3 and the data read and display.
1. Creation of a section
2. Add selection and sort criteria
3. Save and Validate
For this example a "Multi-record" section ABLKCOUNTRIES was created pointing to entity ACOUNTRY and selecting the records having at least a CRY code (CRY >=AA).
In the test base, some codes have less than two characters.
In order to authorize the sort on the country code, an ascending sort was set up on the CRY country code by default and the sort modification by dynamic link was authorized.
The dynamic link tokens ADLKCOUNTRYSORTDW and ADLKCOUNTRYSORTUP make the grid sort possible.
Sort type
Field
Modifiable sort
Yes
Sort fields
CRY
Section ABLKCOUNTRIES was defined as main section of the Web page ACOUNTRIES. It makes it possible to use the alias AMAIN rather than the section's name to access this section:
The sections ABLKLANG and ABLKCURRENCY are "Single-record' and select respectively entities ALANG and ACURRENCY depending on the language code (LAN) and the currency code (CUR) of the line selected in the main section AMAIN_ (section ABLKCOUNTRIES).
The link is made via "dynamic link" token ADLKSELECT selecting the line of a section (specific Web action ABLKSELECT ) and displays the same page again.
This action indicates to the XTEND server that the line containing the link on which the user clicked becomes the selected line.
When a section has a selected line, all the field tokens referring to the section MYBLOCK.MYFIELD take as value the value of the field of the selected line.
Here, since the language (ABLKLANG) and currency (ABLHCURRENCY) sections have as selection AMAIN.LAN et AMAIN.CUR (AMAIN is the alias of section ABLKCOUNTRIES), these sections display automatically the information on the language and the currency of the selected country.
Here for the example the result is displayed in the same page and the display is managed by a "conditioned section" token ADISPMAINSELECT displaying or hiding an HTML field depending on whether the main section MAIN has a selected line or not.
Tokens ADLKCOUNTRYSORTUP and ADLKCOUNTRYSORTDW are used to sort the country list by ascending and descending code.
Current page
Yes
Activity tracking
No because it is not necessary to trace this type of action.
Selection on the entity
ACOUNTRY: Entity to select (that of the country section)
Application selection
'Replaces the selection of the main section': The sort/selection sent by the dynamic link to the destination page (in the example it is the same page) replace the sort/selection of the main section AMAIN (section ABLKCOUNTRIES in the example)
Type of selection
None: only the section sort criteria are to be modified
Sort type
Field: Here the CRY field with ascending order (ADLKCOUNTRYSORTUP) and descending order (ADLKCOUNTRYSORTDW)
Create the page ACOUNTRIES (not protected) which has as main section the section ABLKCOUNTRIES.
Insertion of the Web page token ACOUNTRIES in the left menu to display the page.
<TD class="button"><A adx="ACOUNTRIES">Pays</A></TD>
In order to make a simple link (without action nor selection) to a Web page via an anchor tag, it is sufficient to insert a token of type "Web page" in the tag(<a adx="PageWeb"></a>) in order to limit the number of "dynamic link" tokens.
Displaying the country list consists in positioning the section ABLKCOUNTRIES which makes an iteration on the country list and thus makes it possible to create as many lines in the grid as countries in the list.
<table width="100%" border="1">
<tr class="tabTitle">
<th width="15%">
<a adx="ADLKCOUNTRYSORTUP">+</a>
<b>Code</b>
<a adx="ADLKCOUNTRYSORTDW">-</a>
</th>
<th width="20%"><b>Pays</b></th>
<th width="15%"><b>Continent</b></th>
<th width="15%"><b>Devise</b></th>
<th width="15%"><b>Langue</b></th>
<th width="20%"><b>Drapeau</b></th>
</tr>
<!adx="ABLKCOUNTRIES:xselect=false">
<tr adx="aLineStyle:xattr=Class">
<td><a adx="ADLKSELECT"><span adx="CRY"></span></a></td>
<td adx="CRYDES"></td>
<td adx="CONTINENT"></td>
<td adx="CUR"></td>
<td adx="LAN"></td>
<td><img adx="COUNTRYFLAG" height="25" width="40"></td>
</tr>
<!adx="ABLKCOUNTRIES">
</table>
Setup xselect=false of section ABLKCOUNTRIES indicates not to select the first line by default in order to hide the details provided no line is selected.
<td>
<a adx="ADLKCOUNTRYSORTUP">+</a>
<b>Code</b>
<a adx="ADLKCOUNTRYSORTDW">-</a>
</td>
<img adx="COUNTRYFLAG" height="25" width="40">
<td><a adx="ADLKSELECT"><span adx="CRY"></span></a></td>
<tr adx="aLineStyle:xattr=Class">
In order to display the lines of a grid with alternating lines, an adx token is set in the tag <tr>.
<tr adx="aLineStyle:xattr=Class">
aLineStyle contains the class name and xAttr=Class indicates that it is necessary to value the class attribute with the field aLineStyle value.
The css classes (aLineStyle) applied in the grid lines are defined in the section setup record.
The detail is displayed as soon as a line is selected by clicking on the country code.
The "conditioned link" token ADISPMAINSELECT conditions the display.
Sections ABLKCURRENCY and ABLKLANG trigger the read of country currency and language entities and make possible the detail display.
<!adx="ADISPMAINSELECT">
<table>
<!adx="ABLKCURRENCY">
<tr>
<td><b>Currency</b></td>
<td adx="CUR" width="50"></td>
<td><b>Description</b></td>
<td adx="INTDES" width="150"></td>
<td><b>Symbole</b></td>
<td adx="CURSYM" width="50"></td>
</td>
</tr>
<!adx="ABLKCURRENCY">
<!adx="ABLKLANG">
<tr>
<td><b>Language</b></td>
<td adx="LAN"></td>
<td><b>Description</b></td>
<td adx="INTDES"></td>
<td></td>
</tr>
<!adx="ABLKLANG">
</table>
<!adx="ADISPMAINSELECT">
<!adx="ABLKDOCHTML">
<div adx="TEXTE">
</div>
<!adx="ABLKDOCHTML">
In order to manage page numbering, library pagination.lbi is used, which contains a general HTML code that can be used for the main section (AMAIN) in all HTML pages.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--This library is used to perform pagination on AMAIN bloc-->
<table width="100%">
<tr>
<td align="left" width="20%">
<!--Hide FirstPage and Previous actions if current page is the first page-->
<!adx="aHideMainFirstPage">
<!---->
<a href="" adx="AMAIN.aDlkFirstPage">Première</a>
<a href="" adx="AMAIN.aDlkPrevPage">Précedente</a>
<!adx="aHideMainFirstPage">
</td>
<!--Displays page information-->
<td align="center" width="60%">
Page : <span adx="AMAIN.aPagePos"></span> -
Number of elements: <span adx="AMAIN.aBlkNbElmts"></span>
</td>
<td align="right" width="20%">
<!--Hide LastPage and Next actions if current page is the last page-->
<!adx="aHideMainLastPage">
<a href="" adx="AMAIN.aDlkNextPage">Next</a>
<a href="" adx="AMAIN.aDlkLastPage">Last</a>
<!adx="aHideMainLastPage">
</td>
</tr>
</table>
In order to call a method (or a field) for an XTEND section, the syntax mySection.myAction or mySection.myField is used.
<a href="" adx="AMAIN.aDlkFirstPage">First</a>
<a href="" adx="AMAIN.aDlkPrevPage">Previous</a>