Link to home
Start Free TrialLog in
Avatar of Nika Gudge
Nika GudgeFlag 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>
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

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

Without seeing the code of terminalDto,  we have to guess.  Maybe use
terminalDto.setVaultallowedccterm(true);
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
Avatar of 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'}
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)
>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}">
Avatar of gordon_vt02
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
Avatar of rrz
rrz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<<<<---- is this right way to set a transient boolean variable?????

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