0

NULL pointer exception when loading List onTimer

asked 2014-08-05 20:32:08 +0800

elmetni gravatar image elmetni
145 7

hello

i m working on a ZK project using hibernate and Spring .

i got a wierd Null pointer exception when i Reload my list onTimer , and i dont know what i m doing wrong , when i load my list in Init() it works fine and when i Reload after a while using a timer it gives me Null pointer exception on first Index .

here is my timer

<timer delay="@load(ac.refreshDuration)" onTimer="@command('refreshActivite')" repeats="true"></timer>

refreshActivite Command

@Command("refreshActivite")
    @NotifyChange({"listActivites"})
    public void refresh()
    {
        fillActivites();

        Messagebox.show("Hello time");
    }

fillActivites function

@SuppressWarnings("unchecked")
@NotifyChange({"listActivites","visible"})
public  void fillActivites()
{

    listActivites = new ArrayList<Journal>();

    parameters.put("date", getDate(new Date()));
    parameters.put("idProcess", user.getIdProcess());

    listActivites=CRUDService.findWithNamedQuery("Journal.findForUserBar", parameters);

    if(listActivites.size()==0 || listActivites==null )
    {
        visible = false;
    }

    else
    {
        visible = true;
    }


}

anyone had a similar problem and can help me pls ?

delete flag offensive retag edit

Comments

a stacktrace could aways be usefull. and point out where the line numbers are

chillworld ( 2014-08-05 21:53:50 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-08-08 15:06:52 +0800

Alecs gravatar image Alecs
103 5

updated 2014-08-08 16:22:12 +0800

probably the problem is on this line

if(listActivites.size()==0 || listActivites==null )

revert the conditions to

if(listActivites == null || listActivities.isEmpty())

but without a stacktrace I can't be sure

link publish delete flag offensive edit

Comments

+1 for the good catch.

chillworld ( 2014-08-08 15:35:44 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-08-05 20:32:08 +0800

Seen: 7 times

Last updated: Aug 08 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More