Hi,
are you sure that 'collection' is not null?

Best regards,
Cezary


On Fri, Oct 12, 2012 at 5:27 AM, Ken in Nashua <kcola...@live.com> wrote:

>
> Folks,
>
> I am scratching my head about this code which generally was ok in T4...
> things seem fine but when i enter this handler BOOM
>
> My usage of the Math.min(...) hasnt changed... the NPE occurs faithfully
> on the call to Math.min(...)... even after I tried to change the type of
> itemsPerPage from Integer to int
>
> here is my isolated thing...
>
>     @Property
>     @Parameter(required = false, cache = false)
>     private int itemsPerPage = 50;
>
> and I operate in my eventhandler
>
>     @Component(parameters =
>     { "event=lastPage"  })
>     private EventLink lastPage;
>
>     public void onLastPage()
>     {
>         logger.info("In onLastPage : ");
>
>         int minimum = Math.min(itemsPerPage, collection.size());
>         cursor = (collection.size() - minimum);
>     }
>
> Now I use to have itemsPerPage declared as Integer... and in T4 type
> coercing would occur and it ran fine.
>
> I am getting an NPE though... and changing this to int doesnt help.
>
> I thought I would show you the stack trace... maybe someone can spot
> something.
>
> This one is really stumping me and I am blue in the face.
>
> thanks for checking this out
>
> funny thing... my onFirstPage handler works fine... no NPE when i step
> thru that
>     @Component(parameters =
>     { "event=firstPage" })
>     private EventLink firstPage;
>
>     public void onFirstPage()
>     {
>         logger.info("In onFirstPage : ");
>
>         cursor = 0;
>     }
>
> see NPE stack trace below
>

Reply via email to