Re: String variable with a number s:if test

Greg Huber <[email protected]>
Newsgroups gmane.comp.jakarta.struts.devel
Message-ID <[email protected]>
Ah, ok not to use .equals().

....Think here the type started of as "type1" "type2".. "typeA" "typeB" 
etc and got refactored to 1,2...A,B etc so had an impact.

###

May be it would be faster also to use ==  rather than .equals()?

I do alot of !bean.imageSource.equals('')

Thanks!

On 25/05/2023 08:17, Lukasz Lenart wrote:
> czw., 25 maj 2023 o 09:12 Greg Huber <[email protected]> napisał(a):
>>>> <s:if test='bean.type.equals("2")'>
>> Thanks, need to try and remembered this! Would explain why some of my item types don't select/work as expected.
> I would use "==" to be sure, as documented in
> https://ognl.orphan.software/language-guide#operators
>
> "e1 == e2"; e1 eq e2 - Equality test
>
> Equality is tested for as follows. If either value is null, they are
> equal if and only if both are null. If they are the same object or the
> equals() method says they are equal, they are equal. If they are both
> Numbers, they are equal if their values as double-precision floating
> point numbers are equal. Otherwise, they are not equal. These rules
> make numbers compare equal more readily than they would normally, if
> just using the equals method.
>
> So the final version is:
>
> <s:if test='bean.type == "2"'>
>
>
> Regards
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.