Skip to content

Commit

Permalink
#1038 added the row id and the "single" selection option
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanrauh committed Dec 30, 2018
1 parent e8b6d4f commit 4e3aa5e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,9 @@ private void generateBody(FacesContext context, DataTable dataTable, ResponseWri
Object value = column.getAttributes().get("value");
if (value != null) {
rw.writeText(value, null);
} else if (column.getAttributes().get("selectionMode") != null) {
rw.writeText((1+row), null); // unique ID required by the checkbox plugin
}

renderChildrenOfColumn(column, context);
rw.endElement("td");
}
Expand Down Expand Up @@ -460,8 +461,11 @@ private void generateHeader(FacesContext context, DataTable dataTable, ResponseW
if ("multiple".equals(selectionMode)) {
updateColumnDefinition(dataTable, index, "'checkboxes': {'selectRow': true}");
dataTable.setSelectionMode2("{style: multi}");
} else if ("single".equals(selectionMode)) {
updateColumnDefinition(dataTable, index, "'checkboxes': {'selectRow': true}");
dataTable.setSelectionMode2("{style: single}");
} else {
throw new FacesException("<b:dataTable> only supports the selection mode 'multiple'");
throw new FacesException("<b:dataTable> only supports the selection mode 'multiple' and 'single'");
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,15 @@ public void setSearchable(boolean _searchable) {
}

/**
* Add a checkbox column to select rows. <P>
* Add a checkbox column to select rows. Legal values are 'single' and 'multi'. <P>
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getSelectionMode() {
return (String) getStateHelper().eval(PropertyKeys.selectionMode);
}

/**
* Add a checkbox column to select rows. <P>
* Add a checkbox column to select rows. Legal values are 'single' and 'multi'. <P>
* Usually this method is called internally by the JSF engine.
*/
public void setSelectionMode(String _selectionMode) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/meta/META-INF/bootsfaces-b.taglib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7334,13 +7334,13 @@
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[Add a checkbox column to select rows.]]></description>
<description><![CDATA[Add a checkbox column to select rows. Legal values are 'single' and 'multi'.]]></description>
<name>selection-mode</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Add a checkbox column to select rows.]]></description>
<description><![CDATA[Add a checkbox column to select rows. Legal values are 'single' and 'multi'.]]></description>
<name>selectionMode</name>
<required>false</required>
<type>java.lang.String</type>
Expand Down
2 changes: 1 addition & 1 deletion xtext/BootsFaces.jsfdsl
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ widget dataTableColumn {
header-style "Inline style of the header cell."
header-style-class "Style class of this header cell."
search-value "Initial content of the search filter field."
selection-mode "Add a checkbox column to select rows."
selection-mode "Add a checkbox column to select rows. Legal values are 'single' and 'multi'."
orderable Boolean default "true" "Disables or enables the sort button for this column."
searchable Boolean default "true" "If set to false, this column is excluded from the multi-column-search feature of b:dataTable. Defaults to true. Note that this feature is active only if both searching='true' and multi-column-search='true' are set on the datatable."
value inherited "EL expression referring to the back-end bean attribute providing the value of the field."
Expand Down

0 comments on commit 4e3aa5e

Please sign in to comment.