FlexibleOptionGroup

Have you tried to replace your FlexibleOptionGroup with a normal OptionGroup just to see if selection works or not?

Hi,

I’ve got a Vaadin application (6.7) that uses FlexibleOptionGroup (1.0.0) and the application works fine on my local machine development server (Windows - Tomcat 6) as well as on my main server (Linux - Tomcat 6).
I’ve recently been trying to migrate the Vaadin application to the OpenShift (JBoss) platform. It seems that the application is never returning from a

fop.setPropertyDataSource(property);

call, where fop is a FlexibleOptionGroup. I don’t get any exceptions thrown and I can’t figure out why it shouldn’t be returning (the property object I’m passing in appears to be normal). I have a System out just before and after the method call and the one before is displayed fine but the one after is not displayed.

Any ideas on why this method wouldn’t return or throw an exception on my OpenShift platform?

I’d be willing to share more information if you think it would be helpful in solving this mystery…
Thanks…
Kevin

Hi is it possible to add radio button to different columns using flexibleOptionGroup…

Appreciate any input in this regard.

I don’t understand what you mean. Could you elaborate a bit more?

Hi,

Its a very nice and useful add-on, thanks for that.

I have a requirement which leads to put some stylish RadioButton/CheckBox instead what browser provides. So I followed
http://jsbin.com/efewag/2/edit
this website and used images. It uses the Label for the item I add.

Now I have to use this FlexibleOptionGroup component to show Radio/CheckBox in one of the columns in my Vaadin table. In the method of table.addTableColumnGenerator I am returning instance of ItemComponent from the option group.

new ColumnGenerator() {
			@Override
			public Component generateCell(Table source, Object itemId, Object columnId) {
				return optionGrp.getItemComponent(itemId);
			}
		}

It returns one RadioButton/CheckBox, but without the Label element. I tried to add caption with each item by calling optionGrp.setItemCaption(itemId, "Hi"); but its not happening. Is there a way so I can add a blank Label element to each Item it returns. Then only I will be able to manage it with my custom images.

Thanks in advance.

I am getting the following error
constructor of FlexibleOptionGroupItemComponent is not visible when i try to do
FlexibleOptionGroupItemComponent flexibleOptionGroupItemComponent=new FlexibleOptionGroupItemComponent(flexiOptionGroup, itemId);

Hi,

you cannot call the constructor of the FlexibleOptionGroupItemComponent class. This example from add-on’s Directory page shows how to use it:

// Don't add FlexibleOptionGroup to application
FlexibleOptionGroup fop = new FlexibleOptionGroup();
fop.setContainerDataSource(createTestContainer());
fop.setItemCaptionPropertyId(CAPTION_PROPERTY);
fop.setItemIconPropertyId(ICON_PROPERTY);

HorizontalLayout optionGroupLayout = new HorizontalLayout();
for (Iterator<FlexibleOptionGroupItemComponent> iter = fop
                .getItemComponentIterator(); iter.hasNext();) {
        FlexibleOptionGroupItemComponent comp = iter.next();

        // Add FlexibleOptionGroupItemComponents instead
        optionGroupLayout.addComponent(comp);

        Label captionLabel = new Label();
        captionLabel.setIcon(comp.getIcon());
        captionLabel.setCaption(comp.getCaption());
        optionGroupLayout.addComponent(captionLabel);
}
mainWindow.addComponent(optionGroupLayout); 

-Henri

Hi Henri,

The FlexibleOptionGroup component is very useful. I just have a few questions regarding this:

  1. How to handle the radio button or checkbox click event?
  2. How to check if the radio or checkbox is in selected or in de-selected state?
  3. How to programatically clear or reset the selection of radio buttons?

Your response would be very helpful.

Thanks,
Rohan

Hi Rohan,

Hope my answers are useful to u…
2. You can check if radio/ checkbox is selected/ de-selected using

flexibleoptiongroup.isSelected(Object itemid).

  1. To set/unset, flexibleoptiongroup.select(itemid) / flexibleoptiongroup.unselect(itemid).

Thanks,
Poovannan

how to solve this problem?

How to handle the radio button or checkbox click event?

you didn’t answer rohan’s first question, and i have the same problem, any ClickListen event or

tell me how to implement this funtion, thanks~

Thanks for the reply Poovannan. However, I am still waiting for the answer to my 1st question. For time being, I managed to use Layout listener which holds FelxiOptionGroupComponent and associated Label. But this just seems like a workaround to me.

Dear Henri

I am tryingg to use the addon, with 7.2.2 with MVP and CDI implementation, but i get this error

Widgetset ‘com.vaadin.DefaultWidgetSet’ does not contain implementation for org.vaadin.hene.flexibleoptiongroup.FlexibleOptionGroupItemComponent. Check its component connector’s @Connect mapping, widgetsets GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions.

private void setRolesContainer(BeanItemContainer rolesContainer, User u, boolean isReadOnly) {
flexOptionsRoles = new FlexibleOptionGroup(rolesContainer);
flexOptionsRoles.setItemCaptionPropertyId(“name”);
// flexOptionsRoles.setContainerDataSource(rolesContainer);
flexOptionsRoles.setImmediate(true);
flexOptionsRoles.setMultiSelect(true);
flexOptionsRoles.setReadOnly(isReadOnly);

    for (Iterator<FlexibleOptionGroupItemComponent> iter = flexOptionsRoles.getItemComponentIterator(); iter.hasNext();) {

        FlexibleOptionGroupItemComponent compItem = iter.next();

        if (u.getRoles() != null) {
            for (Role role : u.getRoles()) {

                String strRoleName = compItem.getCaption();
                String strSelected = role.getName();

                if (strSelected.equalsIgnoreCase(strRoleName)) {
                    System.out.println(".......EmployeeForm.setRolesContainer() role selected: " + strRoleName + "  ItemComponent " + strSelected);
                    flexOptionsRoles.select(compItem);
                }
            }
        }

        rolesLayout.addComponent(compItem);
        Label captionLabel = new Label();
        captionLabel.setCaption(compItem.getCaption());
        rolesLayout.addComponent(captionLabel);
    }

}

I’m also having this issue. Would be nice if somebody had a solution.
It would be even nicer if Vaadin supported laying out radio buttons any way we need to.

Hi,

there above error message means that you need to compile your own widgetset what would contain client-side part of the FlexibleOptionGroup addon. You can do this for example by using Vaadin Eclipse plugin or Maven. Take a look at the
Book of Vaadin
.

-Henri

Version 2.2.0 of the addon has been released. It’s again compiled with Java 6!

Does this support adding tooltips for items? Unlike native OptionGroup.

Hi,

Yes, it supports because you can use any component (for example a Label) as Item.

Thanks,

-Henri

Hi,
when i use FlexibleOptionGroup add-on (version 2.3) with Vaadin 7.6.6 under OSGi server (Virgo Server) i get the following error:

[code]

Caused by: java.lang.NoClassDefFoundError: com/vaadin/shared/communication/SharedState
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethod(Class.java:2128)
at com.vaadin.server.AbstractClientConnector.findStateType(AbstractClientConnector.java:318)
at com.vaadin.server.AbstractClientConnector.getStateType(AbstractClientConnector.java:305)
at com.vaadin.server.AbstractClientConnector.createState(AbstractClientConnector.java:289)
at com.vaadin.server.AbstractClientConnector.getState(AbstractClientConnector.java:253)
at com.vaadin.ui.AbstractComponent.getState(AbstractComponent.java:751)
at com.vaadin.ui.AbstractField.getState(AbstractField.java:1723)
at org.vaadin.hene.flexibleoptiongroup.FlexibleOptionGroup.getState(FlexibleOptionGroup.java:169)
at org.vaadin.hene.flexibleoptiongroup.FlexibleOptionGroup.getState(FlexibleOptionGroup.java:42)
at com.vaadin.server.AbstractClientConnector.getState(AbstractClientConnector.java:236)
at com.vaadin.ui.AbstractComponent.getState(AbstractComponent.java:746)
at com.vaadin.ui.AbstractField.getState(AbstractField.java:1718)
at com.vaadin.ui.AbstractSelect.getState(AbstractSelect.java:2339)

Caused by: org.eclipse.virgo.kernel.osgi.framework.s: com.vaadin.shared.communication.SharedState in KernelBundleClassLoader: [bundle=hu.xxx.yyy.web_1.0.0.BUILD-SNAPSHOT]

at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:150)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 143 common frames omitted

Caused by: java.lang.ClassNotFoundException: com.vaadin.shared.communication.SharedState
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:146)
… 144 common frames omitted
[/code]What did I wrong? Could anyone help me? Thanks in advance!


Update:
when I imported both com.vaadin.server and com.vaadin.shared bundle, then I got the following exception:

java.lang.RuntimeException: org.eclipse.virgo.kernel.osgi.framework.ImportMergeException: cannot merge imports of package 'com.google.gwt.core' from sources 'Import-Library 'org.springframework.spring' version '3.1.3.RELEASE'(null), Import-Bundle 'com.vaadin.server' version '7.6.6', Import-Bundle 'com.vaadin.shared' version '7.6.6'' because of conflicting values 'com.vaadin.shared', 'com.vaadin.server' of attribute 'bundle-symbolic-name' After I made a little investigation I relalized that both com.vaadin.shared and com.vaadin.server jar have the same base package name: com.google.gwt.core and that’s the problem for OSGi.

So I imported the whole com.vaadin.shared bundle (this bundle has more packages) and I imported all the packages of com.vaadin.server. So I have a big manifest.mf, but it seems to work at the moment.

Hi again!

My next problem with FlexibleOptionGroup is when i redeploy my webapp to the Virgo server (OSGi) I always get the following error, when i click the option item component:
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class …

Every first deploy with newly started server it works fine, but when i redeploy, i always got the following IllegalArgumentException.
Related ticket is here:
https://dev.vaadin.com/ticket/12826#comment:6

But I don’t understand how should i use FlexibleOptionGroup in order not to receiver that error?. Or forget add-ons on OSGi server and use only built-in components?
Any help would be great, thanks!