Похожие чаты

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 ответов

3 просмотра

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!

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

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

Do any of you guys have interesting projects one could join? I'm a Middle Full-Stack developer (JS/TS, React & Node)
Lev Shapiro
38
Типа вызывать GetParent и проверять на соответствие GetModuleHandle?
The Bird of Hermes
67
$res = json_decode($наша строка из респонса); $res1 = array_map(fn($o) => $o->name, $res->breadcrumbs[0]->entities); Как такое будет на Хаскеле?.. В начале весь джейсон, в ко...
Хаскель Моисеевич Гопник
24
Вопрос по диагностике ошибок (я знаю в чем, в данном конкретном примере, я знаю, как исправить, пример модельный, понятно, что в реальности бывает намного запутаннее). module...
ⰄⰎⰋⰐⰐⰑⰛⰤⰧⰧⰩⰄ ⰊⰑⰁⰓⰡⰛⰦⰕⰫ
10
Хтось використовував Vapor на Windows?
Jaroshevskii
15
I read yesterday that in the near future most cryptos will be gone. It's like there is a lot of bullshit within the crypto sphere and this corruption some way is going to be c...
Kanah The Great
25
Тут кста кто-нибудь NeoVim использует?
Simple Sorcerer
13
А чем вам питонисты не угодили?😂
.
79
у меня вопрос на счет .global <name> для чего это нужно если я пишу на ассемблере? только для того что бы сделать это видимым для линкера? вот что написано в докумментации GA...
Simple Sorcerer
1
Есть какой-нибудь для Delphi/FPC T*Compression(Decompression)Stream на базе LZ4/Zstd/любой другой быстрый(и хорошо сжимающий) алгоритм А ещё лучше в pure pascal А ещё лучше од...
notme
52
Карта сайта