Home > Default > Question on SinglePageCrudTable sample project

Question on SinglePageCrudTable sample project

November 30Hits:0
Advertisement
A part of Page1.java in SinglePageCrudTable sample project follows:
public String deleteButton_action() {
// TODO: Process the button click action. Return value is a navigation
// case name where null will return to the same page.
Iterator rowKeys = selectedTrips.iterator();
while (rowKeys.hasNext()) {        
RowKey rowKey = (RowKey) rowKeys.next();
try {
tripDataProvider.removeRow(rowKey);
} catch (Exception e) {
error("Cannot delete trip with row key " + rowKey);
// do outside loop because commitChanges() invalidates rowkeys
try {
tripDataProvider.commitChanges();
} catch (Exception ex) {
error("Cannot commit deletions.");
form1.discardSubmittedValues("saveChanges");
return null;
/* The set of RowKeys for rows that have been selected.
* This set is manipulated by calls to setSelectedTrip(),
* which will occur when the checkbox of each row is decoded.*/
Set selectedTrips = new HashSet();
//Return true if the trip for the current row is selected
public boolean isSelectedTrip() {
TableRowDataProvider trdp = (TableRowDataProvider) getBean("currentRow");
if (trdp == null) {
return false;
RowKey rowKey = trdp.getTableRow();
return selectedTrips.contains(rowKey);
/* Record whether or not the current trip should be marked as selected,
* based on the state of the checkbox.*/
public void setSelectedTrip(boolean b) {
TableRowDataProvider trdp = (TableRowDataProvider) getBean("currentRow");
RowKey rowKey = trdp.getTableRow();
if (selectedCheckBox.isChecked()) {
selectedTrips.add(rowKey);
} else {
selectedTrips.remove(rowKey);
Q1: The property selectedTrips is a boolian, but how it is defined as a Set?
Q2: The method isSelectedTrip() is never used, then why it is defined there?
Thanks

Answers

Q1: The property selectedTrips is a boolian,
but how it is defined as a Set?
Q2: The method isSelectedTrip() is never used,
then why it is defined there?I'm not an expert, but here is my understanding:
1: Set, as the name indicates, is a set of values, so you are able to store a collection of boolians. This is useful since you could store multiple elements. ie. selecting several rows of data. Also, you will be able to iterate through them, as you can see here:
Iterator rowKeys = selectedTrips.iterator();
while (rowKeys.hasNext()) {
RowKey rowKey = (RowKey) rowKeys.next();
try {
tripDataProvider.removeRow(rowKey);
} catch (Exception e) {
error("Cannot delete trip with row key " + rowKey);
}2. for isSelectedTrip(), it is just a getter method, or an Accessor method. It's good practice to write it, plus, it could be the only way for you to retrieve that "isSelected" information if you are outside of that java class.
That's just my understanding, maybe other experts can shine some insights.

Read other 2 answers

Tags:

Related Articles

  • Question on SinglePageCrudTable sample projectNovember 30

    A part of Page1.java in SinglePageCrudTable sample project follows: public String deleteButton_action() { // TODO: Process the button click action. Return value is a navigation // case name where null will return to the same page. Iterator rowKeys =

  • X-CAN sample project problemNovember 30

    Hey guys, I´m getting started with the myRIO-1900 and try to connect it with my car via X-CAN module with OBD-II BD9 cable to collect and record data from my car. I've installed Labview 2014, X-CAN, realtime module in my computer without any problem.

  • X-can sample projectNovember 30

    Hey guys, I´m getting started with the myRIO-1900 and try to connect it with my car via X-CAN module with OBD-II BD9 cable to collect and record data from my car. I've installed Labview 2014, X-CAN, realtime module in my computer without any problem.

  • How can we share knowledge such as sample projects and OPA standards?November 30

    Is there a place for the community to share things? For instance, we have been working on OPA standards, etc. It might be nice for other people to be able to comment on or reuse what we have created. We also have example projects we are creating to p

  • Sample Project FilesNovember 30

    Is there a place which I can find sample project files? I've been trying to study on blank project file and I need to some sample files to apply extensive techniques.I am going to assume your question relates to Microsoft Project, since you posted in

  • Error in compiling Photoshop CC 2014 sample projectOctober 11

    Hi, I am trying to compile SDK sample project "outbound". but it is showing errors, as "Parse Issue: Unknown type name 'DialogPtr' " in DialogUtilities.h . DialogUtilities.h file is in "Adobe Photoshop CC 2014:photoshopsdk:plugins

  • Error in compiling sample project of Indesign CC 2014October 11

    Hi, I am trying to compile sample project of Indesign CC 2014 using VC++ 2013. but it is showing me following error: "error C2039: 'assert_not_arg' : is not a member of 'boost::mpl' (..\..\..\source\sdksamples\basicmenu\BscMnuSuiteLayoutCSB.cpp)    D

  • Error in compiling sample project of photoshop CC 2014October 11

    Hi, I am trying to compile sample project "Outbound" of Photoshop CC 2014, but it is showing me error, "Parse Issue: Unknown type name 'DialogPtr' " in DialogUtilities.h file . DialogUtilities.h is part of "samplecode:common:inclu

  • Sample Project with ni hardware using NI-DAQmx DriverOctober 11

    hi, i need a Sample Project with NIi hardware using NI-DAQmx DriverPlease stick to one thread. You've created several that are asking the same thing and the answer remains the same - Help> Find Examples if using LabVIEW. Other programming languages c

  • Using Apple's sample project at your own gain, legal or not legal?October 11

    I found a sweet sample project in my Xcode developer folder called "Sketch". I would like to use it's code and redesign, redevelop, and totally flip it around to were I just used it as a template towards my own project. Is that legal to do? Cons

Copyright (C) 2019 wisumpire.com, All Rights Reserved. webmaster#wisumpire.com 15 q. 0.800 s.