Main Content

Magnolia Community Forums: Get help with Magnolia: SwitchableField within MultiValueField throws Exceptions


  • tobiloeb
    tobiloeb
    Full name: Tobias Löbermann
    Posts: 4
    Last post: Sep 18, 2017 1:55:01 PM
    Registered on: Jul 31, 2017
    SwitchableField within MultiValueField throws Exceptions
    #1 by tobiloeb on Aug 31, 2017 2:33:59 PM

    Hello everyone,

    I have a problem with switchable fields within a multifield with the TransformerClass MultiValueSubChildrenNodePropertiesTransformer.
    We need the transformer class to have the reorder possibility for all multiple entries. Currently I am using the switchable field with some other fields in a composite field. The composite field is then placed in the multi field (see code below).

    The creation of multiple (for my case links) fields is working well. But after creating a module with this structure I am not able to edit it again. I always get a ClassCastException because the MultiValueField try to cast my SwitchableFieldDefinition into a MultiValueFieldDefinition.

    Why is it possible to create a module with this configuration but not edit it again? What's going wrong here, maybe I'm using a wrong TransformerClass?

    Thanks for any help.


    SwitchableFieldBuilder switchable = cfg.fields.switchable("switchable_link_")
    .label(linkLabel)
    .description(description)
    .required(isRequired)
    .options(
    new OptionBuilder().value("option1").label("option1").selected(),
    new OptionBuilder().value("option2").label("option2"))
    .layout(Layout.horizontal).fields(
    cfg.fields.text("text1").label("").required(false),
    cfg.fields.text("text2").label("").required(false));

    ArrayList<AbstractFieldBuilder> someOtherFields = new ArrayList<AbstractFieldBuilder>();
    someOtherFields.add(cfg.fields.text("exampleField1").label("").value(""));
    someOtherFields.add(switchable);

    AbstractFieldBuilder compositeField = new CompositeFieldBuilder("link")
    .fields(someOtherFields.toArray(new AbstractFieldBuilder[someOtherFields.size()]))
    .transformerClass(NoOpCompositeTransformer.class)
    .layout(Layout.vertical);

    cfg.fields
    .multi("multiField")
    .label(label)
    .field(compositeField)
    .transformerClass(MultiValueSubChildrenNodePropertiesTransformer.class)
    .description("My description");


    This is how my JCR is looking after creating a module:

    + multiField
    + 00
    + switchable_link_
    - option1 : "THEVALUE"
    - switchable_link_ : "option1"
    - exampleField1: "VALUE"


    Where the Exception is thrown: info.magnolia.ui.form.field.transformer.multi.MultiValueSubChildrenNodePropertiesTransformer

    Caused by: java.lang.ClassCastException: info.magnolia.ui.form.field.definition.SwitchableFieldDefinition$$EnhancerByCGLIB$$9da86851 cannot be cast to info.magnolia.ui.form.field.definition.MultiValueFieldDefinition
    at info.magnolia.ui.form.field.transformer.multi.MultiValueSubChildrenNodePropertiesTransformer.getValueFromChildNode(MultiValueSubChildrenNodePropertiesTransformer.java:154)
    at info.magnolia.ui.form.field.transformer.multi.MultiValueSubChildrenNodePropertiesTransformer.getValueFromChildNode(MultiValueSubChildrenNodePropertiesTransformer.java:92)

  • tobiloeb
    tobiloeb
    Full name: Tobias Löbermann
    Posts: 4
    Last post: Sep 18, 2017 1:55:01 PM
    Registered on: Jul 31, 2017
    Re: SwitchableField within MultiValueField throws Exceptions
    #2 by tobiloeb on Aug 31, 2017 2:35:46 PM

    I am not able to edit my post:

    Here is the JCR again with formatting:

    + multiField
    + 00
    + switchable_link_
    - option1 : "THEVALUE"
    - switchable_link_ : "option1"
    - exampleField1: "VALUE"

You don't have the permission to post on this thread

Sign in

To login on this forum, you can use your Magnolia Forge, Support or Partner account, or, below, your Google, Yahoo! or OpenID account. If you have trouble logging in, or any other sort of issue, please let us know in the Meta forum, on the user-list, or simply by email at forum-admin at magnolia-cms dot com.

* Required

... or sign in with:

  • icon http://{your-openid-url}
  • icon
  • icon https://me.yahoo.com/