deltascience
deltascience

Reputation: 3380

Add a property to a component Vaadin

I use Vaadin 7.2.4. I'm wordering if Vaadin provide the possibiliy to add a property to a component. For example the default HTML rendering for a CssLayout is the following:

<div class="v-csslayout v-layout v-widget"></div>

Now I want to add a property for that Layout so it will be like this :

<div class="v-csslayout v-layout v-widget" type="myType" data-toggle="myDataToggle"></div>

Is is possible to do that in Vaadin ?

Upvotes: 1

Views: 1045

Answers (1)

d2k2
d2k2

Reputation: 714

there seems to be no way doing this directly over the vaadin api. i am using jquery for this:

public static void setProperty(Component component, String propertry, boolean enable){

    if(component.getId() == null){
        component.setId(UUID.randomUUID().toString());
    }

    JavaScript.getCurrent().execute("$('#" + component.getId()+ "').attr('" + propertry + "'," + enable + ");");
}

Upvotes: 1

Related Questions