You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Poggenpohl, Daniel" <Da...@isst.fraunhofer.de> on 2015/10/07 10:39:03 UTC

SelectModel created by Factory using List

Hi,

I tried to fix some IntelliJ warnings by returning not a List<String> for a select model, 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?

Regards,
Daniel

Re: SelectModel created by Factory using List

Posted by Cezary Biernacki <ce...@gmail.com>.
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.Poggenpohl@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:thiagohp@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.Poggenpohl@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-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

AW: SelectModel created by Factory using List

Posted by "Poggenpohl, Daniel" <Da...@isst.fraunhofer.de>.
Hi,

"Can't coerce a List to a SelectModel".

Regards,
Daniel P.

-----Ursprüngliche Nachricht-----
Von: Thiago H de Paula Figueiredo [mailto:thiagohp@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 <Da...@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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org

Re: SelectModel created by Factory using List

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 07 Oct 2015 05:39:03 -0300, Poggenpohl, Daniel  
<Da...@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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org