Avatar of Nika Gudge
Nika Gudge
Flag for United States of America asked on

How do i set a boolean transient variable

im using a transient variable as below:
private transient boolean vaultallowedccterm=false;

im setting it in my java code as below:
if(terminalDto.isCCTerminal()){
                terminalDto.vaultallowedccterm(true);  <<<<---- is this right way to set a transient boolean variable?????
    }

im using it my JSP code to test a condition as below :
<c:if test="${terminal.vaultallowedccterm=='true'}"></c:if>
JavaJSPJavaScript

Avatar of undefined
Last Comment
CEHJ

8/22/2022 - Mon
CEHJ

terminalDto.vaultallowedccterm(true);  <<<<---- is this right way to set a transient boolean variable?????

Open in new window


No. It would be

terminalDto.vaultallowedccterm = true;

Open in new window

rrz

Without seeing the code of terminalDto,  we have to guess.  Maybe use
terminalDto.setVaultallowedccterm(true);
CEHJ

My code will of course only work where the private scope is not a problem. Otherwise, it should have a normal mutator (which should be used) and accessor
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Nika Gudge

ASKER
TerminalDTO is just a data transfer object. I has variables declared and respective getters and setters for it.
public class TerminalDTO{
private transient boolean vaultallowedccterm = false;

//how to declare the getter setter for the above property ????
}

im not able how to figure out how to get the value of it in EL?
${terminal.vaultallowedccterm == 'true'}
CEHJ

how to declare the getter setter for the above property ????

Same as any other bean property


    public boolean getVaultallowedccterm() {
        return this.vaultallowedccterm;
    }

    public void setVaultallowedccterm(boolean vaultallowedccterm) {
        this.vaultallowedccterm = vaultallowedccterm;
    }

Open in new window


but you'd do better to ensure that your variable names are in camel case (beginning lower case)
rrz

>im not able how to figure out how to get the value of it in EL?
>${terminal.vaultallowedccterm == 'true'}
Please try using  
<c:if test="${terminal.vaultallowedccterm}">
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
gordon_vt02

The variable can be accessed the same as any other variable you declare and is restricted by normal scoping rules.  Hence, a private variable is only accessible internally to the class that declares it while a public one (BAD idea) is accessible to anyone.  The 'transient' keyword indicates to Java that the variable should not be serialized when using Java's built-in Serialization mechanisms.
ASKER CERTIFIED SOLUTION
rrz

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
CEHJ

<<<<---- is this right way to set a transient boolean variable?????

Not sure how the accepted answer applies to that question ..?