Method to check three objects at a time

Asked

Viewed 39 times

1

I work with Java and JSF. I have a list of 27 objects and I have a method, called every 20 seconds through Polling, updating a field of these objects.

For very specific reasons, I need this method to update three to three objects.

That is, update three objects, terminate the method and the next time the Polling call the method, it should update the following three objects.

That’s possible?

1 answer

0

You’ll need to put in some Managed bean annotated with PageScoped or SessionScoped, a variable of type int (let’s call it indice) which account from which object should start the verification.

The method that checks (which is also in this Managed bean) access the list of objects, get the three relevant objects and make a indice += 3;. It is also important to put up at least one if somewhere of this method to make sure you are not trying to access the list beyond the limits, which is important in case the list has already finished or has less than three objects remaining.

When all objects have been checked, you can make a indice = 0; for him to resume the process. Or else perform some other action that you deem pertinent.

Stay tuned in case any element is inserted or deleted from the list (assuming there is such a case), otherwise this could mess with your checking.

  • Let me see if I got it right by putting my Managed bean as Pagescope or Sessionscope, the variable I created, Indice, will not lose its value every time my Poll makes a new call in the method, that’s it?

  • @Jason Yes, with the PageScoped or SessionScoped the bean, including all values stored in it, will survive from one request to another.

  • Thank you, I think it will work, I will implement.

  • @Jason If it works, don’t forget to mark my answer as accepted (the green "v" on the left below the answer score). If it doesn’t work, tell me what happened and we’ll see how to solve.

  • OK I’ll do it...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.