Похожие чаты

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

5 просмотров

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!

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

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

Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
Добрый вечер. Есть вопрос, а может и предложение. Был у меня диалог в другой группе о делфи и я задался вопросом: "А нельзя ли в делфи цвет //коментария и {комментария} сде...
Kraszx
24
Всем привет! Подскажи, пожалуйста, как передать в TComboBox сразу значение и id записи. На Delphi я делал так: ComboBox1.Items.AddObject('Какое-то значение', Pointer(id запис...
Евгений
13
Мдя, прикол, боевая сборка запускается (именно под отладчиком) после F9 примерно полторы минуты (97 секунд если быть точным). Начал копать - проблема детектится сразу - зависа...
Александр (Rouse_) Багель
38
How are we going bro about the Raids ??
🅿️abby_FX
13
я так понимаю, я так подозреваю, что создание такого плагина для человека, кто умеет писать плагины для делфи потребует минут 5-10 времени. но это мое подозрение. хотелось бы ...
Kraszx
7
Товарищи, кто работа с iphelper? Или может я в самой логике ошибки фигачу, не пойму.... var ifTable : PMIB_IFTABLE; size, corSize: DWORD; Buffer ...
Warfarellen
4
Здравствуйте, вопрос по структурам данных. Были у вас случаи, когда пришлось писать деревья или двунаправленные списки?
/ /
50
Keep saying it, it’s Trump or WW3. Iran will be emboldened if Harris wins by cheating. Israel will have to take the initiative against Iran. How has BTC faired everytime the...
Adz | Ferrum Network Product & Service Consultant @ Ferrum Network
1
Коллеги, добрый вечер. Создаю коллекцию от TFPGMap, ключ - перечисление, значение - целое. Нужно отсортировать коллекцию по значению. Как это можно сделать?
Kirill Filippenok
11
Карта сайта