How do i set a boolean transient variable

Newton21205
Newton21205 used Ask the Experts™
on
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>
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
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

Commented:
Without seeing the code of terminalDto,  we have to guess.  Maybe use
terminalDto.setVaultallowedccterm(true);
Top Expert 2016

Commented:
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
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
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'}
Top Expert 2016

Commented:
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)

Commented:
>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}">
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.
Commented:
The getter should be  
public boolean isVaultallowedccterm() {
        return this.vaultallowedccterm;
    }

Open in new window

Top Expert 2016

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

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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial