How to get data from dialog in custom action (v6.2)

442 views
Skip to first unread message

Stefan Brockwitz

unread,
Nov 10, 2021, 6:45:16 AM11/10/21
to Magnolia User Mailing List
Hi everyone,

I created a dialog and a custom Action for saving the data.
In dialog is a multi field with pagelink-fields.
The valueContext is just the entry that the dialog is for.
The Question is: Where can I get the pagenodes out of the FormView?
formView.getPropertyNames() give just the name of multiField but formView.getPropertyValue("pages") gives an Optional.Empty instead of selected nodes.

Thank you


Roman Kovařík

unread,
Nov 11, 2021, 2:01:03 AM11/11/21
to Magnolia User Mailing List, stefan.b...@neofonie.de
Hello Stefan,

we are collecting some examples here. Could you share your use case (the dialog definition and the action logic)?

Hope that helps
Roman

Stefan Brockwitz

unread,
Nov 11, 2021, 8:28:15 AM11/11/21
to Magnolia User Mailing List, roman....@magnolia-cms.com, Stefan Brockwitz
Hi,

I have no access to Git (but Magnolia - Jira and so on).
The ActionDefinition:
package templating.action;

import info.magnolia.ui.api.action.ConfiguredActionDefinition;

public class PagesActionDefinition extends ConfiguredActionDefinition {

    public PagesActionDefinition() {
        setImplementationClass(PagesAction.class);
    }
}
Other definitions are attached.
The Dialog is opened from an app, so the ValueContext is the entry from Grid.
But how to get selected page nodes?

Thanks in Advance
PagesAction.java
pages-dialog.yaml

Roman Kovařík

unread,
Nov 12, 2021, 7:58:37 AM11/12/21
to Magnolia User Mailing List, stefan.b...@neofonie.de, Roman Kovařík
Hello again,

The linked examples are similar to your use case.

Regards
Roman

Stefan Brockwitz

unread,
Nov 12, 2021, 8:23:39 AM11/12/21
to Magnolia User Mailing List, roman....@magnolia-cms.com, Stefan Brockwitz
Yes this is a functional Possibility, but is this really the only way to get the data out of Validation Binders? Seems like a really hacky way.

Thank you

Roman Kovařík

unread,
Nov 12, 2021, 9:04:59 AM11/12/21
to Magnolia User Mailing List, stefan.b...@neofonie.de, Roman Kovařík
I wasn't sure if it's about a validation or another operation. Maybe you want something like this (a combination or the first and second example)?

Stefan Brockwitz

unread,
Nov 15, 2021, 4:34:54 AM11/15/21
to Magnolia User Mailing List, roman....@magnolia-cms.com, Stefan Brockwitz
The Operation is just a bulk action.
So you click in a grid on a button where this dialog will open.
Then you select some pages and click on save.
In the commit - action we get the selected page nodes and set the entry from grid to a custom component in this nodes.
I hoped that there is a simple way like form.getPropertyValue("pages"), but it seems not...

Roman Kovařík

unread,
Nov 16, 2021, 8:11:52 AM11/16/21
to Magnolia User Mailing List, stefan.b...@neofonie.de, Roman Kovařík
Hi Stefan,

Thanks for the use case. I've tried to use this dialog:

form: implementationClass: info.magnolia.ui.field.AddPageLinksMultiFormView properties: pages: $type: jcrMultiField itemProvider: $type: jcrChildNodeProvider nodeName: links orderHandler: class: info.magnolia.ui.editor.MultiFormDefinition$OrderHandlerDefinition$Noop field: $type: compositeField properties: pages: $type: pageLinkField

with this form implementation:

public class PagesMultiFormView extends MultiFormView<Node> { @Inject public PagesMultiFormView(MultiFormDefinition<Node> formDefinition, LocaleContext localeContext, Datasource<Node> datasource) { super(formDefinition, localeContext, datasource); } @SneakyThrows @Override public void write(Node node) { for (Node page : valueContext.get().collect(Collectors.toSet())) { final Iterator<Node> nodeIterator = QueryUtil.search("website", "select * from [mgnl:component] where" + " [mgnl:template] = 'mtk2:components/textImage'" + " AND ISDESCENDANTNODE('" + page.getPath() + "')" ); nodeIterator.forEachRemaining(super::write); } } }

which is then stored like
'0': 'mgnl:template': 'mtk2:components/textImage' 'links': 'pages0': 'jcr:uuid': '87d2027c-a5fd-44c5-93d8-505f8da658ed' 'pages': 'b06b82a2-74b0-4994-8015-028c4fd60716' ...
  • no custom action depending on certain dialog configuration
  • the storage strategy is driven by the dialog config
I also understand the need to do this the old way, so I've create a PoC for accessing complex field value via the API https://git.magnolia-cms.com/projects/PLATFORM/repos/ui/pull-requests/1935/overview. Not sure if this gets a priority though. 

Roman

Roman Kovařík

unread,
Mar 22, 2024, 3:54:38 AMMar 22
to Magnolia User Mailing List, Roman Kovařík, stefan.b...@neofonie.de
Hey again,

Just for the record, since there were multiple requests for this, MGNLUI-8082 will be included in Magnolia 6.3.  

Roman

Reply all
Reply to author
Forward
0 new messages