Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: 1.3
-
Component/s: Paging/Sorting
-
Labels:None
Description
DisplayTag provides the ability to override the output of the anchors used for pagination, but not sorting. I need this to be able to use the DisplayTag.
Here is the code to implement it:
Add the following to TableProperties.java:
/**
* property <code>sort.th.link</code>.
*/
public static final String PROPERTY_STRING_SORT_TH_LINK = "sort.th.link"; //$NON-NLS-1$
/**
* Getter for the <code>PROPERTY_STRING_SORT_TH_LINK</code> property.
* @return String
*/
public String getSortThLink()
{
return getProperty(PROPERTY_STRING_SORT_TH_LINK);
}
Add the following to TableTag.properties:
sort.th.link=<a href="{0}">{1}</a>
In TableTag.java, in the writeTableHeader method, replaced this code:
// creates the link for sorting
Anchor anchor = new Anchor(getSortingHref(headerCell), header);
// append to buffer
header = anchor.toString();
with:
// create Object[] including the HREF for the sort and the header text
Object[] objects = {getSortingHref(headerCell).toString(), header};
// get sort th link
String sortedLinkFormat = this.properties.getSortThLink();
// merge the final result
header = MessageFormat.format(sortedLinkFormat, objects);
The docs would need to change to reflect the additional configuration parameter.
Name: sort.th.link
Default: <a href="{0}">{1}</a>
Description: Link to get you back to this page. Displayed in the column th for sorting. {0}: Page Url; {1}: Column Title
Here is the code to implement it:
Add the following to TableProperties.java:
/**
* property <code>sort.th.link</code>.
*/
public static final String PROPERTY_STRING_SORT_TH_LINK = "sort.th.link"; //$NON-NLS-1$
/**
* Getter for the <code>PROPERTY_STRING_SORT_TH_LINK</code> property.
* @return String
*/
public String getSortThLink()
{
return getProperty(PROPERTY_STRING_SORT_TH_LINK);
}
Add the following to TableTag.properties:
sort.th.link=<a href="{0}">{1}</a>
In TableTag.java, in the writeTableHeader method, replaced this code:
// creates the link for sorting
Anchor anchor = new Anchor(getSortingHref(headerCell), header);
// append to buffer
header = anchor.toString();
with:
// create Object[] including the HREF for the sort and the header text
Object[] objects = {getSortingHref(headerCell).toString(), header};
// get sort th link
String sortedLinkFormat = this.properties.getSortThLink();
// merge the final result
header = MessageFormat.format(sortedLinkFormat, objects);
The docs would need to change to reflect the additional configuration parameter.
Name: sort.th.link
Default: <a href="{0}">{1}</a>
Description: Link to get you back to this page. Displayed in the column th for sorting. {0}: Page Url; {1}: Column Title
Activity
fabrizio giustina
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | After 1.1 [ 12190 ] |
fabrizio giustina
made changes -
| Fix Version/s | TBD [ 12190 ] | |
| Fix Version/s | 1.1.1 [ 12450 ] |
fabrizio giustina
made changes -
| Fix Version/s | 1.1.1 [ 12450 ] | |
| Fix Version/s | 1.1.2 [ 13662 ] |
fabrizio giustina
made changes -
| Fix Version/s | 1.3 [ 13663 ] | |
| Fix Version/s | 1.2 [ 13662 ] |
fabrizio giustina
made changes -
| Fix Version/s | 1.0 RC1 [ 11220 ] | |
| Fix Version/s | 1.3 [ 13663 ] |
fabrizio giustina
made changes -
| Fix Version/s | 1.2.1 [ 16873 ] | |
| Fix Version/s | 1.0 RC1 [ 11220 ] |
Use the existing property in the property file
css.th.sortable={class name from css file for use with anchor in header}
Change the existing code in writeTableHeader():
// column is sortable, create link
if (headerCell.getSortable())
{
// creates the link for sorting
Anchor anchor = new Anchor(getSortingHref(headerCell), header);
// append to buffer
header = anchor.toString();
}
to:
// column is sortable, create link
if (headerCell.getSortable())
{
// creates the link for sorting
Anchor anchor = new Anchor(getSortingHref(headerCell), header);
// when a header cell is sortable,
// create a class attribute for the anchor
// - IE compatibility
String cssSortable = this.properties.getCssSortable();
if(cssSortable != null){
anchor.setClass(cssSortable);
}
// append to buffer
header = anchor.toString();
}