You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Gunnar Eketrapp <gu...@gmail.com> on 2011/09/03 09:08:01 UTC
May Tapestry go wrong ...
Hi !
I have been happily hacking web sites with T5 for a year and half now and is
more then pleased!
Kudos to all of you for this excellent web framework that makes coding fun
again.
And I have never ever encountered any defect in the T5 code.
Now to my problem.
I just got an error in an onActivate method that looked like it could not
happen.
When steeping through it in my debugger I really get puzzled.
A variable assigned inside a block is null after leaving the block.
It must have something to do with the "plastering" of my code. Or !?
The error I get is ..
Caused by: java.lang.NullPointerException
at
utskicket.pages.economy.EditYear._$advised$onActivate_13(EditYear.java:91)
... and in the debugger I can see that ledger is null at line 91.
In the code below I have commented what happens in the debugger.
Can anyone understand what could cause this error ...
I have stepped through the generated code without seeing anything strange.
It all looks great but when returning ledger is null.
Do I break any rule / convention with my code !?
Many many thanks in advance,
Gunnar Eketrapp, Stockholm, Sweden
Environment:
*jdk 1.6.0_22*
*t5.2.6*
*windows 7 proffesional, 32-bit*
@Property
private Ledger ledger;
@Property
private String notice;
//
------------------------------------------------------------------------------
// -- Tapestry event methods - Tapestry event methods - Tapestry event
methods --
//
------------------------------------------------------------------------------
@Log
Object onActivate(long groupId, long ledgerId) {
group = groupDAO.findById(groupId);
if (group == null)
return Index.class;
if (ledgerId != 0) {
ledger = ledgerDAO.findById(ledgerId);
if (ledger == null)
return Index.class;
if (!same(group.getId(), ledger.getGroup().getId()))
return Index.class;
hasPrevious = (null != ledgerDAO.findPrevious(ledger));
hasNext = (null != ledgerDAO.findNext(ledger));
transactionCount = transactionDAO.countTransactions(ledger);
} else {
ledger = new Ledger(); * // 1: This one returns null !!!*
Ledger lastLedger = ledgerDAO.findLast(group);
if (null == lastLedger) {
UTDate today = new UTDate();
ledger.setStartDate(new UTDate(today.getYear(), 1, 1)); *//
2: This line ends the block!*
ledger.setEndDate(new UTDate(today.getYear(), 12, 31));
} else {
ledger.setStartDate(lastLedger.getStartDate().warpYears(1));
ledger.setEndDate(lastLedger.getEndDate().warpYears(1));
}
}
* if (ledger.getClosed()) // 3: And here we crash!*
notice = "Året är stängt och kan inte ändras";
else {
if (!mayEdit())
notice = "Endast det senaste året kan ändras.";
else if (!mayEditStarts())
notice = "Startdagen kan inte ändras då det finns tidigare
år.";
}
return null;
}
Re: May Tapestry go wrong ...
Posted by Chris Mylonas <ch...@opencsta.org>.
Cool, glad you found your error
I found it funny watching you do what I do as a first reaction - blame tapestry :)
I'm still a tapestry noob after one and a half years of part-time deving on my own projects :)
Can't wait for the tapestry 5 in action book to help me in my part-time ways .
Have a good weekend,
Chris
On 03/09/2011, at 6:04 PM, Gunnar Eketrapp wrote:
> Tapestry may not go wrong!
>
> It must has to do with autoboxing in method isClosed() in Ledger.
>
> I was fooled by the debugger and that ledger was shown as null but when
> adding log statements I can see that it isn't.
>
> So I have to read a little bit about aoutoboxing but for sure it was NOT a
> T5 problem!
>
> The call ledger.isClosed() raises a nul pointer but ledgers is not null!
>
> Sorry for disturbing all of you.
>
>
> 2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
>
>> BUT it is also a T5 property so that could be T5 related.
>>
>> The instance seems to created but the T5 property ledger is null after the
>> assignment.
>>
>>
>> 2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
>>
>>> Hum .. sorry .. too early in the morning for me .. Ledger is a hibernate
>>> entity class and T5 should not be involved.
>>>
>>> I'll be right back ...
>>>
>>>
>>> 2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
>>>
>>>> Hi !
>>>>
>>>> I have been happily hacking web sites with T5 for a year and half now and
>>>> is more then pleased!
>>>> Kudos to all of you for this excellent web framework that makes coding
>>>> fun again.
>>>>
>>>> And I have never ever encountered any defect in the T5 code.
>>>>
>>>> Now to my problem.
>>>>
>>>> I just got an error in an onActivate method that looked like it could not
>>>> happen.
>>>>
>>>> When steeping through it in my debugger I really get puzzled.
>>>>
>>>> A variable assigned inside a block is null after leaving the block.
>>>>
>>>> It must have something to do with the "plastering" of my code. Or !?
>>>>
>>>> The error I get is ..
>>>>
>>>> Caused by: java.lang.NullPointerException
>>>> at
>>>> utskicket.pages.economy.EditYear._$advised$onActivate_13(EditYear.java:91)
>>>>
>>>> ... and in the debugger I can see that ledger is null at line 91.
>>>>
>>>> In the code below I have commented what happens in the debugger.
>>>>
>>>> Can anyone understand what could cause this error ...
>>>> I have stepped through the generated code without seeing anything
>>>> strange. It all looks great but when returning ledger is null.
>>>>
>>>> Do I break any rule / convention with my code !?
>>>>
>>>> Many many thanks in advance,
>>>> Gunnar Eketrapp, Stockholm, Sweden
>>>>
>>>> Environment:
>>>> *jdk 1.6.0_22*
>>>> *t5.2.6*
>>>> *windows 7 proffesional, 32-bit*
>>>>
>>>>
>>>> @Property
>>>> private Ledger ledger;
>>>>
>>>> @Property
>>>> private String notice;
>>>>
>>>> //
>>>> ------------------------------------------------------------------------------
>>>> // -- Tapestry event methods - Tapestry event methods - Tapestry
>>>> event methods --
>>>> //
>>>> ------------------------------------------------------------------------------
>>>>
>>>> @Log
>>>> Object onActivate(long groupId, long ledgerId) {
>>>>
>>>> group = groupDAO.findById(groupId);
>>>> if (group == null)
>>>> return Index.class;
>>>>
>>>> if (ledgerId != 0) {
>>>> ledger = ledgerDAO.findById(ledgerId);
>>>> if (ledger == null)
>>>> return Index.class;
>>>> if (!same(group.getId(), ledger.getGroup().getId()))
>>>> return Index.class;
>>>>
>>>> hasPrevious = (null != ledgerDAO.findPrevious(ledger));
>>>> hasNext = (null != ledgerDAO.findNext(ledger));
>>>> transactionCount = transactionDAO.countTransactions(ledger);
>>>>
>>>> } else {
>>>> ledger = new Ledger(); * // 1: This one returns null !!!*
>>>> Ledger lastLedger = ledgerDAO.findLast(group);
>>>> if (null == lastLedger) {
>>>> UTDate today = new UTDate();
>>>> ledger.setStartDate(new UTDate(today.getYear(), 1, 1));
>>>> *// 2: This line ends the block!*
>>>> ledger.setEndDate(new UTDate(today.getYear(), 12, 31));
>>>> } else {
>>>>
>>>> ledger.setStartDate(lastLedger.getStartDate().warpYears(1));
>>>> ledger.setEndDate(lastLedger.getEndDate().warpYears(1));
>>>> }
>>>> }
>>>>
>>>> * if (ledger.getClosed()) // 3: And here we crash!*
>>>> notice = "Året är stängt och kan inte ändras";
>>>> else {
>>>> if (!mayEdit())
>>>> notice = "Endast det senaste året kan ändras.";
>>>> else if (!mayEditStarts())
>>>> notice = "Startdagen kan inte ändras då det finns
>>>> tidigare år.";
>>>> }
>>>>
>>>> return null;
>>>> }
>>>>
>>>>
>>>
>>>
>>> --
>>> [Hem: 08-715 59 57, Mobil: 070-991 86 42]
>>> Allévägen 2A, 132 42 Saltsjö-Boo
>>>
>>
>>
>>
>> --
>> [Hem: 08-715 59 57, Mobil: 070-991 86 42]
>> Allévägen 2A, 132 42 Saltsjö-Boo
>>
>
>
>
> --
> [Hem: 08-715 59 57, Mobil: 070-991 86 42]
> Allévägen 2A, 132 42 Saltsjö-Boo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: May Tapestry go wrong ...
Posted by Steve Eynon <st...@alienfactory.co.uk>.
If you wanted to keep the "closed" variable, I often use something like:
return Boolean.TRUE.equals(closed);
which returns false should closed by null;
On 3 September 2011 16:30, Gunnar Eketrapp <gu...@gmail.com> wrote:
> Yea for sure that was exactly the problem.
>
> I changed closed to a closedDate and isClosed to
>
> @Transient
> public boolean isClosed() {
> return closedDate != null;
> }
>
> so now I also now when the ledger was closed.
>
> Thank you for "bearing with me" ...
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: May Tapestry go wrong ...
Posted by Gunnar Eketrapp <gu...@gmail.com>.
Yea for sure that was exactly the problem.
I changed closed to a closedDate and isClosed to
@Transient
public boolean isClosed() {
return closedDate != null;
}
so now I also now when the ledger was closed.
Thank you for "bearing with me" ...
2011/9/3 Steve Eynon <st...@googlemail.com>
> Yeah, autoboxing is evil - it's just a compiler convenience thing. If you
> have:
>
> Boolean closed = null;
>
> boolean isClosed() {
> return closed;
> }
>
> The compiler transforms it to
>
> boolean isClosed() {
> return closed.booleanValue();
> }
>
> which of course throws an NPE.
>
> Steve.
> --
> Steve Eynon
>
>
> On 3 September 2011 16:04, Gunnar Eketrapp <gu...@gmail.com>
> wrote:
> > Tapestry may not go wrong!
> >
> > It must has to do with autoboxing in method isClosed() in Ledger.
> >
> > I was fooled by the debugger and that ledger was shown as null but when
> > adding log statements I can see that it isn't.
> >
> > So I have to read a little bit about aoutoboxing but for sure it was NOT
> a
> > T5 problem!
> >
> > The call ledger.isClosed() raises a nul pointer but ledgers is not null!
> >
> > Sorry for disturbing all of you.
> >
> >
> > 2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
> >
> >> BUT it is also a T5 property so that could be T5 related.
> >>
> >> The instance seems to created but the T5 property ledger is null after
> the
> >> assignment.
> >>
> >>
> >> 2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
> >>
> >>> Hum .. sorry .. too early in the morning for me .. Ledger is a
> hibernate
> >>> entity class and T5 should not be involved.
> >>>
> >>> I'll be right back ...
> >>>
> >>>
> >>> 2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
> >>>
> >>>> Hi !
> >>>>
> >>>> I have been happily hacking web sites with T5 for a year and half now
> and
> >>>> is more then pleased!
> >>>> Kudos to all of you for this excellent web framework that makes coding
> >>>> fun again.
> >>>>
> >>>> And I have never ever encountered any defect in the T5 code.
> >>>>
> >>>> Now to my problem.
> >>>>
> >>>> I just got an error in an onActivate method that looked like it could
> not
> >>>> happen.
> >>>>
> >>>> When steeping through it in my debugger I really get puzzled.
> >>>>
> >>>> A variable assigned inside a block is null after leaving the block.
> >>>>
> >>>> It must have something to do with the "plastering" of my code. Or !?
> >>>>
> >>>> The error I get is ..
> >>>>
> >>>> Caused by: java.lang.NullPointerException
> >>>> at
> >>>>
> utskicket.pages.economy.EditYear._$advised$onActivate_13(EditYear.java:91)
> >>>>
> >>>> ... and in the debugger I can see that ledger is null at line 91.
> >>>>
> >>>> In the code below I have commented what happens in the debugger.
> >>>>
> >>>> Can anyone understand what could cause this error ...
> >>>> I have stepped through the generated code without seeing anything
> >>>> strange. It all looks great but when returning ledger is null.
> >>>>
> >>>> Do I break any rule / convention with my code !?
> >>>>
> >>>> Many many thanks in advance,
> >>>> Gunnar Eketrapp, Stockholm, Sweden
> >>>>
> >>>> Environment:
> >>>> *jdk 1.6.0_22*
> >>>> *t5.2.6*
> >>>> *windows 7 proffesional, 32-bit*
> >>>>
> >>>>
> >>>> @Property
> >>>> private Ledger ledger;
> >>>>
> >>>> @Property
> >>>> private String notice;
> >>>>
> >>>> //
> >>>>
> ------------------------------------------------------------------------------
> >>>> // -- Tapestry event methods - Tapestry event methods - Tapestry
> >>>> event methods --
> >>>> //
> >>>>
> ------------------------------------------------------------------------------
> >>>>
> >>>> @Log
> >>>> Object onActivate(long groupId, long ledgerId) {
> >>>>
> >>>> group = groupDAO.findById(groupId);
> >>>> if (group == null)
> >>>> return Index.class;
> >>>>
> >>>> if (ledgerId != 0) {
> >>>> ledger = ledgerDAO.findById(ledgerId);
> >>>> if (ledger == null)
> >>>> return Index.class;
> >>>> if (!same(group.getId(), ledger.getGroup().getId()))
> >>>> return Index.class;
> >>>>
> >>>> hasPrevious = (null != ledgerDAO.findPrevious(ledger));
> >>>> hasNext = (null != ledgerDAO.findNext(ledger));
> >>>> transactionCount =
> transactionDAO.countTransactions(ledger);
> >>>>
> >>>> } else {
> >>>> ledger = new Ledger(); * // 1: This one returns null !!!*
> >>>> Ledger lastLedger = ledgerDAO.findLast(group);
> >>>> if (null == lastLedger) {
> >>>> UTDate today = new UTDate();
> >>>> ledger.setStartDate(new UTDate(today.getYear(), 1,
> 1));
> >>>> *// 2: This line ends the block!*
> >>>> ledger.setEndDate(new UTDate(today.getYear(), 12,
> 31));
> >>>> } else {
> >>>>
> >>>> ledger.setStartDate(lastLedger.getStartDate().warpYears(1));
> >>>>
> ledger.setEndDate(lastLedger.getEndDate().warpYears(1));
> >>>> }
> >>>> }
> >>>>
> >>>> * if (ledger.getClosed()) // 3: And here we crash!*
> >>>> notice = "Året är stängt och kan inte ändras";
> >>>> else {
> >>>> if (!mayEdit())
> >>>> notice = "Endast det senaste året kan ändras.";
> >>>> else if (!mayEditStarts())
> >>>> notice = "Startdagen kan inte ändras då det finns
> >>>> tidigare år.";
> >>>> }
> >>>>
> >>>> return null;
> >>>> }
> >>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> [Hem: 08-715 59 57, Mobil: 070-991 86 42]
> >>> Allévägen 2A, 132 42 Saltsjö-Boo
> >>>
> >>
> >>
> >>
> >> --
> >> [Hem: 08-715 59 57, Mobil: 070-991 86 42]
> >> Allévägen 2A, 132 42 Saltsjö-Boo
> >>
> >
> >
> >
> > --
> > [Hem: 08-715 59 57, Mobil: 070-991 86 42]
> > Allévägen 2A, 132 42 Saltsjö-Boo
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
[Hem: 08-715 59 57, Mobil: 070-991 86 42]
Allévägen 2A, 132 42 Saltsjö-Boo
Re: May Tapestry go wrong ...
Posted by Steve Eynon <st...@googlemail.com>.
Yeah, autoboxing is evil - it's just a compiler convenience thing. If you have:
Boolean closed = null;
boolean isClosed() {
return closed;
}
The compiler transforms it to
boolean isClosed() {
return closed.booleanValue();
}
which of course throws an NPE.
Steve.
--
Steve Eynon
On 3 September 2011 16:04, Gunnar Eketrapp <gu...@gmail.com> wrote:
> Tapestry may not go wrong!
>
> It must has to do with autoboxing in method isClosed() in Ledger.
>
> I was fooled by the debugger and that ledger was shown as null but when
> adding log statements I can see that it isn't.
>
> So I have to read a little bit about aoutoboxing but for sure it was NOT a
> T5 problem!
>
> The call ledger.isClosed() raises a nul pointer but ledgers is not null!
>
> Sorry for disturbing all of you.
>
>
> 2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
>
>> BUT it is also a T5 property so that could be T5 related.
>>
>> The instance seems to created but the T5 property ledger is null after the
>> assignment.
>>
>>
>> 2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
>>
>>> Hum .. sorry .. too early in the morning for me .. Ledger is a hibernate
>>> entity class and T5 should not be involved.
>>>
>>> I'll be right back ...
>>>
>>>
>>> 2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
>>>
>>>> Hi !
>>>>
>>>> I have been happily hacking web sites with T5 for a year and half now and
>>>> is more then pleased!
>>>> Kudos to all of you for this excellent web framework that makes coding
>>>> fun again.
>>>>
>>>> And I have never ever encountered any defect in the T5 code.
>>>>
>>>> Now to my problem.
>>>>
>>>> I just got an error in an onActivate method that looked like it could not
>>>> happen.
>>>>
>>>> When steeping through it in my debugger I really get puzzled.
>>>>
>>>> A variable assigned inside a block is null after leaving the block.
>>>>
>>>> It must have something to do with the "plastering" of my code. Or !?
>>>>
>>>> The error I get is ..
>>>>
>>>> Caused by: java.lang.NullPointerException
>>>> at
>>>> utskicket.pages.economy.EditYear._$advised$onActivate_13(EditYear.java:91)
>>>>
>>>> ... and in the debugger I can see that ledger is null at line 91.
>>>>
>>>> In the code below I have commented what happens in the debugger.
>>>>
>>>> Can anyone understand what could cause this error ...
>>>> I have stepped through the generated code without seeing anything
>>>> strange. It all looks great but when returning ledger is null.
>>>>
>>>> Do I break any rule / convention with my code !?
>>>>
>>>> Many many thanks in advance,
>>>> Gunnar Eketrapp, Stockholm, Sweden
>>>>
>>>> Environment:
>>>> *jdk 1.6.0_22*
>>>> *t5.2.6*
>>>> *windows 7 proffesional, 32-bit*
>>>>
>>>>
>>>> @Property
>>>> private Ledger ledger;
>>>>
>>>> @Property
>>>> private String notice;
>>>>
>>>> //
>>>> ------------------------------------------------------------------------------
>>>> // -- Tapestry event methods - Tapestry event methods - Tapestry
>>>> event methods --
>>>> //
>>>> ------------------------------------------------------------------------------
>>>>
>>>> @Log
>>>> Object onActivate(long groupId, long ledgerId) {
>>>>
>>>> group = groupDAO.findById(groupId);
>>>> if (group == null)
>>>> return Index.class;
>>>>
>>>> if (ledgerId != 0) {
>>>> ledger = ledgerDAO.findById(ledgerId);
>>>> if (ledger == null)
>>>> return Index.class;
>>>> if (!same(group.getId(), ledger.getGroup().getId()))
>>>> return Index.class;
>>>>
>>>> hasPrevious = (null != ledgerDAO.findPrevious(ledger));
>>>> hasNext = (null != ledgerDAO.findNext(ledger));
>>>> transactionCount = transactionDAO.countTransactions(ledger);
>>>>
>>>> } else {
>>>> ledger = new Ledger(); * // 1: This one returns null !!!*
>>>> Ledger lastLedger = ledgerDAO.findLast(group);
>>>> if (null == lastLedger) {
>>>> UTDate today = new UTDate();
>>>> ledger.setStartDate(new UTDate(today.getYear(), 1, 1));
>>>> *// 2: This line ends the block!*
>>>> ledger.setEndDate(new UTDate(today.getYear(), 12, 31));
>>>> } else {
>>>>
>>>> ledger.setStartDate(lastLedger.getStartDate().warpYears(1));
>>>> ledger.setEndDate(lastLedger.getEndDate().warpYears(1));
>>>> }
>>>> }
>>>>
>>>> * if (ledger.getClosed()) // 3: And here we crash!*
>>>> notice = "Året är stängt och kan inte ändras";
>>>> else {
>>>> if (!mayEdit())
>>>> notice = "Endast det senaste året kan ändras.";
>>>> else if (!mayEditStarts())
>>>> notice = "Startdagen kan inte ändras då det finns
>>>> tidigare år.";
>>>> }
>>>>
>>>> return null;
>>>> }
>>>>
>>>>
>>>
>>>
>>> --
>>> [Hem: 08-715 59 57, Mobil: 070-991 86 42]
>>> Allévägen 2A, 132 42 Saltsjö-Boo
>>>
>>
>>
>>
>> --
>> [Hem: 08-715 59 57, Mobil: 070-991 86 42]
>> Allévägen 2A, 132 42 Saltsjö-Boo
>>
>
>
>
> --
> [Hem: 08-715 59 57, Mobil: 070-991 86 42]
> Allévägen 2A, 132 42 Saltsjö-Boo
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: May Tapestry go wrong ...
Posted by Gunnar Eketrapp <gu...@gmail.com>.
Tapestry may not go wrong!
It must has to do with autoboxing in method isClosed() in Ledger.
I was fooled by the debugger and that ledger was shown as null but when
adding log statements I can see that it isn't.
So I have to read a little bit about aoutoboxing but for sure it was NOT a
T5 problem!
The call ledger.isClosed() raises a nul pointer but ledgers is not null!
Sorry for disturbing all of you.
2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
> BUT it is also a T5 property so that could be T5 related.
>
> The instance seems to created but the T5 property ledger is null after the
> assignment.
>
>
> 2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
>
>> Hum .. sorry .. too early in the morning for me .. Ledger is a hibernate
>> entity class and T5 should not be involved.
>>
>> I'll be right back ...
>>
>>
>> 2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
>>
>>> Hi !
>>>
>>> I have been happily hacking web sites with T5 for a year and half now and
>>> is more then pleased!
>>> Kudos to all of you for this excellent web framework that makes coding
>>> fun again.
>>>
>>> And I have never ever encountered any defect in the T5 code.
>>>
>>> Now to my problem.
>>>
>>> I just got an error in an onActivate method that looked like it could not
>>> happen.
>>>
>>> When steeping through it in my debugger I really get puzzled.
>>>
>>> A variable assigned inside a block is null after leaving the block.
>>>
>>> It must have something to do with the "plastering" of my code. Or !?
>>>
>>> The error I get is ..
>>>
>>> Caused by: java.lang.NullPointerException
>>> at
>>> utskicket.pages.economy.EditYear._$advised$onActivate_13(EditYear.java:91)
>>>
>>> ... and in the debugger I can see that ledger is null at line 91.
>>>
>>> In the code below I have commented what happens in the debugger.
>>>
>>> Can anyone understand what could cause this error ...
>>> I have stepped through the generated code without seeing anything
>>> strange. It all looks great but when returning ledger is null.
>>>
>>> Do I break any rule / convention with my code !?
>>>
>>> Many many thanks in advance,
>>> Gunnar Eketrapp, Stockholm, Sweden
>>>
>>> Environment:
>>> *jdk 1.6.0_22*
>>> *t5.2.6*
>>> *windows 7 proffesional, 32-bit*
>>>
>>>
>>> @Property
>>> private Ledger ledger;
>>>
>>> @Property
>>> private String notice;
>>>
>>> //
>>> ------------------------------------------------------------------------------
>>> // -- Tapestry event methods - Tapestry event methods - Tapestry
>>> event methods --
>>> //
>>> ------------------------------------------------------------------------------
>>>
>>> @Log
>>> Object onActivate(long groupId, long ledgerId) {
>>>
>>> group = groupDAO.findById(groupId);
>>> if (group == null)
>>> return Index.class;
>>>
>>> if (ledgerId != 0) {
>>> ledger = ledgerDAO.findById(ledgerId);
>>> if (ledger == null)
>>> return Index.class;
>>> if (!same(group.getId(), ledger.getGroup().getId()))
>>> return Index.class;
>>>
>>> hasPrevious = (null != ledgerDAO.findPrevious(ledger));
>>> hasNext = (null != ledgerDAO.findNext(ledger));
>>> transactionCount = transactionDAO.countTransactions(ledger);
>>>
>>> } else {
>>> ledger = new Ledger(); * // 1: This one returns null !!!*
>>> Ledger lastLedger = ledgerDAO.findLast(group);
>>> if (null == lastLedger) {
>>> UTDate today = new UTDate();
>>> ledger.setStartDate(new UTDate(today.getYear(), 1, 1));
>>> *// 2: This line ends the block!*
>>> ledger.setEndDate(new UTDate(today.getYear(), 12, 31));
>>> } else {
>>>
>>> ledger.setStartDate(lastLedger.getStartDate().warpYears(1));
>>> ledger.setEndDate(lastLedger.getEndDate().warpYears(1));
>>> }
>>> }
>>>
>>> * if (ledger.getClosed()) // 3: And here we crash!*
>>> notice = "Året är stängt och kan inte ändras";
>>> else {
>>> if (!mayEdit())
>>> notice = "Endast det senaste året kan ändras.";
>>> else if (!mayEditStarts())
>>> notice = "Startdagen kan inte ändras då det finns
>>> tidigare år.";
>>> }
>>>
>>> return null;
>>> }
>>>
>>>
>>
>>
>> --
>> [Hem: 08-715 59 57, Mobil: 070-991 86 42]
>> Allévägen 2A, 132 42 Saltsjö-Boo
>>
>
>
>
> --
> [Hem: 08-715 59 57, Mobil: 070-991 86 42]
> Allévägen 2A, 132 42 Saltsjö-Boo
>
--
[Hem: 08-715 59 57, Mobil: 070-991 86 42]
Allévägen 2A, 132 42 Saltsjö-Boo
Re: May Tapestry go wrong ...
Posted by Gunnar Eketrapp <gu...@gmail.com>.
BUT it is also a T5 property so that could be T5 related.
The instance seems to created but the T5 property ledger is null after the
assignment.
2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
> Hum .. sorry .. too early in the morning for me .. Ledger is a hibernate
> entity class and T5 should not be involved.
>
> I'll be right back ...
>
>
> 2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
>
>> Hi !
>>
>> I have been happily hacking web sites with T5 for a year and half now and
>> is more then pleased!
>> Kudos to all of you for this excellent web framework that makes coding fun
>> again.
>>
>> And I have never ever encountered any defect in the T5 code.
>>
>> Now to my problem.
>>
>> I just got an error in an onActivate method that looked like it could not
>> happen.
>>
>> When steeping through it in my debugger I really get puzzled.
>>
>> A variable assigned inside a block is null after leaving the block.
>>
>> It must have something to do with the "plastering" of my code. Or !?
>>
>> The error I get is ..
>>
>> Caused by: java.lang.NullPointerException
>> at
>> utskicket.pages.economy.EditYear._$advised$onActivate_13(EditYear.java:91)
>>
>> ... and in the debugger I can see that ledger is null at line 91.
>>
>> In the code below I have commented what happens in the debugger.
>>
>> Can anyone understand what could cause this error ...
>> I have stepped through the generated code without seeing anything strange.
>> It all looks great but when returning ledger is null.
>>
>> Do I break any rule / convention with my code !?
>>
>> Many many thanks in advance,
>> Gunnar Eketrapp, Stockholm, Sweden
>>
>> Environment:
>> *jdk 1.6.0_22*
>> *t5.2.6*
>> *windows 7 proffesional, 32-bit*
>>
>>
>> @Property
>> private Ledger ledger;
>>
>> @Property
>> private String notice;
>>
>> //
>> ------------------------------------------------------------------------------
>> // -- Tapestry event methods - Tapestry event methods - Tapestry event
>> methods --
>> //
>> ------------------------------------------------------------------------------
>>
>> @Log
>> Object onActivate(long groupId, long ledgerId) {
>>
>> group = groupDAO.findById(groupId);
>> if (group == null)
>> return Index.class;
>>
>> if (ledgerId != 0) {
>> ledger = ledgerDAO.findById(ledgerId);
>> if (ledger == null)
>> return Index.class;
>> if (!same(group.getId(), ledger.getGroup().getId()))
>> return Index.class;
>>
>> hasPrevious = (null != ledgerDAO.findPrevious(ledger));
>> hasNext = (null != ledgerDAO.findNext(ledger));
>> transactionCount = transactionDAO.countTransactions(ledger);
>>
>> } else {
>> ledger = new Ledger(); * // 1: This one returns null !!!*
>> Ledger lastLedger = ledgerDAO.findLast(group);
>> if (null == lastLedger) {
>> UTDate today = new UTDate();
>> ledger.setStartDate(new UTDate(today.getYear(), 1, 1));
>> *// 2: This line ends the block!*
>> ledger.setEndDate(new UTDate(today.getYear(), 12, 31));
>> } else {
>>
>> ledger.setStartDate(lastLedger.getStartDate().warpYears(1));
>> ledger.setEndDate(lastLedger.getEndDate().warpYears(1));
>> }
>> }
>>
>> * if (ledger.getClosed()) // 3: And here we crash!*
>> notice = "Året är stängt och kan inte ändras";
>> else {
>> if (!mayEdit())
>> notice = "Endast det senaste året kan ändras.";
>> else if (!mayEditStarts())
>> notice = "Startdagen kan inte ändras då det finns tidigare
>> år.";
>> }
>>
>> return null;
>> }
>>
>>
>
>
> --
> [Hem: 08-715 59 57, Mobil: 070-991 86 42]
> Allévägen 2A, 132 42 Saltsjö-Boo
>
--
[Hem: 08-715 59 57, Mobil: 070-991 86 42]
Allévägen 2A, 132 42 Saltsjö-Boo
Re: May Tapestry go wrong ...
Posted by Gunnar Eketrapp <gu...@gmail.com>.
Hum .. sorry .. too early in the morning for me .. Ledger is a hibernate
entity class and T5 should not be involved.
I'll be right back ...
2011/9/3 Gunnar Eketrapp <gu...@gmail.com>
> Hi !
>
> I have been happily hacking web sites with T5 for a year and half now and
> is more then pleased!
> Kudos to all of you for this excellent web framework that makes coding fun
> again.
>
> And I have never ever encountered any defect in the T5 code.
>
> Now to my problem.
>
> I just got an error in an onActivate method that looked like it could not
> happen.
>
> When steeping through it in my debugger I really get puzzled.
>
> A variable assigned inside a block is null after leaving the block.
>
> It must have something to do with the "plastering" of my code. Or !?
>
> The error I get is ..
>
> Caused by: java.lang.NullPointerException
> at
> utskicket.pages.economy.EditYear._$advised$onActivate_13(EditYear.java:91)
>
> ... and in the debugger I can see that ledger is null at line 91.
>
> In the code below I have commented what happens in the debugger.
>
> Can anyone understand what could cause this error ...
> I have stepped through the generated code without seeing anything strange.
> It all looks great but when returning ledger is null.
>
> Do I break any rule / convention with my code !?
>
> Many many thanks in advance,
> Gunnar Eketrapp, Stockholm, Sweden
>
> Environment:
> *jdk 1.6.0_22*
> *t5.2.6*
> *windows 7 proffesional, 32-bit*
>
>
> @Property
> private Ledger ledger;
>
> @Property
> private String notice;
>
> //
> ------------------------------------------------------------------------------
> // -- Tapestry event methods - Tapestry event methods - Tapestry event
> methods --
> //
> ------------------------------------------------------------------------------
>
> @Log
> Object onActivate(long groupId, long ledgerId) {
>
> group = groupDAO.findById(groupId);
> if (group == null)
> return Index.class;
>
> if (ledgerId != 0) {
> ledger = ledgerDAO.findById(ledgerId);
> if (ledger == null)
> return Index.class;
> if (!same(group.getId(), ledger.getGroup().getId()))
> return Index.class;
>
> hasPrevious = (null != ledgerDAO.findPrevious(ledger));
> hasNext = (null != ledgerDAO.findNext(ledger));
> transactionCount = transactionDAO.countTransactions(ledger);
>
> } else {
> ledger = new Ledger(); * // 1: This one returns null !!!*
> Ledger lastLedger = ledgerDAO.findLast(group);
> if (null == lastLedger) {
> UTDate today = new UTDate();
> ledger.setStartDate(new UTDate(today.getYear(), 1, 1)); *//
> 2: This line ends the block!*
> ledger.setEndDate(new UTDate(today.getYear(), 12, 31));
> } else {
>
> ledger.setStartDate(lastLedger.getStartDate().warpYears(1));
> ledger.setEndDate(lastLedger.getEndDate().warpYears(1));
> }
> }
>
> * if (ledger.getClosed()) // 3: And here we crash!*
> notice = "Året är stängt och kan inte ändras";
> else {
> if (!mayEdit())
> notice = "Endast det senaste året kan ändras.";
> else if (!mayEditStarts())
> notice = "Startdagen kan inte ändras då det finns tidigare
> år.";
> }
>
> return null;
> }
>
>
--
[Hem: 08-715 59 57, Mobil: 070-991 86 42]
Allévägen 2A, 132 42 Saltsjö-Boo