Does anyone have any code examples of having 2 levels of parent/child relationships.
The goal is trying to setup a app container that will contain some parent apps to actual working apps. This is kind of like the built in app button controller.
Top level app is basically a wrapper to be a container.
Next level app will act as a management container for worker apps with some configuration
Bottom app has it's own configuration that will submit some data to the Middle level for final processing.
I have the structure and the apps written. I just need to get the UI to cooperate and when trying to navigate to set them up.
Where are you getting stuck? While I don't know of a fully-fleshed example, the reply in that thread seems concrete enough to attempt. You can enumerate the child apps, then create an href element in your parent using the ID from the child app object.
You might even get away with using the app object if you just want a list of the child apps, though that's not mentioned in the thread. I haven't tried that with more than one level of parent-child apps myself, though.
The link I included explains what i experienced perfectly.
I did confirm that what @bravenel linked obviously works (ofcourse it would) but that didn't exactly resolve the issue of creating a this nested solution.
I followed the typical method for creating child/parent apps and relationships with the Parent called out in the definition section of the parent apps and then the Children being created in the Preference section with the app method.
That works fine until you create that nested parent app situation. Based on that linked suggestion I confirmed that you could use a href call to access an app and it's particular page. But that depends on the app being created and you being able to retrieve the appid. So then I started looking at using the addChildApp method to see if i could use that with a simple button to create an app and then programmatically retrieve the appid and then call the href to go into the configuration. I would need to do something similar at each parent app. Seems reasonable, but unfortunately i haven't been able to get the addChildApp call to work. It is currently listed as needing to be documented. So i think what i need is to simply figure that out and then i can piece the rest of it together.
Honestly a simple example app of the top level parent app used for something like Button Controller is exactly what i am looking for. I don't need it to do anything other then create the next level parent app to help organize all of the app instances underneath it. So far the only examples i have see of this method though are built in apps, and of course we don't have access to their code.
A little bit more persistence is all that may have been needed. I just managed to create a app with the addChildApp method. So I will keep digging into this.
So i have done what I mentioned above. I have a button that creates a child app. In the Button actions it submits the create and then immediately follows with retrieving the child apps App ID. The next action i am trying to do is have module then call the page as @bravenel suggested in the linked thread. When i do that i am getting a error". It is as follows
java.lang.NullPointerException: Cannot Get property 'body' on null Object on line xxx (method appButtonHandler).
I think this means for some reason it can't get load it. But I can put in the URL and it works. I even hardcoded the URL to ensure there wasn't a programing problem and it didn't work.
The line i am using is as follows. Before this executes i extract the app id into variable newApp and the lable into newAppLabel.
To see if this will work outside of the button handler and I was created a section in the main setup page. That did seem to work, as now I can see the instance and when I click on the newly created link it takes me into the setup page. But this just adds another step to the process.
OK so that means I will need a button to build the child instance. And then once that is done a href in a separate part of the UI that can then open up that child instance of the app.
It is too bad the regular parent/child stuff gets messed up when more than two levels are used.
No, it just means that you don't do this in appButtonHandler(). appButtonHandler is not part of the app's UI, it is outside it, as it is basically a callback method. The way you fix this is set a state variable in appButtonHandler, and check for that in the UI portion of your code. Assuming that you are using submitOnChange: true for inputs, or using a button (that submits the page after calling appButtonHandler), this test just goes in the same method that put up the button or input. Be sure to clear that state variable within the code block that discovers it true.
Not really. This has implications in the Apps page UI, where the nesting has to be dealt with. By going further, that page would get very messy and the understandability of nested parent/child relationships goes out the window. Complexity is not your friend, and certainly not a friend to users.
The top level in my case needs to do no more then what the button controllers top most level does. Just create the app instance below it and send you to it. But i can't seem to find options to make that happen. I have now replaced the creation method with with href calls similar to what was discuss above and i am still experiencing problems when clicking done from the middle parent app. It doesn't go back to the top level and it doesn't exit. It just puts you back to the child app you last went into.
I tried to do what you mentioned above and I must be missing something. I will display the link to go to the app, but it isn't immediately navigating to the URL once it validates the state value.
Maybe it isn't possible to do this with a user developed app which is a reasonable possiblity. But that shows exactly what i am trying to accomplish.
For that top-level app, have you considered just using an app control?
section("<b>Prestaging Rules:</b>") {
app(name: "anyOpenApp", appName: "Virtual Prestaging Child", namespace: "evequefou", title: "<b>Create a new prestaging rule</b>", multiple: true)
}
The href model works when you need to link to particular pages or include the links particular places in the UI, but this control is really easy for listing child instances.
That line did trigger the top level Parent wrapper app to immediately open up the newly created child app. This still didn't fix the issue though i have been trying to fix all along. It seems that regardless of which method you use to go down the levels once you get to that middle teir of the parent child relationship, the done button gets mesed up. It also doesn't seem to matter that you open up the middle app directly like we often do with Button controller.
Any other ideas on how to get this to work. Honestly I wouldn't even mind it if i just had to to put code in for each "Done" button to tell it what to do and where to go. If i did that Is there a good way to get it in the same spot as the regular Done button. I would want to keep it in the same spot if possible.
It seems that the button URL is getting messed with the wrong URL when a parent app is also a child app. So going along with the whole point of this thread.
Top Teir app is basically a wrapper and creates child app that manages instances of the app.
Middle Teir app is the app instance with some configuration for that instance.
Third(actually functional child app) that handles process for a instance and interact with parent app for certain functions.
It isn't hard to create the apps with that structure. The problem is that when you go to the Middle teir app and then click on the third teir app to do some configuration changes and click done. The Done button on the middle teir app just redirects you back to the Third teir app when clicked to close close out configuration.