I assume you are on Struts2.
I'm not familiar with the ${} expression, but you are right, there is an
OGNL null handler that will instantiate objects for you if they are null,
so the behaviour we see makes sense, which means that you don't have a
certificate in the value stack.

How do you access your view ? Prior to getting your view, you should have
an action that gets executed in an Action class which has a certificate
field, which gets populated prior to returning to the view.

Antonios


On 27 June 2013 11:33, Fabian Richter <frich...@mtg.de> wrote:

> I have an update: I enabled the ${certificate.status} in the else branch
> again and checked the tomcat logs:
>
> getStatus called: 0
> getStatus called: 0
> getStatus called: 0
> getStatus called: 0
> getStatus called: 1
>
> That would mean that for each if/elseif he doesnt actually call getStatus
> on the actual certificate, but on a fake (?) one he created on the fly? I
> think I remember reading something in the Webworks book, that if there is
> no object he creates it on the fly and then all field are uninitialized
> which is a 0 for int?
>
> Or is that nonsense? And if it might be true, why does he correctly read
> the object via
>
> ${certificate.status}
>
> but not in the test="..." ?
>
>
> Am 27.06.2013 12:26, schrieb Antonios Gkogkakis:
>
>  if it's called then there is something wrong with the comparison, are you
>> sure that you don't have a String getStatus somewhere?
>> What I would do is instead of checking the == 1 in the jsp create a method
>> on the certificate boolean isValid() { return status==1} and so on.
>>
>> I know it doesn't answer your original question but it solves the problem
>> and it's more maintenable IMHO.
>>
>> Antonios
>>
>>
>> On 27 June 2013 10:34, Fabian Richter <frich...@mtg.de> wrote:
>>
>>  Am 27.06.2013 11:20, schrieb Antonios Gkogkakis:
>>>
>>>   I would temporarily remove  ${certificate.status} from the else and I
>>>
>>>> would
>>>> check if the getStatus is called for the conditionals
>>>>
>>>>
>>> Yes, it is called.
>>>
>>> I was hoping it wasn't :( What now?
>>>
>>>
>>>
>>
> --
> media transfer AG
>
> Fabian Richter, M.Sc.
> Softwareentwickler
>
> Mail:    frich...@mtg.de
> Telefon: +49 6151 8193-24
> Telefax: +49 6151 8193-41
> Web:     http://www.mtg.de
>
> Firmensitz: Dolivostraße 11, 64293 Darmstadt
> Registergericht: Amtsgericht Darmstadt, HRB 8901
> Vorstand: Jürgen Ruf (Vors.), Tamer Kemeröz
> Aufsichtsratsvorsitzender: Dr. Thomas Milde
>
>

Reply via email to