You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ebt <no...@gmail.com> on 2010/07/08 00:59:32 UTC

Where to define this class?

I have a class that I am using for each row in a grid, it is the mix of
multiple entities data. the question is where to put it? I tried placing the
class in the component package and instantiating it within my page, tried
returning the class from an injected service, and nesting the class within
the page POJO. in all cases it will work once and then on refresh I get this
error:

Failure writing parameter 'row' of component admin/Add:grid.rows: Failure
writing parameter 'row' of component admin/Add:grid: Could not find a
coercion from type com.foo.bar.pages.admin.Add$RolesRow to type
com.foo.bar.pages.admin.Add$RolesRow.


here is the class

   public static class RolesRow{
    @Property public Boolean ROLE_SUPER;
    @Property public Boolean ROLE_ADMIN;
    @Property public Boolean ROLE_USER;
    @Property public Boolean ROLE_VIEW;
    @Property public Boolean ROLE_EMAIL;
    private Map<String,Role> roles;
    public RolesRow(){

    }
    public RolesRow(Map<String,Role> roles){
        ROLE_SUPER = (roles.containsKey("ROLE_SUPER") ? true:false);
        ROLE_ADMIN = (roles.containsKey("ROLE_ADMIN") ? true:false);
        ROLE_USER =  (roles.containsKey("ROLE_USER") ? true:false);
        ROLE_VIEW =  (roles.containsKey("ROLE_VIEW") ? true:false);
        ROLE_EMAIL = (roles.containsKey("ROLE_EMAIL") ? true:false);
        this.roles = roles;
    }
    public List<Role> selected(){
        List<Role> r = new ArrayList<Role>();
        checked(r,"ROLE_SUPER",ROLE_SUPER);
        checked(r,"ROLE_ADMIN",ROLE_ADMIN);
        checked(r,"ROLE_USER",ROLE_USER);
        checked(r,"ROLE_VIEW",ROLE_VIEW);
        checked(r,"ROLE_EMAIL",ROLE_EMAIL);
        return r;
    }
    private void checked(List<Role> r,String field,Boolean obj){
        if (obj !=null && obj == true){
            r.add(roles.get(field));
        }

    }
I am instantiating the record in setupRender:

        void setupRender(){
         List<RolesRow> list = new ArrayList<RolesRow>();
     list.add(new RolesRow());
-- 
View this message in context: http://old.nabble.com/Where-to-define-this-class--tp29100001p29100001.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Where to define this class?

Posted by ebt <no...@gmail.com>.
Ahh, makes sense now. I changed all the fields to public because of that
little gotcha. 


Josh Canfield wrote:
> 
>> I have a class that I am using for each row in a grid, it is the mix of
>> multiple entities data. the question is where to put it?
> 
> Are you using it in more than one page? With a tiny view class I
> sometimes just stick it right in the page/component that uses it.
> Otherwise, like Thiago said, you need to put it in a package that's
> not special to tapestry. How about /viewobject or /vo
> 
> By the way
>>    @Property public Boolean ROLE_SUPER;
> This only works in your page and component classes. You'll need to
> create your own getter/setters.
> 
> Josh
> 
> On Wed, Jul 7, 2010 at 3:59 PM, ebt <no...@gmail.com> wrote:
>>
>> I have a class that I am using for each row in a grid, it is the mix of
>> multiple entities data. the question is where to put it? I tried placing
>> the
>> class in the component package and instantiating it within my page, tried
>> returning the class from an injected service, and nesting the class
>> within
>> the page POJO. in all cases it will work once and then on refresh I get
>> this
>> error:
>>
>> Failure writing parameter 'row' of component admin/Add:grid.rows: Failure
>> writing parameter 'row' of component admin/Add:grid: Could not find a
>> coercion from type com.foo.bar.pages.admin.Add$RolesRow to type
>> com.foo.bar.pages.admin.Add$RolesRow.
>>
>>
>> here is the class
>>
>>   public static class RolesRow{
>>    @Property public Boolean ROLE_SUPER;
>>    @Property public Boolean ROLE_ADMIN;
>>    @Property public Boolean ROLE_USER;
>>    @Property public Boolean ROLE_VIEW;
>>    @Property public Boolean ROLE_EMAIL;
>>    private Map<String,Role> roles;
>>    public RolesRow(){
>>
>>    }
>>    public RolesRow(Map<String,Role> roles){
>>        ROLE_SUPER = (roles.containsKey("ROLE_SUPER") ? true:false);
>>        ROLE_ADMIN = (roles.containsKey("ROLE_ADMIN") ? true:false);
>>        ROLE_USER =  (roles.containsKey("ROLE_USER") ? true:false);
>>        ROLE_VIEW =  (roles.containsKey("ROLE_VIEW") ? true:false);
>>        ROLE_EMAIL = (roles.containsKey("ROLE_EMAIL") ? true:false);
>>        this.roles = roles;
>>    }
>>    public List<Role> selected(){
>>        List<Role> r = new ArrayList<Role>();
>>        checked(r,"ROLE_SUPER",ROLE_SUPER);
>>        checked(r,"ROLE_ADMIN",ROLE_ADMIN);
>>        checked(r,"ROLE_USER",ROLE_USER);
>>        checked(r,"ROLE_VIEW",ROLE_VIEW);
>>        checked(r,"ROLE_EMAIL",ROLE_EMAIL);
>>        return r;
>>    }
>>    private void checked(List<Role> r,String field,Boolean obj){
>>        if (obj !=null && obj == true){
>>            r.add(roles.get(field));
>>        }
>>
>>    }
>> I am instantiating the record in setupRender:
>>
>>        void setupRender(){
>>         List<RolesRow> list = new ArrayList<RolesRow>();
>>     list.add(new RolesRow());
>> --
>> View this message in context:
>> http://old.nabble.com/Where-to-define-this-class--tp29100001p29100001.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> 
> -- 
> --
> http://www.bodylabgym.com - a private, by appointment only, one-on-one
> health and fitness facility.
> --
> http://www.ectransition.com - Quality Electronic Cigarettes at a
> reasonable price!
> --
> TheDailyTube.com. Sign up and get the best new videos on the internet
> delivered fresh to your inbox.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Where-to-define-this-class--tp29100001p29103188.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Where to define this class?

Posted by Josh Canfield <jo...@gmail.com>.
> I have a class that I am using for each row in a grid, it is the mix of
> multiple entities data. the question is where to put it?

Are you using it in more than one page? With a tiny view class I
sometimes just stick it right in the page/component that uses it.
Otherwise, like Thiago said, you need to put it in a package that's
not special to tapestry. How about /viewobject or /vo

By the way
>    @Property public Boolean ROLE_SUPER;
This only works in your page and component classes. You'll need to
create your own getter/setters.

Josh

On Wed, Jul 7, 2010 at 3:59 PM, ebt <no...@gmail.com> wrote:
>
> I have a class that I am using for each row in a grid, it is the mix of
> multiple entities data. the question is where to put it? I tried placing the
> class in the component package and instantiating it within my page, tried
> returning the class from an injected service, and nesting the class within
> the page POJO. in all cases it will work once and then on refresh I get this
> error:
>
> Failure writing parameter 'row' of component admin/Add:grid.rows: Failure
> writing parameter 'row' of component admin/Add:grid: Could not find a
> coercion from type com.foo.bar.pages.admin.Add$RolesRow to type
> com.foo.bar.pages.admin.Add$RolesRow.
>
>
> here is the class
>
>   public static class RolesRow{
>    @Property public Boolean ROLE_SUPER;
>    @Property public Boolean ROLE_ADMIN;
>    @Property public Boolean ROLE_USER;
>    @Property public Boolean ROLE_VIEW;
>    @Property public Boolean ROLE_EMAIL;
>    private Map<String,Role> roles;
>    public RolesRow(){
>
>    }
>    public RolesRow(Map<String,Role> roles){
>        ROLE_SUPER = (roles.containsKey("ROLE_SUPER") ? true:false);
>        ROLE_ADMIN = (roles.containsKey("ROLE_ADMIN") ? true:false);
>        ROLE_USER =  (roles.containsKey("ROLE_USER") ? true:false);
>        ROLE_VIEW =  (roles.containsKey("ROLE_VIEW") ? true:false);
>        ROLE_EMAIL = (roles.containsKey("ROLE_EMAIL") ? true:false);
>        this.roles = roles;
>    }
>    public List<Role> selected(){
>        List<Role> r = new ArrayList<Role>();
>        checked(r,"ROLE_SUPER",ROLE_SUPER);
>        checked(r,"ROLE_ADMIN",ROLE_ADMIN);
>        checked(r,"ROLE_USER",ROLE_USER);
>        checked(r,"ROLE_VIEW",ROLE_VIEW);
>        checked(r,"ROLE_EMAIL",ROLE_EMAIL);
>        return r;
>    }
>    private void checked(List<Role> r,String field,Boolean obj){
>        if (obj !=null && obj == true){
>            r.add(roles.get(field));
>        }
>
>    }
> I am instantiating the record in setupRender:
>
>        void setupRender(){
>         List<RolesRow> list = new ArrayList<RolesRow>();
>     list.add(new RolesRow());
> --
> View this message in context: http://old.nabble.com/Where-to-define-this-class--tp29100001p29100001.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
--
http://www.bodylabgym.com - a private, by appointment only, one-on-one
health and fitness facility.
--
http://www.ectransition.com - Quality Electronic Cigarettes at a
reasonable price!
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


Re: Where to define this class?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 07 Jul 2010 19:59:32 -0300, ebt <no...@gmail.com> wrote:

> I have a class that I am using for each row in a grid, it is the mix of
> multiple entities data. the question is where to put it?

Any package that isn't components, pages, mixins or base.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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