Nope, no popup plugin, no funny business whatsoever. For context, what I’m trying to do is hide a “new” button if client goes to an actions list form, but show the new button if they’re viewing the same form inside a tabpanel so that only related records can be made…
What about moving the new button to that form which uses your action list form in a tab panel? You still could delegate the “new” functionality to the action list form by calling a method on that form.
Are you aware that the currentcontroller and controller are not REALLY the same in ALL cases?
currentcontroller will give you the main form when using forms in a tabpanel the currentcontroller will still give you the form where the tabpanel is on. Using controllor will give you the form where your controller is at…
In my opinion the button is on the wrong form. Why should a form care about how its use? What about encapsulation, structured programming, building modules (not servoy modules)?
It is not the first time I say this in the forum. But either my explanations are bad or I’m the only one who cares. I don’t think I’m wrong, though
But either my explanations are bad or I’m the only one who cares.
I don’t think it is either. It is simply the way Servoy is structured right now and that might change (or not, I really don’t know).
We simply have a RAD tool named Servoy that does things in a certain way. Some we like, some we don’t.
I think I said it before and I will probably keep saying it. It is because of the ‘limitations’ that Servoy can be a RAD tool. Otherwise we can use Java, C++ etc.
Having that said, I think hinting towards improvements and new structures etc. will never hurt but will keep the Servoy development team striving for more customer satisfaction
The button is hidden on a list of actions form which shows all actions belonging to all users if viewed in isolation (with only the navigator present). I don’t want clients to create actions if the created action is not implicitly related to the parent contact record (this way actions must belong to people). The same button must be visible if the same form is viewed in a tabpanel through a relationship from contacts to actions. My reason for doing it this way is to avoid having to build the actions list form twice (once with the button, once without), and to avoid the possibility that an action can be created without an owner.
If it shouldn’t be on this form, where should it be? considering there are multiple tabs showing related data from multiple list view forms (i.e. I don’t want 15 ‘new line’ buttons on the master form but rather only available when viewing the right related list of data). I guess I’m not seeing the deeper programatic reason for your point but would be grateful if you’d elaborate (I’m always keen to learn more and understand better the way these things are best done. It frustrates me when I have to plough through a problem knowing that there is a more elegant way of doing something, just not knowing how to do it…)
var formname = currentcontroller.getName()
if (formname == ‘actions’)
{
elements.new_button.visible = false
}
if (formname == ‘contacts’)
{
elements.new_button.visible = true
}
the way I understand, currentcontroller will be contacts form if I’m viewing actions through a tabpanel, and the actions form if I’m not. Therefore it’s always going to hide the button if I’m directly in actions and show the button if I’m directly in contacts. Therefore new action records (via the button) cannot be made in the actions form. Is this not right?
thank you both for your replies. I think I often had the same problem as you, Bevil, had with the button. And I’m glad discussion goes into another round
The way I’d look at this action list form:
I call the list form child form.
the form where the list can be used within a tab panel is the parent form.
the dependencies are: parent knows child, child does not know parent (don’t use the parents form name in the child, don’t call methods of the parent by name, don’t assume anything about parents)
if the child can not add actions without having a parent, the functionality does not belong to the child. But the button could. Since this might be the place for the user event.
in our application I have implemented an eventing: a parent registers interest in a child. For this the parent registers itself and a method in a form variable of the child (onShow) for a specific event. If this event occurrs, the child iterates over this registration variable and calls dynamically the parent method. With: ```
executeMethod(formname, methodname)
You may know this from other programming languages. It's what Servoy offers for the same form: You can hook the event onAction. But only the same for can. Any other form cannot.
- in your case: I'd add the button to the child form and disable it by default (or hide it). And I would register the parent at the child and implement the add method in the parent. And why not let the parent enable (or making visible) the add button of the child?
My intention is to decouple the forms. Imagine you add another parent form to your solution which uses the child form in a tab panel. In your solution you need to change the child: You have to extend the if statement in your method: ```
if (formname == 'NewParentForm')...
```.
I try to structure my code and my forms and my modules to avoid these dependencies with a clear hierarchy. Of course: it is a bit more work for a simple button. But my experience tells me that sooner or later as application grows and functionality gets more complex its worth the work.
I hope I expressed my ideas good enough to reconstruct them. And mybe they are of some help.
Regards
Birgit
PS: By the way answers in the forum gave me the idea how to implement the registration: form variables and the method executeMethod(...)