Creator Tip: Adding a button panel to the table component header
Sun Java Studio Creator Table component has more capabilities than being exposed by the Table Layout dialog. One of the features is the ability to add a button panel to the header or the footer of the table component. This tip shows how to achieve this simple task. I have created a sample project, which extends the Multi row selectable Table Component tip project and adds button panels to the header and footer of the table component. User can select one or more rows from the table and then click the delete button in the header or footer to delete the rows. This sample project can be downloaded from here.
Also, I have included Java Script to the Table Component to pop up a confirmation dialog asking if the rows should be deleted. Also the dialog would warn that the action can not be undone. Also the Java Script would dynamically enable or disable the buttons based on the selection of the rows.
Steps:
<!-- Actions (Top) --><f:facet name="actionsTop">
<ui:button action="#{Page1.button1_action}"
binding="#{Page1.button1}" disabled="true" id="button1"
onClick="if (confirmDeleteSelectedRows() == false) return false"
text="Delete"/>
</f:facet>
<!-- Actions (Bottom) -->
<f:facet name="actionsBottom">
<ui:button action="#{Page1.button2_action}"
binding="#{Page1.button2}" disabled="true" id="button2"
onClick="if (confirmDeleteSelectedRows() == false) return false"
text="Delete"/>
</f:facet>
function confirmDeleteSelectedRows() {
var table = document.getElementById("form1:table1");
return table.confirmDeleteSelectedRows();
}
function disableActions() {
// Disable table actions by default.
var table = document.getElementById("form1:table1");
var selections = table.getAllSelectedRowsCount();
var disabled = (selections > 0) ? false : true;
// Set disabled state for top actions.
document.getElementById("form1:table1:button1").setDisabled(disabled);
// Set disabled state for bottom actions.
document.getElementById("form1:table1:button2").setDisabled(disabled);
}
public String button1_action() {
int selectedRows = getTableRowGroup1().getSelectedRowsCount();
RowKey[] selectedRowKeys = getTableRowGroup1().getSelectedRowKeys();
for(int i=0; i< selectedRowKeys.length; i++){
if (tripDataProvider.canRemoveRow(selectedRowKeys[i])){
tripDataProvider.removeRow(selectedRowKeys[i]);
info("Row " + selectedRowKeys[i].getRowId() + " Removed");
}else{
info("Can not remove row " + selectedRowKeys[i].getRowId());
}
}
tripDataProvider.commitChanges();
if(selectedRowKeys.length < 1){
info("No rows selected for deletion");
}
return null;
}
That is it. We are done. Deploy the application. Initially the buttons will be disabled. Select a row and the buttons will be enabled. Click on the button and the confirmation dialog (shown below) should popup.
Posted at 09:18PM Sep 10, 2006 | Permanent link to this entry
Posted by mickgiu on September 11, 2006 at 01:33 AM PDT #
Posted by Winston Prakash on September 11, 2006 at 06:26 AM PDT #
Posted by Lars on September 11, 2006 at 05:07 PM PDT #
Posted by 213.71.0.193 on September 12, 2006 at 08:59 AM PDT #
Posted by Walid on September 14, 2006 at 08:22 AM PDT #
Posted by tata on September 16, 2006 at 03:52 PM PDT #
Posted by cavaliernino on September 25, 2006 at 09:01 PM PDT #
Posted by suganthan on October 05, 2006 at 03:39 AM PDT #
Posted by red on October 17, 2006 at 02:47 PM PDT #
Posted by Giuspy on November 08, 2006 at 07:13 AM PST #
Posted by 59.163.73.83 on January 04, 2007 at 01:04 AM PST #
Posted by Erich on January 31, 2007 at 08:38 PM PST #
Qweas Software Search Engine
offers services including software search, downloads, store, directory, and so on.
Posted by freda on March 06, 2007 at 09:51 PM PST #
Posted by Ehab Tarek Fouad on May 01, 2007 at 06:32 AM PDT #
Posted by Valeria on May 24, 2007 at 02:32 AM PDT #
Posted by altairbob on May 24, 2007 at 06:55 AM PDT #
Posted by youngDev on May 31, 2007 at 12:47 PM PDT #
Posted by altairbob on June 01, 2007 at 02:40 AM PDT #
Posted by freda on June 05, 2007 at 08:01 PM PDT #
Posted by David wei on July 20, 2007 at 01:18 AM PDT #
Posted by Leonid Sidorenko on August 03, 2007 at 08:03 AM PDT #
http://www.batteryfast.co.uk/sony/pcg-gr250.htm sony pcg-gr250 battery,
http://www.batteryfast.co.uk/sony/pcg-gr270.htm sony pcg-gr270 battery,
http://www.batteryfast.co.uk/toshiba/pa2457ur.htm toshiba pa2457ur battery,
Posted by laptop batteries on October 23, 2008 at 11:45 PM PDT #
If you want to know how to use laptop battery well, You can see it from
<a href=http://www.adapterlist.com/sony/pcg-gr270.htm>sony pcg-gr270 battery</a>,it's very useful .
Posted by laptop battery on February 17, 2009 at 10:42 PM PST #
I think, we should use these button end of the pages. Also thanks your helps..
Posted by tekstil aksesuar on July 28, 2009 at 03:21 PM PDT #