Hi Daniel, it is a bug in IntelliJ: for some reason it does not recognise all Tapestry coercions. You can still run your application, as the warning does not affect compilation. The best course of the action is to report the bug to JetBrains and get them fixed. If you really need to remove the warning just to get no warning state, and you cannot wait for the fix from JetBrains and, you can use:
- pre 5.4: TapestryInternalUtils.toSelectModel(), though it is not a great idea to use non-public API. - 5.4: SelectModelFactory.create(List<Object> objects) method If you are not yet using Tapestry 5.4 and do not like to use TapestryInternalUtils, than yes, SelectModelFactory.create(List<?> objects, String labelProperty) is one of your option. "labelProperty" should be a name of property (in JavaBeans sense) on each object passed in the list that will be used as a client side label. If you would pass your own objects in the list, you would just need to add a getter e.g. "getName()" and specify "name" as "labelProperty", but String lacks appropriate method to be used. Another option is to use TypeCoercer, e.g.: "SelectModel model = typeCoercer.coerce(myList, SelectModel.class)". Best regards, Cezary On Wed, Oct 7, 2015 at 4:48 PM, Poggenpohl, Daniel < daniel.poggenp...@isst.fraunhofer.de> wrote: > Hi, > > "Can't coerce a List to a SelectModel". > > Regards, > Daniel P. > > -----Ursprüngliche Nachricht----- > Von: Thiago H de Paula Figueiredo [mailto:thiag...@gmail.com] > Gesendet: Mittwoch, 7. Oktober 2015 16:11 > An: Tapestry users > Betreff: Re: SelectModel created by Factory using List<String> > > On Wed, 07 Oct 2015 05:39:03 -0300, Poggenpohl, Daniel < > daniel.poggenp...@isst.fraunhofer.de> wrote: > > > Hi, > > Hi! > > > I tried to fix some IntelliJ warnings by returning not a List<String> > > for a select model, > > Tapestry has a built-in conversion from List to SelectModelFactory so it's > a completely valid object to pass to the model parameter of > SelectModel-based components. I don't know why IntelliJ is showing you a > warning for that. What exactly does the warning say? > > > but rather a SelectModel created using the SelectModelFactory.create > > method. The method takes two parameters. If I give a List<String> as > > the objects, what labelProperty do I have to set then? > > You don't. > > -- > Thiago H. de Paula Figueiredo > Tapestry, Java and Hibernate consultant and developer > http://machina.com.br > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org >