Похожие чаты

Hey guys. Question here: I have a Java class with

some methods. This methods use some FLAGS that are declared as private booleans as false attributes. My application is a web one, so it's executing on a browser and this class executes its methods when the user clicks on a button and flags are false. The problem is the following: first time code executes well, flags are put to true (correct behaviour) after conditions for execution are met. The following times the user clicks on the button the code is not executing because the flags are true already. Is there a way to "clean2 this flags when the method of this class is called from the outside? I cannot know which class is executing because there are plenty and, depending on some data, class A,b,C or D will execute via reflection. So I'm not sure if I can call a constructor or smth like that. Thank you so much!

8 ответов

6 просмотров

No sure whether I understood it correctly. But it seems that you are looking for ! negation logical operator: var flagState = flagHolder.getFlag(); flagHolder.setFlag( ! flagState);

I do have some questions on this: 1. Why can't you simply set the flags to false from outside? 2. If that is not allowed, is it the case where the class which you are trying to execute again on user click is supposed to execute only once? If so then understand why it was designed that way. 3. If you realise it was designed that way then there's something that you are doing wrong.

.- Автор вопроса
Anish
I do have some questions on this: 1. Why can't you...

1. Because the class executing as well as its method its obtained via java reflection, dynamic. I guess i could try to call a clean method or a constructor, but i would need to hard code the name of the method i guess? 2. No, it can be executed many times. It generates some information for the user on click event.

.- Автор вопроса
Dmytro Buryak
No sure whether I understood it correctly. But it ...

Thank you for the answer! I think i did not explain myself well enough haha

.
1. Because the class executing as well as its meth...

1. I am sorry, I have limited experience with reflections. 2. If that is the case then why are those flags limiting the methods from being executed multiple time?

.- Автор вопроса
Anish
1. I am sorry, I have limited experience with refl...

1. No problem man :) 2. Its a bit complex to explain here. But the thing is the first time flags are set to true, then the second time they are already true. During the execution of this class, some methods are called more than once but some parts of them must be executed only one time, thats why there are flags.

.
1. No problem man :) 2. Its a bit complex to expl...

Let me ask this. If there was no reflection involved, would the problem be different? Still I can't understand what is the problem. Based on your description void yourMethod() { // code that will be always executed if (!wasBlock1executed) { // block1 which should be executed only once // ... wasBlock1Executed = true; } if (block2NumExec <= 3) { // block2 should be executed no more than 3 times // ... block2NumExec++; } } Anyway, we're playing guessing game here. You won't get any real help without showing exact code which you're having problem with

.- Автор вопроса
Dmytro Buryak
Let me ask this. If there was no reflection involv...

Thank you for your time. I will try to pass by tomorrow and show some code!

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта