title

FreeMarker widgets for displaying data

The following macros are working very closely with the Struts actions of the Tiny Marbles Framework. The main purpose it to show data in form of lists with rows, columns, filter and pagination. For that reason each action or class which uses these widgets (in the related FreeMarker template) has to import the class org.cws.webcore.FilterHibernate and provide a public method getFilter().  

@data.table

Shows a table with the given collection of elements. In combination with the macros below like @data.column and @data.pagination it is a powerful macro and used in the admin pages of Tiny Marbles CMS to show data objects in form of tables (=list with rows and columns).

Parameters of @data.table:

label (required)
text for the table title. elements (required)
a collection of elements to be shown in the table. showHeader (optional boolean, default 'true')
if true the header of the table is shown with a title given in the label. dataResultCssClass (optional, default empty)
adds a CSS class to the element <div> which frames the table. id (optional, default 'dataTable')
id of the table. cssTableClass (optional, default empty)
adds a CSS class to the table. cssEmptyClass (optional, default empty)
adds a CSS class for an empty table. rowIdAttribute (optional, default 'id')
fetches the id for the row of the table from property 'id' of the collection. If the
property has another name you can specify this name here.
rowCssClass (optional, default empty)
adds a CSS class to the row. onMouseOver (optional, default empty)
JavaScript, used for the event onmouseover of a table row. onMouseOut (optional, default empty)
JavaScript, used for the event onmouseout of a table row. headerAsLink=false (optional boolean, default 'false')
adds a link to the header of the table. headerLink (optional, default '#')
value of the link for the header of the table. headerOnClick (optional, default empty)
JavaScript for the header on click. headerClass (optional, default 'header')
adds a CSS class to the header. url (optional, default empty)
url for links and pagination. Pagination is created automatically in case url is not
empty. Is passed to the macros @data.column and @data.pagination which are used
internally.
param (optional, default empty)
parameter for the url for links and pagination. Is passed to the macros @data.column
and @data.pagination which are used internally.
jsFunction (optional, default empty)
JavaScript, is passed to the macros @data.column and @data.pagination which are used
internally.
onPageNumberClick (optional, default empty)
JavaScript, is passed to the macro @data.pagination which is used internally. onClick (optional, default empty)
JavaScript, is passed to the macros @data.column and @data.pagination which are used
internally.
paginationLinkFirst (optional, default '<img src='${base}/webcore-static/images
/first.png' alt='first'/>')
link for pagination, link: 'first page'. paginationLinkPrevious (optional, default '<img src='${base}/webcore-static/images
/previous.png' alt='previous'/>')
link for pagination, link: 'previous page'. paginationLinkNext (optional, default '<img src='${base}/webcore-static/images/next.png'
alt='next'/>')
link for pagination, link: 'next page'. paginationLinkLast (optional, default '<img src='${base}/webcore-static/images/last.png'
alt='last'/>')
link for pagination, link: 'last page'. paginationShowItemsFound (optional boolean, default 'true')
if true the total number of elements are shown in pagination. paginationBeforePageNumber (optional, default empty)
decoration before page number of pagination. Could be virtually any character,
usually '|' or '['.
paginationAfterPageNumber (optional, default empty)
decoration after page number of pagination. Could be virtually any character,
usually '|' or '['.

Example for @data.table:

<@data.table id="users" elements=filter.result.elements 
   label="user.list" url="/list.action"; user>
   <@data.column label="Login" sortBy=["login:asc"]>${user.login}</@data.column>
   <@data.column label="Name" sortBy=["name:asc"]>${user.name}</@data.column>
</@data.table>

Screenshot (example) for @data.table:

user_list.png

 

@data.column

Provides a column for the data table. Must be used as child of @data.table to build the dynamic table.

Parameters of @data.column:

label (required)
text to show for the title of the column. cssClass (optional, default empty)
a CSS class name for the row (<td> element). sortBy (optional, default empty)
name of the property of the object. Used for the sorter in the table header. Example:
["loginname:asc"].
fixedSortBy (optional, default empty)
name of the property of the object. Used for the second sort value for sorter in the
table header. Example: ["id:asc"].
id (optional, default empty)
id for the row (<td> element). onClick (optional, default empty)
JavaScript for the link element of the row, event on click. tdOnClick (optional, default empty)
JavaScript for the row (<td> element) itself, event on click. style (optional, default empty)
a CSS style for the row (<td> element).

Example for @data.column:

<@data.column label=action.getText("label.Zone.name") sortBy=["name:asc"]>
   <@show.link target="${base}/admin/zone/view.action?zone.id=${zone.id?c}"
      label="${zone.name?html}"/>
</@data.column>

 

@data.deleteColumn

This is a specialization of the @data.column. Provides a column with an image for the delete action. It has a multi-selection feature, that enables the user to select one or more items of the list to delete at the same time (using shift/control). Calls internally the @data.column macro. An overlay box appears to confirm the delete action, the delete action uses an Ajax call.

Parameters of @data.deleteColumn:

url (required)
url of the delete action (Struts) to delete the selected elements. paramId (required)
the name of the parameter id to be deleted, examples: 'versionId' or 'zoneId'. params (optional, default empty)
optional parameter for the url. cssClass (optional, default empty)
a CSS style to be passed to the macro @data.column. showDeleteButton (optional boolean, default 'true')
if set to true the macro shows the default delete button. If false, a nested code can
be used to show a customized delete button.
deleteAllowed (optional boolean, default 'true')
adds a CSS style to the delete button if delete is not allowed. obj (optional, default empty)
the object to be deleted. Internally used to get the id of the object to be deleted. onExecute (optional, default 'delete_elements')
JavaScript callback function name for when delete is executed. onUnCheck (optional, default 'unCheckDelete')
JavaScript callback function name for when a element is unchecked. onCheck (optional, default 'checkDelete')
JavaScript callback function name for when a element is checked. width (optional, default '500')
width of the confirmation overlay box. height (optional, default '120')
height of the confirmation overlay box.

Example for @data.deleteColumn:

<@data.deleteColumn obj=user showDeleteButton=false 
   url="${base}/admin/user/delete-form.action"
   paramId="users" width="524" height="188"
   params="active=${active}"; objId>
      <#if user?exists && (user.systemId?if_exists != defaultUserSystemId)
         && (user != currentUser) && deleteUser && user.active>
       <@data.deleteButton deleteAllowed=true objId=objId />
      </#if>
</@data.deleteColumn>

Screenshot (example) for @data.deleteColumn:

company_delete.png

 

@data.pagination

Shows the navigation for the pagination feature at the bottom of a data table. Usually used in combination with the macro @data.table, but it can also be used independantly, for example to add pagination to an article list or blog list of the public website.

Parameters of @data.pagination:

url (required)
url the links of pagination. labelItens (optional, default 'label.pagination.itensFound')
text for items found. max (optional, default empty)
optional parameter for the url. param (optional, default empty)
optional parameter for the url. anchor (optional, default empty)
optional anchor to be added at the link of the pagination. jsFunction (optional, default empty)
calls a JavaScript function in the link instead of an url. cssClass (optional, default empty)
adds a CSS class to the element <div> which frames the pagination. linkFirst (optional, default '<img src='${base}/webcore-static/images/first.png'
alt='first'/>')
link for pagination, link: 'first page'. linkPrevious (optional, default '<img src='${base}/webcore-static/images/previous.png'
alt='previous'/>')
link for pagination, link: 'previous page'. linkNext (optional, default '<img src='${base}/webcore-static/images/next.png'
alt='next'/>')
link for pagination, link: 'next page'. linkLast (optional, default '<img src='${base}/webcore-static/images/last.png'
alt='last'/>')
link for pagination, link: 'last page'. showItemsFound (optional boolean, default 'true')
if true the total number of elements are shown in pagination. beforePageNumber (optional, default empty)
decoration before page number of pagination. Could be virtually any character,
usually '|' or '['.
afterPageNumber (optional, default empty)
decoration after page number of pagination. Could be virtually any character,
usually '|' or '['.
onPageNumberClick (optional, default empty)
JavaScript executed when page number is clicked. showInactiveLinks (optional boolean, default 'false')
if true also inactive links of the pagination are shown. showAllPages (optional boolean, default 'false')
if true, all pages of the pagination are shown.

Example for @data.pagination:

<#local params = 
   "${params}&amp;channel=${(channel.systemId)!}&amp;request_locale=${locale?string}" />
<#assign hasPagination =
   elements?size gt 0 && (filter.result.hasNext() || filter.result.hasPrevious()) />
<#if hasPagination>
   <#if filter.sortOptions?exists>
      <#assign params =
         "${params}&amp;filter.sd=${filter.sd?lower_case}${data.createSortOptions()}" />
   </#if>
   <@data.pagination url=url param=params labelItens="pagination.News.view"
      linkFirst="" linkLast=""
      linkPrevious="<span class='back'>${action.getText('label.back')}</span>"
      linkNext="<span class='forward'>${action.getText('label.next')}</span>"
      showItemsFound=false cssClass="navPag"/>
</#if>

Screenshot (example) for @data.pagination:

pagination.png


Oasis Faith Based Rehab Center . comment pirater un compte facebook