Checking a boolean in a getValueAt

I have a method that assigns a value to a boolean variable

 
//////////////////////////////////////////////////////////////////////////
   //                     setDestinationCheck()                            //
   //////////////////////////////////////////////////////////////////////////
   public boolean setDestinationCheck(boolean b){
      boolean dscheck = b;
       return dscheck;
   }//end setDestinationCheck

Open in new window


I am checking that boolean value in my getValueAt()

This is only part of it

   
 case PRL_COL: {
             String prlCheck = rds.get(row).rev.getRelatedComponent("IMAN_master_form_rev").getStringProperty("PRL");
             boolean res = dscheck;
             System.out.println("res = " + res + "\n");
             if (res == false) {
                o = prlCheck;
                
             }
             else {
                 if ((prlCheck == null || prlCheck.isEmpty())){
                    o = rds.get(row).valuePRL;
                 }
                 else {
                    o = prlCheck;
                 }
                 break; 
             }
             break;
            }

Open in new window


I know that the first method is changing the value of dscheck, but the value of dschcek in the 2nd method never changes.  
jkteaterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkteaterAuthor Commented:
it is also not updating the value in isCellEditable();

When the setDestinationCheck() runs and dscheck is updated and returned
shouldn't getValueAt() and isCellEditable() reflect the changed value of the variable?

 if (dscheck) {
         return false;
      }
0
for_yanCommented:
Thuis should not be declared agaian:

  boolean dscheck = b;
0
for_yanCommented:

thats how it should be:
  public void setDestinationCheck(boolean b){
      dscheck = b;
      // return dscheck;
   }//end setDestinationCheck

Open in new window

0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

for_yanCommented:
If you are setting boolean value - this boolean value should be an instance variable opf your class, not local variable in the method
0
for_yanCommented:
Then, normally your set... method would be void - it needs to set the vvalue, not to return it

Your get... method - that one would return boolean, but not the set... method
0
for_yanCommented:
this is more clearly how it should be once again:

public class ....
...
boolean dscheck;
...

  public void setDestinationCheck(boolean b){
      dscheck = b;
      // return dscheck;
   }//end setDestinationCheck

Open in new window

0
jkteaterAuthor Commented:
I put a print statement at the bottom of the method

public void setDestinationCheck(boolean b){
      boolean dscheck = b;
      System.out.println("DestCheck = " + dscheck + "\n");

Open in new window


and I put print statements in the 2 methods in question

public boolean isCellEditable(int row, int column){
      Object o = null;
      System.out.println("DSCHECK = " + dscheck + "\n");
      if (dscheck) {

Open in new window


 case PRL_COL: {
             String prlCheck = rds.get(row).rev.getRelatedComponent("IMAN_master_form_rev").getStringProperty("PRL");
             boolean res = dscheck;
             System.out.println("res = " + res + "\n");

Open in new window


the out put looks like

DestCheck = true
DSCHECK = false
res = false

should be

DestCheck = true
DSCHECK = true
res = true

The bottom 2 never change from false



0
for_yanCommented:
Please, explain, what is the point of this:

public void setDestinationCheck(boolean b){
      boolean dscheck = b;
     

Open in new window


if you want to set boolean vlaue, this value should be instance variable,
not local vraible of the method
You should not declare it again, remove "boolean"

...
public void setDestinationCheck(boolean b){
       dscheck = b;
...





0
for_yanCommented:
If you declare it again - it will change local value dscheck inside the mnethod
It is not affecting the values of dscheck in another method, because inside the
setDestinationCheck nmethod
with second declaraion you effective hide your instance variabnle dscheck and it dioes not change.
remove second declataion like this::


 public void setDestinationCheck(boolean b){
      dscheck = b;
         }//end setDestinationCheck
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.