Main Content

Magnolia Community Forums: Get help with Magnolia: Vaadin color picker in component dialog


  • pedro
    pedro
    Full name: Pedro
    Posts: 11
    Last post: Sep 26, 2017 12:51:35 PM
    Registered on: Jul 27, 2017
    Vaadin color picker in component dialog
    #1 by pedro on Sep 22, 2017 1:26:15 PM

    Hi,

    Refering to this post, someone could help me how to display this custom field on component a template component? This is a example of one component that I use for tests:

    @Controller
    @Template(id = "module:components/article/test", title = "test")
    @TemplateDescription("")
    public class Test{

    @RequestMapping("/test")
    public String render() throws RepositoryException {
    return "components/article/test.ftl";

    }

    @TabFactory(" ")
    public void addDialog(UiConfig cfg, TabBuilder tab, DamConfig dam) {


    tab.fields(
    cfg.fields.text("test").label("test")
    );

    }

    }

  • mgeljic
    mgeljic
    Full name: Mikaël Geljić
    Posts: 71
    Last post: Nov 10, 2017 11:28:08 AM
    Re: Vaadin color picker in component dialog
    #2 by mgeljic on Sep 22, 2017 4:11:20 PM

    Hi Pedro,

    You're trying to use a Vaadin component in a template; that's not gonna work, unless you create a custom Renderer to bootstrap a Vaadin app on your frontend page.
    It works in dialogs, because the Magnolia Admincentral is built with Vaadin.

    Probably not worth the overhead, you might have better luck reusing a color-picker on the pure JS side.

    Cheers,
    Mika

    PS: no need for the double-posting, and title of this post should be "Vaadin color picker in component template", not dialog ;)

  • pedro
    pedro
    Full name: Pedro
    Posts: 11
    Last post: Sep 26, 2017 12:51:35 PM
    Registered on: Jul 27, 2017
    Re: Vaadin color picker in component dialog
    #3 by pedro on Sep 26, 2017 12:51:35 PM

    Hi there Mikael,

    First of all, thanks for trying to help me. Probably I miss some explanation on what I want to archive.
    I want that the magnolia user (the one who create the website) could chose a color, for example, to use as background color, for that I need to add a ColorPicker Field in my component. At the moment I have a custom field in my component fully working where the user picks the color and it saves the hexadecimal code to jcr as a String value, the problem is that I can't see the previous color as default in the next component edition, so I'm trying the code in the previous post to update mine.
    So, I'm trying to make something like this:
    ...
    tab.fields(
    new ColorField("color").label("Background color")
    )
    ...



    Best regards,
    Pedro

    Ps.: I'm quite new to this forum :P I'm learning to use it.

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/