Before creating your site, it is recommended to read the following documentation:Before starting.
The block token reads and displays the Entity which is assigned to it by setup:
1. It reads the entity or entities in the X3 database by calling up an interface (Web service) of type 'Access to data',
2. It performs an iteration on the entities returned to dynamically create the lines of a grid.
The block token is inserted in the HTML page with the following syntax:
<table>
<!adx="MyBlock">
<tr>
<td adx="aBLKELMTRANK"></td>
<td adx="ITEMREF"></td>
</tr>
<!adx="MyBlock">
</table>
The XTEND engine processes blocks as follows:
This stage is performed once when the HTML page is loaded:
This stage is carried out each time the HTML page is displayed:
1. Block initialization
2. Iteration on all returned entities
In previous example, if the selection displays 3 products of code PUZ001, PUZ002 and PUZ003, a 3-line grid will be obtained:
1 | PUZ001 | |
2 | PUZ002 | |
3 | PUZ003 |
The generated HTML is as follows:
The HTML 'child' of the block token was repeated 3 times and was recalculated each time with respect to the new data context (current line).
<table>
<tr>
<td>1</td>
<td>PUZ001</td>
</tr>
<tr>
<td>2</td>
<td>PUZ002</td>
</tr>
<tr>
<td>3</td>
<td>PUZ003</td>
</tr>
</table>
The block token not only displays data grids, it also manages the dynamic modification of selection and sort criteria.
The block setups set the default criteria and it is possible to authorize or deny the modification of these criteria by a dynamic link.
The dynamic link token can modify the block criteria and it is also possible to define selection and sort setups for this token.
Only the selection and sort criteria or the page main block (alias AMAIN) can be modified by the dynamic link criteria.
It is possible to define several blocks by page, but only one of them (the main block) has selection and sort criteria that can be modified by the user.
There are three types of modification via dynamic link for the block criteria:
These three options make it possible to handle most situations occurring in Web pages.
The block token record is used to set up the block selection and sort criteria.
These are the default criteria applied at first display of the page containing the block.
The block token proposes two parameters 'Modifiable selection' and 'Modif. sorting' indicating if the selection criteria and/or sort criteria can be modified by a dynamic link.
These parameters are only applied if the block was defined as main block in the record of the Web page displaying it.
In order to display a block with several cells by line, the specific token ASTAMP is used to delineate the cell.
The XTEND server repeats the HTML code present between the two ASTAMP tags as many times as cells in the line.
<table>
<!-Iteration on the block lines-->
<!adx="MYBLOCK">
<tr>
<!-Code repeated as many times as cells by lines'-->
<!adx="ASTAMP">
<!--Used to alternate the color of cells-->
<td adx="ALINESTYLE:xattr=Class">
<!--Code HTML d'une cellule-->
<b>Name</b><p adx="NAME"></p>
<b>First name</b><p adx="FIRSTNAME"></p>
</td>
<!adx="ASTAMP">
</tr>
<!adx="MYBLOCK">
</table>
The example below shows how to fill empty cells when the number of recordings is not a multiple of the number of cells by line.
The conditioned blockADISPSTAMPEMPTY is used to define the HTML dedicated to the empty cells.
<table>
<!-Iteration on the block lines-->
<!adx="MYBLOCK">
<tr>
<!adx="ASTAMP">
<td adx="ALINESTYLE:xattr=Class">
<!adx="ADISPSTAMPEMPTY">
<!--Empty cell with a blank-->
<!adx="ADISPSTAMPEMPTY">
<!adx="ADISPSTAMPEMPTY:xnot">
<!--Code HTML d'une cellule-->
<b>Name</b><p adx="NAME"></p>
<b>First name</b><p adx="FIRSTNAME"></p>
<!adx="ADISPSTAMPEMPTY">
</td>
<!adx="ASTAMP">
</tr>
<!adx="MYBLOCK">
</table>
The actions ABLKFIRSTPAGE, ABLKNEXTPAGE, ABLKPREVPAGE, ABLKLASTPAGE are used to manage the page numbering in the blocks.
The tokens ADLKFIRSTPAGE, ADLKNEXTPAGE, ADLKPREVPAGE, ADLKLASTPAGE can be used on the page main block.
The fields aBLKNBELMTS and APAGEPOS display the total number of recordings and the position of the page compared to the total page number.
The conditioned blocks AHIDEMAINFIRSTPAGE and AHIDEMAINLASTPAGE manage the display/hide status of page numbering buttons for the first and last pages.
Syntax
MonBloc.ADLK*
For instance:
Page numbering with display management at start and end of page numbering.
<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">First</a>
<a href="" adx="AMAIN.aDlkPrevPage">Previous</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>
The dynamic links ADLKSELECT and ADLKUNSELECT (action ABLKSELECT and ABLKUNSELECT) are used to select/deselect a block line.
Use
Insert the tokens ADLKSELECT and ADLKUNSELECT in one of the line cells either in a tag <a> or in a tag <input type='button'>.
The field ABLKSELECTEDLINE contains the rank (1 to N) of the selected line.
For instance:
The block ABLKCOUNTRIES displays the countries in the site ASAMPLE with selection of the line to display the detail Currency/Country language.
A click on the first cell (CRY) selects the line.
<!adx="ABLKCOUNTRIES:xselect=false">
<tr>
<td><a adx="ADLKSELECT"><span adx="CRY"></span></a></td>
<td adx="CRYDES"></td>
<td adx="CUR"></td>
<td adx="LAN"></td>
</tr>
<!adx="ABLKCOUNTRIES">
<!--Displaying of the line number selected-->
<span adx='ABLKCOUNTRIES.ABLKSELECTEDLINE'></span>
The HTML parameter 'xSelect=true' is used to select the first line by default.
If this parameter is not used, or if its value is 'false', the block has no selected line by default.
When a block has a selected line, it is possible to access the fields of this line via the syntax MyBlock.MyField.
The values of the fields of the selected line can be displayed or used as criteria in a block, dynamic link, or conditioned block.
The conditioned block AHIDEMAINSELECT displays/hides an HTML zone taking into account whether the main block has a selected line or not (see country page of site ASAMPLE).
The action ABLKRESTOREMAINCTX is used to get back to a list page from a detail page without loosing the page numbering or the selected line of the main block.
The dynamic link below is used to get back to the page FORMQUERYRES and restore the main block context.
<input type="button" value="Return list" adx="DlkFrmQueryBack" class="xtendButton" >
Following syntax is used to access directly the data of a block line:
<!--First line-->
<span adx="MYBLOCK(first).MYFIELD"></span>]<br>
<!--Last line-->
<span adx="MYBLOCK(last).MYFIELD"></span>]<br>
<!--Nth line-->
<span adx="MYBLOCK(N).MYFIELD"></span>]<br>
The following syntax is used to value a JavaScript variable with the JSON representation of a block or block line:
<script>
// JSON data of a block
var wMyBlock_JSON=<!adx="MYBLOCK(*)"><!adx="MYBLOCK(*)">;
var wMyBlock_JSON=<!adx="MYBLOCK(*)"><!adx="MYBLOCK(*):xinclude=FIELD1,FIELD2">;
var wMyBlock_JSON=<!adx="MYBLOCK(*)"><!adx="MYBLOCK(*):xexclude=FIELD1,FIELD2">;
// JSON data of a line
var wMyLine_JSON=<!adx="MYBLOCK(2)"><!adx="MYBLOCK(2)">;
var wMyLine_JSON=<!adx="MYBLOCK(2):xinclude=FIELD1,FIELD2"><!adx="MYBLOCK(2)">;
var wMyLine_JSON=<!adx="MYBLOCK(2):xexclude=FIELD1,FIELD2"><!adx="MYBLOCK(2)">;
</script>
The JSON variable of a block is composed of an array of lines:
<script>
var wMyBlock = [{line 1},{line 2},...];
var wMyBlock = [{"STATUT":1,"STATUT_DESCR":"To process","PRIX":81.35,"COD2":"30-112"},
{"STATUT":2,"STATUT_DESCR":"Processed","PRIX":117.9,"COD2":"31-02"},
{"STATUT":1,"STATUT_DESCR":"To process","PRIX":606.15,"COD2":"32-034"}];
</script>
The JSON variable of a line is an object containing fields:
<script>
var wMyLine ={"CHAMP1":"Value1","CHAMP2":"Value2"...};
var wMyLine = {"STATUT":1,"STATUT_DESCR":"To process","PRIX":606.15,"COD2":"32-034"}
</script>
For a field, the xjson^parameter generates a JSON object {"FieldName:"Value"}. Without xjson parameter, the JavaScript variable is valued with the field value.
<script>
// JSON data of a field
var wMyField_JSON=<!adx="MYFIELD:xjson"><!adx="MYFIELD">;
//XTEND generates
var wMyField_JSON={"MYFIELD":"Value"};
// Value of a field
var wMyField_JSON=<!adx="MYFIELD"><!adx="MYFIELD">;
//XTEND generates
var wMyField_JSON="Value";
</script>
Code | Parameter | Effect |
xselect | True/False | Selects the first line by default |
Code | Type | Description |
ABLKELMTIDX | Integer | Index of an element in a block (O->ABLKNBELMTS-1) |
ABLKELMTRANK | Integer | Rank of an element in a block (O->ABLKNBELMTS-1) |
ABLKLINEIDX | Integer | Index of line in a block (O->ABLKNBELMTS-1) |
ABLKLINERANK | Integer | Rank of line in a block (O->ABLKNBLINES) |
ABLKNBELMTS | Integer | Total number of elements (recordings) of a block request |
ABLKNBLINES | Integer | Rank of the selected line of a block via action ABLKSELECT |
ABLKSELECTEDLINE | Integer | Number of lines in a block |
APAGENB | Integer | Number of pages in a block |
APAGENUM | Integer | Rank of a block current page |
APAGEPOS | Integer | APAGEPOS/APAGENUM |
Code | Description |
ACONST | Contains all fields of type constant |
ACURRENT | Current data context (top) in XDEND stack of data |
AHTMLFORM | HTML form |
AHTTPCOOKIE | HTTP cookies |
AMAIN | Main block of a page defined in the page parameters |
APBG | Background block of a page defined in the page parameters |
AMESS | User messages |
AREFERENCE | In the expression MonBlocReference.MonTokenLien, the block MonBlocReference corresponds to 'reference block' ; |
ASESSION | Contains the user session data |
AUSERCRIT | Contains the user criteria (HTML parameter xcrit) |
AUSERINF | Contains the user data provided by the login |
AUSERVAR | Contains the user variables created by the functions JavaSCript xtdSetUserVar/xtdRemoveUserVar |
Fields
The following fields are present on this tab :
| Block token code. |
| Current Web site |
|   |
Close
Presentation
General parameters of the block.
Close
Fields
The following fields are present on this tab :
Characteristics
|
|
|
|
| Specifies the entities that will be created from the request result. |
| 'Data access' type interface that will be called. |
| 'Data access' type interface that will be called. |
Close
Presentation
Parameters of the selection associated with the block.
Close
Fields
The following fields are present on this tab :
Characteristics
| None: all the records are selected. Query: the selection criteria of the section are applied. Last link clicked: are applied the selection criteria of the dynamic link which has been clicked to access the page containing the section. |
| No: the SQL query associated with the section cannot be modified using the query of a dynamic link. Yes: the query cannot be modified using the query associated with a dynamic link. The query of the section is the default query. |
| Selection of the optimization submitted by the interface. None: No optimization No image file: the interface does not return the 'image file' type field No text file: the interface does not return the 'text file' type field Neither image file nor text file: the interface does not return the 'image file' and 'text file' type fields |
Selection synthesis
| Query of the section in text format |
Grid Selection criteria
| Logical operation sequencing operator. |
| Opening brackets. |
| Field of the entity whose value is the first operand of the operation. |
| Comparison operator |
|
|
| The parameter value is entered here. Depending on the case, this value is entered as if it were a number, a date or an alphanumeric code. When the parameter is of local menu type, it is possible to enter either the beginning of the name or the numeric value corresponding to the position of the name in the list. When the code is controlled by an annex table, a selection key may be used to select it. |
| Block code for the 'Field token' origin. |
| Name of the block for the 'Field token' origin. |
| Field code for the 'Field token' origin. |
| Closing brackets. |
|
|
|   |
Entity
| Specifies the entities that will be created from the result of the query. |
| 'Data access" type interface which will be called. |
| 'Data access" type interface which will be called. |
Close
Fields
The following fields are present on this tab :
Characteristics
| Select a sort type:
|
|
|
Grid Sort
| Name of the field for the 'Field token' origin. |
| Ascending/descending sort order. |
Close
Fields
The following fields are included in this window :
Date returned by block
| Specifies what must be displayed in the block location in the HTML page if the selection is empty:
No data context is set. |
Grid Style per line
|
Grid Param sub-routine access
| Code of the sub-program setup. |
|
|
|
|
| Block code for the 'Field token' origin. |
| Block entity for the 'Field token' origin. |
| Field code for the 'Field token' origin. |
Close
By default, the following reports are associated with this function :
PRTSCR : Screen print
This can be changed using a different setup.
This button is used to copy a block token. |