Touchkit 2 with required field missing asterisk

I’m experimenting with touchkit 2.1.3 and I have a form which dynamically makes fields visible/invisible required/not required depending on other user entries. It all works perfectly on a non-touchkit application. I added a UI using touchkit and it all works almost perfectly. The one thing that doesn’t quite work is when a field changes from not required to required I don’t see the red asterisk appear.
The asterisk does appear if I make the field visible+required when it was invisible. But once it is visible+unrequired if I then make it required then no asterisk. The underlying field does seem to be required so I think it is just rendering wrong.

The code is simple enough:

field.setRequired(true);
field.requestRepaint();

I’ll try this on Vaadin7 in a couple of weeks but some logistics prevent that just now.
Is there something else I ought to be doing with Touchkit 2?
Thanks
Roger

Edit: I just noticed that if I make the field invisible then make it required+visible it doesn’t become visible. The field is initially invisible and the first time I make it visible+required I see the asterisk. But subsequent times I think it is not rendering at all when visible+required. Visible+unrequired does make it visible. Is there something more complicated about rendering a field with required that I missed?

Hi,

The “required field indicator” is on responsibility of the component container, so the issue might be in some layout component in TouchKit or its styles. Into what type of component do you place your components? I’d appreciate if you can create a short test case and place a ticket about this to dev.vaadin.com.

I guess you could overcome this issue by using FormLayout like in e.g.
this example
. Then it should work like with std. Vaadin (unless the failure is with TouchKit’s FormLayout styles).

I’d suggest to not hurry with V7 upgrade. It is a major upgrade and there are still nasty issues, especially with touch devices and TouchKit.

cheers,
matti

BTW. That field.requestRepaint() line should never be needed in Vaadin.

Thanks for the quick reply.

The required field is in a com.vaadin.ui.Form
That is added to a com.vaadin.addon.touchkit.ui.VerticalComponentGroup
which is added to com.vaadin.ui.CssLayout
which is setContent() into the mainWindow
which is a com.vaadin.addon.touchkit.ui.TouchKitWindow.TouchKitWindow()

I added a com.vaadin.ui.FormLayout wrapper around the Form and I get
com.vaadin.ui.FormLayout(NO CLIENT IMPLEMENTATION FOUND) in the resulting display.
I didn’t find a touchkit FormLayout
I also tried using com.vaadin.addon.touchkit.ui.NavigationView in place of FormLayout but I got the same NO CLIENT IMPLEMENTATION FOUND message.

Finally I tried upgrading to 2.1.5 and recompiled my widgets. No change.

I will cook up a small demo asap and I will review the need for the repaints.
If it is any use the whole thing is running at http://pizzaorder.cloudfoundry.com/
(pick ‘medium’ to see a requied field appear, pick large or small for the requiredness to go away, then pick medium again and it should, but doesn’t reappear)
The code for this is spread across two libraries you probably don’t want to wade through but here they are anyway:
http://code.google.com/p/madura-pizzaorder/
http://code.google.com/p/madura-vaadinsupport/

I’ll do something more compact in a few days.

Thanks
Roger

Yep, it was the FormLayout as Matti suggested. To be precise it was the lack of FormLayout. Here’s what happened.
I copied the Vornithologist widgetset to get started and it includes a WidgetMapGenerator which was new to me.
In the WidgetMapGenerator you can comment out various kinds of components to make the download smaller and one of the things commented out was FormLayout. When I put together my form I hit problems with that because Form requires a FormLayout internally. Rather than add FormLayout I changed the internal component to a com.vaadin.addon.touchkit.ui.VerticalComponentGroup.VerticalComponentGroup which I figured would likely play nicely with the other touchkit stuff. And almost everything did work just fine, only the required asterisk gave a problem.

So now I have uncommented FormLayout in WidgetMapGenerator and I am using the (default) FormLayout in the Form and it all works fine.
Problem solved.